Something went wrong. Try again.
My own corner of monopam
Something went wrong. Try again.
3.7 kB · 82 lines
at main
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283; Included by the root dune file: its paths are relative to the root.
; release-link-flags.sexp: OS-gated linker size flags for release links, pulled; in by the release env in dune-workspace. Section GC + symbol strip, both; linker-specific: macOS ld64 dead-strips per symbol (-dead_strip), then the; compiler wrapper fully strips the linked executable (ld64's -s is obsolete; and ignored). GNU ld uses --gc-sections and -s. OCaml exception backtraces; survive both (they ride in the -g frame data, not the symbol table).; The macOS wrapper also links every non-system library from its static; archive (see the script). A link reads the wrapper but does not declare it,; so its digest rides in the -cc command: an edit to the wrapper changes every; release link's key, and the shared cache cannot hand back an old link.; Generated per %{system}, never committed.
(rule (target release-link-flags.sexp) (enabled_if (= %{system} macosx)) (action (with-stdout-to release-link-flags.sexp (system "printf '(-cc \"env MACOS_OCAMLOPT_LINK=%s %s\" -cclib -Wl,-dead_strip)\\n' \"$(shasum -a 256 < %{dep:scripts/macos-ocamlopt-link} | cut -c1-64)\" %{dep:scripts/macos-ocamlopt-link}"))))
(rule (target release-link-flags.sexp) (enabled_if (<> %{system} macosx)) (action (with-stdout-to release-link-flags.sexp (echo "(-cclib -Wl,--gc-sections -cclib -Wl,-s)"))))
; switch-pins: the switch this build runs in takes every package root.opam's; pin-depends: names from the source the list names, and pins nothing else; (scripts/switch_pins.ml). The switch is the one whose compiler the build; uses, %{ocamlopt}'s prefix. The rule reads the switch's state outside the; workspace, so it runs every time it is asked. No build depends on it: a; developer's switch may carry toolchain pins of its own, and a release-profile; build of any binary (the fleet's mq is one) runs regardless. The release cut; asks it: bottler's release builds it beside the bottled binaries (the checks; of homebrew.yml's build section) and refuses the release on drift, so no; shipped binary links a library from a source the list does not name.; `dune build @switch-pins` checks a switch on demand.
(rule (alias switch-pins) (deps (universe) root.opam) (action (system "%{exe:scripts/switch_pins.exe} root.opam \"$(dirname \"$(dirname %{ocamlopt})\")\"")))
; lto-flags.sexp: -use-lto for the release link, which re-runs the flambda; middle-end over the whole program and drops the code nothing reaches. The two; profiles use two compilers: dev builds with the upstream 5.4.1 in the local; switch, which has no such flag, and a release build runs in the release; context of dune-workspace.release, on the lto-5.4.1 switch, whose compiler; carries the link-time DCE patches (samoht/ocaml, see root.opam.template). So; the release rule probes %{ocamlopt} and writes (-use-lto), and REFUSES the; build when the flag is missing rather than linking a release binary without; LTO. Every other profile writes (): nothing includes the file there, but the; root directory's targets must still build. Generated per switch, never; committed.
(rule (target lto-flags.sexp) (enabled_if (= %{profile} release)) (action (with-stdout-to lto-flags.sexp (system "if %{ocamlopt} -use-lto -version >/dev/null 2>&1; then echo '(-use-lto)'; else echo 'lto-flags.sexp: the release profile needs a compiler with -use-lto; build in the release context, on the lto-5.4.1 switch: opam exec -- dune build --workspace dune-workspace.release ./_build/release/<target>' >&2; exit 1; fi"))))
(rule (target lto-flags.sexp) (enabled_if (<> %{profile} release)) (action (with-stdout-to lto-flags.sexp (echo "()"))))