about summary refs log tree commit diff
path: root/pkgs/stdenv
diff options
context:
space:
mode:
authorDaiderd Jordan <daiderd@gmail.com>2020-01-13 17:46:11 +0100
committerDaiderd Jordan <daiderd@gmail.com>2020-01-31 21:52:07 +0100
commita826b49c97bcc9d8365b5d18aeec8087116d195d (patch)
tree52812761355a97eb85cabe3a9e0b6ea417cfa6a0 /pkgs/stdenv
parent16ffc74a32392d203ffaeb37a486fb55e1c4e7d1 (diff)
downloadnixlib-a826b49c97bcc9d8365b5d18aeec8087116d195d.tar
nixlib-a826b49c97bcc9d8365b5d18aeec8087116d195d.tar.gz
nixlib-a826b49c97bcc9d8365b5d18aeec8087116d195d.tar.bz2
nixlib-a826b49c97bcc9d8365b5d18aeec8087116d195d.tar.lz
nixlib-a826b49c97bcc9d8365b5d18aeec8087116d195d.tar.xz
nixlib-a826b49c97bcc9d8365b5d18aeec8087116d195d.tar.zst
nixlib-a826b49c97bcc9d8365b5d18aeec8087116d195d.zip
stdenv: make darwin builds reproducable
Fixes #21629

Passing these extra linker flags removes both the semi-random uuid
included in most binaries as well as making the sdk version consistent
instead of based on the current os version.

    Load command 8
         cmd LC_UUID
     cmdsize 24
        uuid 70FAF921-5DC8-371C-B814-4F121FADFDF4

    Load command 9
          cmd LC_VERSION_MIN_MACOSX
      cmdsize 16
      version 10.12
          sdk 10.13

The -macosx_version_min flag isn't strictly necessary since that's
already handled by MACOSX_DEPLOYMENT_TARGET.
Diffstat (limited to 'pkgs/stdenv')
-rw-r--r--pkgs/stdenv/darwin/default.nix15
1 files changed, 10 insertions, 5 deletions
diff --git a/pkgs/stdenv/darwin/default.nix b/pkgs/stdenv/darwin/default.nix
index f73fca48b7a7..207502285b2e 100644
--- a/pkgs/stdenv/darwin/default.nix
+++ b/pkgs/stdenv/darwin/default.nix
@@ -28,15 +28,20 @@ let
   ];
 in rec {
   commonPreHook = ''
-    export NIX_ENFORCE_PURITY="''${NIX_ENFORCE_PURITY-1}"
-    export NIX_ENFORCE_NO_NATIVE="''${NIX_ENFORCE_NO_NATIVE-1}"
+    export NIX_ENFORCE_NO_NATIVE=''${NIX_ENFORCE_NO_NATIVE-1}
+    export NIX_ENFORCE_PURITY=''${NIX_ENFORCE_PURITY-1}
     export NIX_IGNORE_LD_THROUGH_GCC=1
-    stripAllFlags=" " # the Darwin "strip" command doesn't know "-s"
-    export MACOSX_DEPLOYMENT_TARGET=10.12
-    export SDKROOT=
     export CMAKE_OSX_ARCHITECTURES=x86_64
+    export SDKROOT=
+
+    # Ensure consistent LC_VERSION_MIN_MACOSX and remove LC_UUID.
+    export MACOSX_DEPLOYMENT_TARGET=10.12
+    export NIX_LDFLAGS+=" -macosx_version_min 10.12 -sdk_version 10.12 -no_uuid"
+
     # Workaround for https://openradar.appspot.com/22671534 on 10.11.
     export gl_cv_func_getcwd_abort_bug=no
+
+    stripAllFlags=" " # the Darwin "strip" command doesn't know "-s"
   '';
 
   bootstrapTools = derivation {