Skip to content
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

Sort input file list #266

Merged
merged 1 commit into from Feb 14, 2022
Merged

Sort input file list #266

merged 1 commit into from Feb 14, 2022

Conversation

bmwiedemann
Copy link
Contributor

Sort input file list
so that btop builds in a reproducible way
in spite of indeterministic filesystem readdir order. (linking order matters)

See https://reproducible-builds.org/ for why this is good.

This PR was done while working on reproducible builds for openSUSE.

so that btop builds in a reproducible way
in spite of indeterministic filesystem readdir order

See https://reproducible-builds.org/ for why this is good.
@aristocratos
Copy link
Owner

@bmwiedemann
Does this matter when compiling with -flto (used by default for btop) since no linking is happening until all object files are already compiled?

@bmwiedemann
Copy link
Contributor Author

It matters both with and without -flto

@aristocratos
Copy link
Owner

@bmwiedemann
Looks like there is more changes needed to make it deterministic.
From: https://blog.conan.io/2019/09/02/Deterministic-builds-with-C-C++.html

Randomness created by the compiler

This problem arises for example in gcc when Link-Time Optimizations are activated (with the -flto flag). This option introduces randomly generated names in the binary files. The only way to avoid this problem is to use -frandom-seed flag. This option provides a seed that gcc uses when it would otherwise use random numbers. It is used to generate certain symbol names that have to be different in every compiled file. It is also used to place unique stamps in coverage data files and the object files that produce them. This setting has to be different for each source file. One option would be to set it to the checksum of the file so the probability of collision is very low. For example in CMake it could be made with a function like this [...]

@bmwiedemann
Copy link
Contributor Author

This PR was the only patch needed to make openSUSE btop package builds reproducible (even with LTO).
Probably gcc got some toolchain fix in the meantime.

@aristocratos
Copy link
Owner

@bmwiedemann
I don't doubt your claim, but I'm curious, what was the setup for replicating the result?

@aristocratos aristocratos merged commit 4a94c83 into aristocratos:main Feb 14, 2022
@bmwiedemann
Copy link
Contributor Author

bmwiedemann commented Feb 15, 2022

@bmwiedemann I don't doubt your claim, but I'm curious, what was the setup for replicating the result?

on openSUSE (should also work on Debian with osc, and obs-build packages), I use

osc checkout openSUSE:Factory/btop && cd $_
rbk

where the rbk script comes from
https://github.com/bmwiedemann/reproducibleopensuse/

@bmwiedemann bmwiedemann deleted the sort branch February 15, 2022 12:59
@aristocratos
Copy link
Owner

Alright, thanks for contributing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants