roc icon indicating copy to clipboard operation
roc copied to clipboard

produced executables should be identical when produced in different folders

Open Anton-4 opened this issue 1 year ago • 3 comments

When working on #6311 I noticed the sha256sum of executables was different if they were built in a different folder. The path of the platform was included in the debuginfo.

There are other differences as well, we should find where all of these come from and eliminate them.

Finding the origin of these differences can be a good first issue for someone with some low level linux executable experience.

Anton-4 avatar Jan 15 '24 16:01 Anton-4

  • [ ] Once the differences have been removed we should add a CI test that verifies this reproducibility.

Anton-4 avatar Jan 15 '24 16:01 Anton-4

I started looking into this. Initially looking at mach-O binaries.

In the output of dsymutil -s bench-folder-main/crates/cli_testing_examples/benchmarks/nQueens, I can see a few absolute paths that may be one issue.

[   641] 000080f3 64 (N_SO         ) 00     0000   0000000000000000 '/Users/jschear/dev/roc/bench-folder-main/crates/cli_testing_examples/benchmarks/platform/'
[   643] 00008152 66 (N_OSO        ) 00     0001   0000000065d6d49b '/Users/jschear/dev/roc/bench-folder-main/crates/cli_testing_examples/benchmarks/platform/macos-arm64.o'

I don't have a good sense of where to insert this yet, but there's a potentially useful -oso_prefix linker flag to get rid of these absolute paths: https://milen.me/writings/apple-linker-ld64-deterministic-builds-oso-prefix (Still reading up on the linking story for roc, this may not apply.)

jschear avatar Feb 22 '24 05:02 jschear

Check out the link.rs file which I think is crates/build (can't check right now). There are linker commands in there. Partly depends on the host language. Longer term, we want to take the host language dependent stuff out of the compiler but it's there for now.

brian-carroll avatar Feb 22 '24 12:02 brian-carroll