buildRebar3: add erlangDeterministicBuilds

The motivation is similar to (and implementation taken partly from)
#271288 --- some rebar3-compiled `.beam` files contain debug information
exposing references to `.hrl` files from the Erlang distribution it
was compiled with.  This results in unnecessary store references.

See also #423588's change to Elixir's `generic-builder.nix` where the
same option is used when building to avoid the same issue.
This commit is contained in:
Asherah Connor 2025-08-18 19:22:54 +10:00
parent c81c8af1b9
commit bccaba9e26

View File

@ -21,6 +21,11 @@
buildPhase ? null,
configurePhase ? null,
meta ? { },
erlangCompilerOptions ? [ ],
# Deterministic Erlang builds remove full system paths from debug information
# among other things to keep builds more reproducible. See their docs for more:
# https://www.erlang.org/doc/man/compile
erlangDeterministicBuilds ? true,
...
}@attrs:
@ -64,6 +69,12 @@ let
inherit src;
ERL_COMPILER_OPTIONS =
let
options = erlangCompilerOptions ++ lib.optionals erlangDeterministicBuilds [ "deterministic" ];
in
"[${lib.concatStringsSep "," options}]";
# stripping does not have any effect on beam files
# it is however needed for dependencies with NIFs
# false is the default but we keep this for readability