aboutsummaryrefslogtreecommitdiff
path: root/pkgs/build-support
diff options
context:
space:
mode:
authorAndreas Rammhold <andreas@rammhold.de>2020-10-31 17:29:54 +0100
committerAndreas Rammhold <andreas@rammhold.de>2020-11-01 19:40:12 +0100
commit83f0bccc89b6cd6de576609bb49abcb3f507d58e (patch)
tree0338e3cd14f67ba3b823f0b331a27ef82c2752ec /pkgs/build-support
parentb7ef4d7ddaf553b06329bfebd056f4765ff2de27 (diff)
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.
Diffstat (limited to 'pkgs/build-support')
-rw-r--r--pkgs/build-support/setup-hooks/reproducible-builds.sh4
1 files changed, 4 insertions, 0 deletions
diff --git a/pkgs/build-support/setup-hooks/reproducible-builds.sh b/pkgs/build-support/setup-hooks/reproducible-builds.sh
new file mode 100644
index 000000000000..2d8db6ff7d3c
--- /dev/null
+++ b/pkgs/build-support/setup-hooks/reproducible-builds.sh
@@ -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##*/}"