-
Notifications
You must be signed in to change notification settings - Fork 39
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
Compilation artifacts are not reproducible due to everchanging build ID #518
Comments
I find it hard to imagine that the toolchain doesn't have a way to resolve this, as this is a big barrier to reproducible builds. |
We could ignore it (stripping it or setting a default build ID) or fixing the cause: it's possible that one of our dependencies is doing something funky and interferes with the build ID somehow |
Firstly, I can't reproduce this as described above: I got the same binary after running We can suppress generation of the build-id with However, it would be interesting to know why the build-id is changing. One of the inputs to the linker must be different each time, even though the change only affects the build-id. If we could discover what that input is perhaps we could find a better solution that using |
Looks like the build ID difference could come among other things from sections (.debug_info, .debug_abbrev, .debug_loc, .debug_pubtypes) that get stripped after the build (033a241): I commented the stripping out and am getting two distinct binaries regardless of the build ID. Most diffs seems to be simple byte replacements or insertions here and there. |
Are we using the build id for anything? If not, let's just strip it. |
I don't think we're using it. I'm opening a PR for that |
Can other people please try |
Some careless experiments have given me the impression that |
PR #520 introduced a work-around for this issue, so I'll close it. However, it is still interesting to know where the non-reproducibility comes from. Non-reproducibility can be reproduced (ha!) with the following trivial program:
Test by running This is not inconsistent with the problem originating in It seems the non-reproducibility of that particular program goes away if you upgrade the toolchain from Perhaps the work-around introduced by PR #520 won't always be needed, but it doesn't do any harm to leave it in. I'd expect non-reproducibility to come from a crate that uses a build script ( |
Perhaps this really was a bug in the toolchain: rust-lang/rust#90301 ("reproducible builds broken in rustc 1.56.0 due to LLVM 13 update") (In the simple case described above, the relevant differences appear in sections called |
So this issue could perhaps have been fixed by merging #516, which updates the toolchain from |
Describe the bug
Veracruz binaries (client, server, attestation, runtime manager) contain a build ID (
.note.gnu.build-id
section) in their ELF headers. This build ID is a hash determined by rustc and/or the linker.However, for unknown reasons (timestamp somewhere? source of randomness?), the build ID changes every time the crate is cargo cleaned then rebuilt.
This results in binaries that are functionally equivalent but have different overall hashes, which gives different Docker images.
FWIW some debug sections (e.g. .debug_info, .debug_abbrev, .debug_loc, .debug_pubtypes) change between builds as well
To Reproduce
make nitro
veracruz-server
:sha256sum nitro-host/target/debug/veracruz-server
make clean
make nitro
veracruz-server
:sha256sum nitro-host/target/debug/veracruz-server
objdump --section=.note.gnu.build-id --full-contents nitro-host/target/release/veracruz-server
Expected behaviour
It's not clear to me how the build ID is determined, but I would expect it to stay constant between builds as long as the binaries are functionally equivalent and the code doesn't change.
Solutions
Strip build ID from binaries (
strip --remove-section=.note.gnu.build-id <binary>
) or fix build ID generationThe text was updated successfully, but these errors were encountered: