While working on reproducible builds for openSUSE, I found that
our insighttoolkit package varied from the type of build machine CPU
that randomly gets chosen from the pool of build workers.
This is because InsightToolkit-5.1.0/CMake/ITKSetStandardCompilerFlags.cmake has -mtune=native
and dropping this helped to make builds reproducible.
See https://reproducible-builds.org/ for why this matters.
It should be possible to get bit-identical build results on different build machines.
May be triggered via a cmake flag or the SOURCE_DATE_EPOCH environment variable
build results vary from build machine CPU
100%
5.1
openSUSE-Tumbleweed-20200728
This PR was done while working on reproducible builds for openSUSE.
@bmwiedemann thanks for working on the openSUSE packages! :package: :pray:
Perhaps a different -mtune value should be specified in the package build configuration to select the target cpu?
I believe -mtune=generic is the recommended way to produce "code optimized for the most common CPUs at the time the version of gcc was released"
‘generic’
Produce code optimized for the most common IA32/AMD64/EM64T processors. If you know the CPU on which your code will run, then you should use the corresponding -mtune or -march option instead of -mtune=generic. But, if you do not know exactly what CPU users of your application will have, then you should use this option.As new processors are deployed in the marketplace, the behavior of this option will change. Therefore, if you upgrade to a newer version of GCC, code generation controlled by this option will change to reflect the processors that are most common at the time that version of GCC is released.
There is no -march=generic option because -march indicates the instruction set the compiler can use, and there is no generic instruction set applicable to all processors. In contrast, -mtune indicates the processor (or, in this case, collection of processors) for which the code is optimized.
Yes, -mtune=generic sounds good. I tested that it also builds reproducibly.
Close the issue?
@dzenanz I'd prefer to see #1953 merged
-mtune=generic is the least common denominator, which means only use instructions from 20 years ago.
-mtune=generic is the least common denominator, which means only use instructions from 20 years ago.
It is my understanding that this is for the optimization of the instructions ( order, delay etc. ), not which instruction sets used. The march flag ( and others ) dictate which instruction can be used.