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

Avoid -march=native when reproducible builds are wanted #7241

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bmwiedemann
Copy link

Distribution builds that intend to have verifiable binaries, set the SOURCE_DATE_EPOCH variable.
Those builds should not default to -march=native so that verification builds can produce bit-identical results on other CPUs of the same architecture.

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

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

Note: this is tested a bit, but might have room for improvement.

Distribution builds that intend to have verifiable binaries,
set the SOURCE_DATE_EPOCH variable. Those builds should not default
to -march=native so that verification builds can produce bit-identical
results on other CPUs of the same architecture.

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

This patch was done while working on reproducible builds for openSUSE.
@hyc
Copy link
Collaborator

hyc commented Dec 31, 2020

This patch shouldn't be needed, since we already took care of this in fcfa666

@bmwiedemann
Copy link
Author

We are at 0.17.1.7 and that patch was in there, but the build still had -march=native by default.

The patch commit message you linked also does not tell anything in that direction.

Copy link
Collaborator

@moneromooo-monero moneromooo-monero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be nice to find something less ad hoc than SOURCE_DATE_EPOCH if possible, but if not, looks ok

@bmwiedemann
Copy link
Author

A nice alternative would be to always be reproducible by default and only use ARCH=native when requested by the one building it.

@hyc
Copy link
Collaborator

hyc commented Dec 31, 2020

Making a reproducible build is about more than just setting a consistent timestamp in object files. That's why our reproducible builds use the depends system, driven by the gitian build scripts. IMO setting this in the master CMake file is deceptive because it implies that the build is "reproducible" when it actually isn't, without all of the other dependencies being addressed.

@moneromooo-monero
Copy link
Collaborator

Oh, this wasn't actually using gitian ?

@hyc
Copy link
Collaborator

hyc commented Dec 31, 2020

This situation can only arise if not using gitian/depends, since contrib/depends/toolchain.cmake.in explicitly sets ARCH=default.

@bmwiedemann
Copy link
Author

bmwiedemann commented Jan 1, 2021

This is how we build:
https://github.com/bmwiedemann/openSUSE/blob/master/packages/m/monero/monero.spec#L177
And it builds reproducibly with -DARCH=default added. IMHO this should be the default, especially for release builds.

Also worth noting that 95% of our other 13000 packages are already reproducible without gitian. The goal for us is not to rebuild upstream binaries, but to have our own verifiable binaries built with our toolchain. Pulling in Ubuntu is not an option there.

@iamamyth
Copy link

iamamyth commented Jan 4, 2021

Defaulting to native architecture tends to be the default for most cmake builds I've seen, as it better matches typical usage patterns (building on the hardware which will run the binary and wanting a well-optimized optimized release binary). If you want to use cmake to generate a generic build, why not just explicitly set march=default in your particular run configuration?

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

4 participants