jon.recoil.org

Module Measure_object_files

Measuring allocated section sizes in object files.

This module computes the total size of allocated ELF sections across a collection of object files, archives, and OCaml compilation units.

type error =
  1. | File_not_found of string
  2. | Duplicate_file of string

Errors that can occur when measuring object files.

exception Error of Measure_object_files.error

Exception wrapper for measurement errors.

Pretty-print a measurement error.

type file_origin =
  1. | OCaml
    (*

    OCaml-compiled code (.o from .cmx, .a from .cmxa)

    *)
  2. | Startup
    (*

    Startup object file

    *)
  3. | Cached_genfns
    (*

    Cached generic functions

    *)

The origin of a file, used to determine partition placement.

Note: Passthrough files (C stubs from -cclib, runtime libraries) are separated before measuring and don't use this type.

module File_size : sig ... end

Information about a single file's allocated section size.

val measure_files : (module Compiler_owee.Unix_intf.S) -> files:(string * Measure_object_files.file_origin) list -> Measure_object_files.File_size.t list

measure_files unix ~files computes the allocated section size for each file in files.

Handles the following file types based on extension:

  • .o: ELF object file, analyzed directly
  • .a: archive file, all .o members analyzed and summed

Files are tracked to avoid double-counting when the same file appears multiple times. Returns an empty entry for files with unrecognized extensions.

Each file is paired with its origin, which determines partition placement.