Something went wrong. Try again.
My own corner of monopam
Something went wrong. Try again.
2.0 kB · 55 lines
at main
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556The release context===================
A release or benchmark build runs in the worktree and its `_build`, in thecontext `release` that `dune-workspace.release` declares: this tree's`dune-workspace` and one more context, on the lto-5.4.1 switch, whose compilertakes -use-lto, under the release profile. Its build directory is`_build/release`, beside `_build/default`, and neither build disturbs theother. The fixture carries both workspace files, the release flags and oneexecutable, and builds with no shared cache, so every link it asks for runs.
$ mkdir -p fx/scripts $ cp ../dune-workspace ../dune-workspace.release fx/ $ cp release-flags.inc macos-ocamlopt-link fx/scripts/ $ touch fx/root.opam $ printf '(lang dune 3.21)\n' > fx/dune-project $ cat > fx/dune <<'EOF' > (include scripts/release-flags.inc) > (rule > (target c-debug-flags.sexp) > (action (with-stdout-to c-debug-flags.sexp (echo "()")))) > (rule > (target link-flags.sexp) > (action (with-stdout-to link-flags.sexp (echo "()")))) > (executable > (name hello)) > EOF $ echo 'let () = print_endline "hello"' > fx/hello.ml $ export DUNE_CACHE=disabled
A dev build links in the default context, with no LTO:
$ dune build --root fx ./_build/default/hello.exe 2>&1 | grep -c -- -use-lto 0 [1]
The release context links the same executable with -use-lto, whose linkreports the code it eliminated:
$ dune build --root fx --workspace fx/dune-workspace.release \ > ./_build/release/hello.exe 2>&1 | grep -o -- '^-use-lto (hello.exe)' -use-lto (hello.exe) $ fx/_build/release/hello.exe hello
The release build leaves the default context as it was: a dev build after itruns nothing.
$ dune build --root fx ./_build/default/hello.exe --display short 2>&1
Nor does a release build after it: both contexts stay built in the one`_build`.
$ dune build --root fx --workspace fx/dune-workspace.release \ > ./_build/release/hello.exe --display short 2>&1