erlang/otp

Deterministic builds delete important module meta data

Opened this issue · 2 comments

Describe the bug
When Erlang is configured with --enable-deterministic-build option, compiler produces BEAMs without options and source subsections in module meta data. This data is required for some dependents, at least Elixir expects it.

To Reproduce
Compile with --enable-deterministic-build option, then run REPL:

$ erl
1> lists:module_info(compile).
[{version,"8.4.3"}]

Expected behavior

1> lists:module_info(compile).
[{version,"8.4.3"},
 {options,[debug_info,
           {i,"/some/path/to/lib/stdlib/src/../include"},
           {i,"/some/path/to/lib/stdlib/src/../../kernel/include"},
           warn_missing_doc_function,warn_missing_doc_callback,
           warn_missing_spec_documented,deterministic]},
 {source,"/some/path/to/lib/stdlib/src/lists.erl"}]

May be it would be suitable to normalize paths somehow, may be by changing '/some/path/to' to something hardcoded, for example: '/deterministic' when compiled with --enable-deterministic-build option.

Affected versions
I have tested it on 27.0 and maint branch.

Additional context
None. Feel free to ask.

Another solution: to provide some option for preserve compile meta data (at least source).

Is it be suitable if I just make compiler to preserve source tuple with filename:basename(Source) when deterministic option is switched on (with test suite modification)? It seems to be enough for Elixir's tests to pass.

Proposed output would be:

1> lists:module_info(compile).
[{version,"8.4.3"},
 {options,[]},
 {source,"lists.erl"}]