mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-27 13:57:10 +03:00
stdenv: add -frandom-seed to NIX_CFLAGS_COMPILE for reproducibility
This adds -frandom-seed to each compiler invocation in stdenv. The object here is to make the compierl invocations produce the same output every time they are called (for the same derivation). When the -frandom-seed option is not set the compiler will use a combination of random numbers (in GCC's case from /dev/urandom) and the durrent time to produce a "random" input per file. This can (among other things) lead to different ordering of symbols in the produced object files. For reason of reproducibility we prefer having the same derivation produce the exact same outputs. This is not a silver bullet but one way to tame the compiler.
This commit is contained in:
parent
b7ef4d7dda
commit
83f0bccc89
4
pkgs/build-support/setup-hooks/reproducible-builds.sh
Normal file
4
pkgs/build-support/setup-hooks/reproducible-builds.sh
Normal file
@ -0,0 +1,4 @@
|
||||
# Use the last part of the out path as hash input for the build.
|
||||
# This should ensure that it is deterministic across rebuilds of the same
|
||||
# derivation and not easily collide with other builds.
|
||||
export NIX_CFLAGS_COMPILE+=" -frandom-seed=${out##*/}"
|
@ -70,6 +70,7 @@ let
|
||||
../../build-support/setup-hooks/move-sbin.sh
|
||||
../../build-support/setup-hooks/move-lib64.sh
|
||||
../../build-support/setup-hooks/set-source-date-epoch-to-latest.sh
|
||||
../../build-support/setup-hooks/reproducible-builds.sh
|
||||
# TODO use lib.optional instead
|
||||
(if hasCC then cc else null)
|
||||
];
|
||||
|
Loading…
Reference in New Issue
Block a user