summary refs log tree commit diff
path: root/pkgs/build-support
diff options
context:
space:
mode:
authorAlexander Kjeldaas <ak@formalprivacy.com>2014-04-09 17:12:33 +0200
committerVladimír Čunát <vcunat@gmail.com>2014-09-13 15:32:34 +0200
commitaa119e1106fa5cf67f1d34e1361e6b9e83f269a1 (patch)
tree6ea3d24f8be76745d5e51424ab526db4abb25fd2 /pkgs/build-support
parent7141303c998942f04dec761555c5944f309658d2 (diff)
downloadnixlib-aa119e1106fa5cf67f1d34e1361e6b9e83f269a1.tar
nixlib-aa119e1106fa5cf67f1d34e1361e6b9e83f269a1.tar.gz
nixlib-aa119e1106fa5cf67f1d34e1361e6b9e83f269a1.tar.bz2
nixlib-aa119e1106fa5cf67f1d34e1361e6b9e83f269a1.tar.lz
nixlib-aa119e1106fa5cf67f1d34e1361e6b9e83f269a1.tar.xz
nixlib-aa119e1106fa5cf67f1d34e1361e6b9e83f269a1.tar.zst
nixlib-aa119e1106fa5cf67f1d34e1361e6b9e83f269a1.zip
gcc-wrapper: make __DATE__/__TIME__ deterministic
...when NIX_ENFORCE_PURITY=1.

@vcunat corrected the date according to docs.
https://gcc.gnu.org/onlinedocs/cpp/Standard-Predefined-Macros.html
In order to handle the spaces well, the extraAfter array had to be
quoted more properly and appended by +=.
Diffstat (limited to 'pkgs/build-support')
-rw-r--r--pkgs/build-support/gcc-wrapper/gcc-wrapper.sh19
1 files changed, 14 insertions, 5 deletions
diff --git a/pkgs/build-support/gcc-wrapper/gcc-wrapper.sh b/pkgs/build-support/gcc-wrapper/gcc-wrapper.sh
index 2ad7783a442c..d6e91ebc666a 100644
--- a/pkgs/build-support/gcc-wrapper/gcc-wrapper.sh
+++ b/pkgs/build-support/gcc-wrapper/gcc-wrapper.sh
@@ -84,11 +84,20 @@ fi
 extraAfter=($NIX_CFLAGS_COMPILE)
 extraBefore=()
 
+# When enforcing purity, pretend gcc can't find the current date and
+# time
+if test "$NIX_ENFORCE_PURITY" = "1"; then
+    extraAfter+=('-D__DATE__=??? ?? ????'
+        '-D__TIME__=??:??:??'
+        -Wno-builtin-macro-redefined)
+fi
+
+
 if test "$dontLink" != "1"; then
 
     # Add the flags that should only be passed to the compiler when
     # linking.
-    extraAfter=(${extraAfter[@]} $NIX_CFLAGS_LINK)
+    extraAfter+=($NIX_CFLAGS_LINK)
 
     # Add the flags that should be passed to the linker (and prevent
     # `ld-wrapper' from adding NIX_LDFLAGS again).
@@ -97,9 +106,9 @@ if test "$dontLink" != "1"; then
     done
     for i in $NIX_LDFLAGS; do
 	if test "${i:0:3}" = "-L/"; then
-	    extraAfter=(${extraAfter[@]} "$i")
+	    extraAfter+=("$i")
 	else
-	    extraAfter=(${extraAfter[@]} "-Wl,$i")
+	    extraAfter+=("-Wl,$i")
 	fi
     done
     export NIX_LDFLAGS_SET=1
@@ -139,9 +148,9 @@ fi
 # `-B' flags, since they confuse some programs.  Deep bash magic to
 # apply grep to stderr (by swapping stdin/stderr twice).
 if test -z "$NIX_GCC_NEEDS_GREP"; then
-    @gccProg@ ${extraBefore[@]} "${params[@]}" ${extraAfter[@]}
+    @gccProg@ ${extraBefore[@]} "${params[@]}" "${extraAfter[@]}"
 else
-    (@gccProg@ ${extraBefore[@]} "${params[@]}" ${extraAfter[@]} 3>&2 2>&1 1>&3- \
+    (@gccProg@ ${extraBefore[@]} "${params[@]}" "${extraAfter[@]}" 3>&2 2>&1 1>&3- \
         | (grep -v 'file path prefix' || true); exit ${PIPESTATUS[0]}) 3>&2 2>&1 1>&3-
     exit $?
 fi