Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deterministic builds delete important module meta data #8602

Open
delitrem opened this issue Jun 20, 2024 · 6 comments
Open

Deterministic builds delete important module meta data #8602

delitrem opened this issue Jun 20, 2024 · 6 comments
Assignees
Labels
bug Issue is reported as a bug stalled waiting for input by the Erlang/OTP team team:VM Assigned to OTP team VM

Comments

@delitrem
Copy link
Contributor

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.

@delitrem delitrem added the bug Issue is reported as a bug label Jun 20, 2024
@delitrem
Copy link
Contributor Author

delitrem commented Jun 20, 2024

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

@delitrem
Copy link
Contributor Author

delitrem commented Jun 26, 2024

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"}]

@delitrem
Copy link
Contributor Author

delitrem commented Jul 2, 2024

I'm very sorry for the long ignorance -- was a kind of busy with other things.

I've made a small fix, as was suggested by @michalmuskala at #8607.

Haven't changed anything in test suite, to my mind the existing tests cover this feature (at least compile_SUITE:deterministic_paths/1).

I can also take yet another one feature (as separate task) which was advised by @michalmuskala, in spite of it is not directly related to deterministic builds. :)

@delitrem
Copy link
Contributor Author

delitrem commented Jul 3, 2024

That solution also breaks Elixir.

Still no ideas, what is better. May be just to revert bootstrap's compile.beam from #8579?

Almost no one needs deterministic out-of-box, but almost everyone many people need workable Elixir.

@delitrem
Copy link
Contributor Author

delitrem commented Jul 7, 2024

Just updated #8607. Branch name is old and not relevant.

What was done there:

  • compiler option +preserve_paths for using with +deterministic option for preserving paths such as {source, Source} and {i, Include};
  • compiler option +{modify_path,{From,To}} to modify paths such as {source, Source} and {i, Include}.

Those options are also workable from shell:

$ERL_TOP/bin/erlc +deterministic +preserve_paths simple.erl
$ERL_TOP/bin/erlc +deterministic +preserve_paths +'{modify_path,{"/path/to/erlang/otp","/otp"}}' simple.erl

Is it more suitable?

@jhogberg jhogberg added the stalled waiting for input by the Erlang/OTP team label Jul 10, 2024
@jhogberg
Copy link
Contributor

jhogberg commented Jul 10, 2024

Thanks for raising this issue and taking the time to make a PR addressing it. Unfortunately we're in the middle of the vacation period and have limited time to look at things right now, especially changes that require consensus, so we'll revisit this once most of us are back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is reported as a bug stalled waiting for input by the Erlang/OTP team team:VM Assigned to OTP team VM
Projects
None yet
Development

No branches or pull requests

3 participants