Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign uprustc produces indeterministic asm #57041
Comments
Centril
added
A-LLVM
A-codegen
labels
Dec 21, 2018
This comment has been minimized.
This comment has been minimized.
bmwiedemann
commented
Jan 2, 2019
|
Spent some more time on this and did for i in $(seq 20) ; do
echo 10000 > /proc/sys/kernel/ns_last_pid
taskset 1 setarch `arch` -R strace -s 4096 -o rustc$i.strace -f ./build.sh
doneThis can create more reproducible results as long as the system is idle. diffing strace outputs showed that the 'idle' result correlated with more, smaller All this indicates that there is some raciness in the communication between the involved threads and this is where the non-determinism comes from. |
This comment has been minimized.
This comment has been minimized.
|
Have you found any difference in the emitted LLVM IR? |
This comment has been minimized.
This comment has been minimized.
bmwiedemann
commented
Jan 2, 2019
|
@jonas-schievink no, LLVM IR is always deterministic, as mentioned in the last line of the original report. |
This comment has been minimized.
This comment has been minimized.
bmwiedemann
commented
Jan 2, 2019
|
Because of my very limited rust-foo I would appreciate help in further reducing the 183 lines of .rs files into an even smaller reproducer so that it becomes more visible what matters in there. |
This comment has been minimized.
This comment has been minimized.
|
@bmwiedemann In that case, can you reproduce this by running
Does it make a difference if you pass (this does indeed look like the same problem as #50556) |
This comment has been minimized.
This comment has been minimized.
bmwiedemann
commented
Jan 3, 2019
|
I changed my build.sh to have I also tried -Ccodegen-units=$N and 1 behaved pretty much like before but 2 produced 2 output files that did not seem to vary for some reason. I'm on llvm-5,0,1 atm. llvm-6.0.1 is also bad, but llc from llvm-7.0.0 seems to be good. |
This comment has been minimized.
This comment has been minimized.
bmwiedemann
commented
Jan 3, 2019
|
I now ran my autoreduce script on lib.ll and shrank it to 176 lines: |
This comment has been minimized.
This comment has been minimized.
bmwiedemann
commented
Jan 9, 2019
|
In llvm I ran a |
This comment has been minimized.
This comment has been minimized.
|
cc #34902 |
This comment has been minimized.
This comment has been minimized.
|
Is there anything actionable to do here on the side of rustc? Per your investigation this issue has already been fixed in LLVM 7.0. |
This comment has been minimized.
This comment has been minimized.
|
I think this can be closed, once someone checks the original reproduction with a nightly build. |
This comment has been minimized.
This comment has been minimized.
bmwiedemann
commented
Feb 1, 2019
|
Found another patch that makes llc determistic with lib.ll from the full git-rs |
This comment has been minimized.
This comment has been minimized.
|
@bmwiedemann LLVM has short release cycles and LLVM 6 is long since dead. Not even LLVM 7 will receive further backports (there will only be one more release with a single change, that was not included in LLVM 7.0.1 because it is ABI breaking). |
bmwiedemann commentedDec 21, 2018
•
edited
While working on reproducible builds for openSUSE, I found that
the svgcleaner and exa rust packages had variations in machine code.
For exa, I traced this down to variations from git2-rs that is embedded there.
From that I reduced the code as much as I could, so that now there are only 183 lines of rust left.
Steps to Reproduce:
Actual Result:
Expected Result:
rustc should always produce the same asm output
I have identified 6 places that can be dropped and make the output reproducible:
https://github.com/bmwiedemann/git2-rs/blob/race/src/panic.rs#L11
https://github.com/bmwiedemann/git2-rs/blob/race/src/lib.rs#L5
https://github.com/bmwiedemann/git2-rs/blob/race/src/lib.rs#L13 ++
https://github.com/bmwiedemann/git2-rs/blob/race/src/call.rs#L10 +4
https://github.com/bmwiedemann/git2-rs/blob/race/src/index.rs#L39 +8
https://github.com/bmwiedemann/git2-rs/blob/race/src/index.rs#L64 ++
This bug might be related to bug #50556, but that one is closed and this bug is still reproducible with rust-1.31
I checked that llvm-bc and llvm-ir output are reproducible even when asm is not.