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
.beam files differ between builds #8689
Comments
|
Thanks @bmwiedemann. Do you have steps to reproduce this? How are you going the builds? Which Erlang/OTP version are you using? I am getting consistent results with Elixir master and Erlang/OTP 21. Note that earlier Erlang/OTP versions would include timestamps, which would make them not reproducible. |
|
I also could not reproduce this in ExDoc: |
|
erlang is 21.1.4 Here is a reproducer (also works in Debian, if you produced here: Logs show, it just uses |
|
Oh, sorry, I see now that you included Erlang in your initial report, sorry. Now I also see why I can't reproduce it, I am running on v1.8.0 which has this commit: d76f150 The commit above made the compiler deterministic when meta-programming. Therefore this is fixed in v1.8+ and master. In any case, thank you for checking and for the report! |
|
d76f150 cherry-picked cleanly to 1.7.4 and reduced the elixir diff to only have instances of /usr/lib/elixir/lib/ex_unit/ebin/Elixir.ExUnit.Assertions.beam differs at offset '8' (Erlang BEAM file)
@@ -1,4 +1,4 @@
-00000000 46 4f 52 31 00 00 6f 74 42 45 41 4d 41 74 55 38 |FOR1..otBEAMAtU8|
+00000000 46 4f 52 31 00 00 6f 78 42 45 41 4d 41 74 55 38 |FOR1..oxBEAMAtU8|
00000010 00 00 07 41 00 00 00 af 18 45 6c 69 78 69 72 2e |...A.....Elixir.|Is there another patch missing? |
|
This is a bit weird. Bytes 5 to 8 are the size of the BEAM chunk. So if the size is different, then something else should also show up in the diff? |
|
indeed, our special-purpose diff tool was hiding the lower part diff.txt |
|
I see, so the difference is in the documentation chunk. I am not quite sure yet though. I can also reproduce it locally. I will take a look later after I pick the kids from school. |
|
Btw, this diff tool is neat, is it available externally? :D |
|
The bad one is build-compare and the good one is https://github.com/bmwiedemann/reproducibleopensuse/blob/master/filterdiff |
|
If you want to work with the openSUSE package, you can also try my |
|
Got it. So we literally had |
|
I applied this patch to my 1.8 package and am still getting diffs in at least 5 beam files. And github did not let me upload that 1MB file: https://rb.zq1.de/compare.factory-20190113/elixir-1.8-diff.txt Elixir.Stream.beam has the smallest diff of the 5. Shall I open a new bug or do we keep tracking it here? |
|
Could you please share which are these beam files? It will be easier to track down |
|
They are: Code.Formatter, Stream, Enum, String and System. @bmwiedemann we can likely solve all of them but we cannot solve the |
|
So I cannot reproduce the one for Code.Formatter but I can reproduce it for Enum, Stream and String and they are related to the Dbgi chunk (which stores AST). I will post more updates soon. |
|
@josevalim I would say it is I haven't fully read it, but it all looks it is a common issue. |
|
I found the root cause for Enum, String, Stream, which were relying on map ordering when sorting specs, which is non deterministic. This would have happened when we have more than 32 specs in the same module. Please see the commit above. I still cannot reproduce the formatter one properly. I will provide SOURCE_DATE_EPOCH support for the System one. Btw, is anyone interested in contributing a shell script we can run in CI that checks our builds are deterministic? The following would be needed:
|
|
One option would be to deprecate build_date() and change it to something else based on the last commit date. That way given it will be deterministic. |
|
I can volunteer for contributing such script |
|
@eksperimental the problem is that people may not always be assembling from the git repo, so we are back to square one. I think SOURCE_DATE_EPOCH is a good compromise.
Beautiful! |
|
PR for SOURCE_DATE_EPOCH here: #8694. @bmwiedemann all should be fixed except the Code.Formatter one, which I cannot reproduce locally and I cannot figure out the root cause based on the diff you sent. Can you reproduce it on Elixir master? Thanks for the feedback and guidance here! |
|
All issues have been addressed. Thanks @bmwiedemann! |
|
I wanted to mention that working with you guys was among the most fun cooperations I did - that is after doing 200+ upstream patches for reproducible builds. Nice github reaction-smiley, fast responses, good patches. And I still know not a bit of elixir syntax ;-) |
See elixir-lang#8689 for more information
Environment
elixir-1.7.4 erlang-21.1.4
Current behavior
Somewhat similar to #4814 building the openSUSE elixir package produces various .beam files that differ for every build, e.g.
/usr/lib/elixir/lib/mix/ebin/Elixir.Mix.Tasks.Deps.Unlock.beamSome of the diff is even there when doing builds as similar as possible (e.g. disabling ASLR, 1-core VM without parallelism)
The erlang package itself does not have this kind of variations in its .beam files (but others from timestamps)
Note: the elixir-ex_doc package (in the best case) only has 1 beam file with 1 bit diff so might be easier to debug.
Expected behavior
Builds should produce deterministic results.
See https://reproducible-builds.org/ for why this matters.
The text was updated successfully, but these errors were encountered: