boot_stage2: improve reproducibility #1907
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Specifying the final boot2 source file as a link library here causes the final
.elf
to be linked directly with that.S
, which causes it to be compiled into an object file with a name like/tmp/<random chars>.o
. This temporary object name is embedded in the final.elf
, so the.elf
's contents change after each link even if none of the input files change, breaking reproducibility.Fix the issue by specifying the source file as the source for an object-only library, then specifying the library's object files as the target link libraries, so the source is compiled in a separate step and only the object is passed to the linker.
Fixes #1906
This makes everything fully reproducible for me and my setup though I have not tested exhaustively and reproducibility is of course something that can't be absolutely proved. Also please keep in mind I'm not knowledgeable with CMake and bumbled into this solution.