about summary refs log tree commit diff
path: root/pkgs/development/compilers
diff options
context:
space:
mode:
authorDaiderd Jordan <daiderd@gmail.com>2017-11-17 22:31:32 +0100
committerGitHub <noreply@github.com>2017-11-17 22:31:32 +0100
commitccf7310e2db1397678294105d877719040e8e9ca (patch)
tree484f42c5bedb0c9594a0db112582fcb8b7b36656 /pkgs/development/compilers
parentb7734b61a0a4076ac9f940217272acf7e75c851f (diff)
parentc72b22c420587ff15e6212a7ba022dbd2c75b8ae (diff)
downloadnixlib-ccf7310e2db1397678294105d877719040e8e9ca.tar
nixlib-ccf7310e2db1397678294105d877719040e8e9ca.tar.gz
nixlib-ccf7310e2db1397678294105d877719040e8e9ca.tar.bz2
nixlib-ccf7310e2db1397678294105d877719040e8e9ca.tar.lz
nixlib-ccf7310e2db1397678294105d877719040e8e9ca.tar.xz
nixlib-ccf7310e2db1397678294105d877719040e8e9ca.tar.zst
nixlib-ccf7310e2db1397678294105d877719040e8e9ca.zip
Merge pull request #31125 from LnL7/darwin-rust-bootstrap
rust-bootstrap: cleanup darwin expression
Diffstat (limited to 'pkgs/development/compilers')
-rw-r--r--pkgs/development/compilers/rust/binaryBuild.nix57
-rw-r--r--pkgs/development/compilers/rust/bootstrap.nix7
2 files changed, 38 insertions, 26 deletions
diff --git a/pkgs/development/compilers/rust/binaryBuild.nix b/pkgs/development/compilers/rust/binaryBuild.nix
index 37b06555bdbd..e67b305106e1 100644
--- a/pkgs/development/compilers/rust/binaryBuild.nix
+++ b/pkgs/development/compilers/rust/binaryBuild.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, makeWrapper, cacert, zlib, buildRustPackage, curl
+{ stdenv, fetchurl, makeWrapper, cacert, zlib, buildRustPackage, curl, darwin
 , version
 , src
 , platform
@@ -6,12 +6,32 @@
 }:
 
 let
-  inherit (stdenv.lib) optionalString;
-
-  needsPatchelf = stdenv.isLinux;
+  inherit (stdenv.lib) getLib optionalString;
+  inherit (darwin) libiconv;
+  inherit (darwin.apple_sdk.frameworks) Security;
 
   bootstrapping = versionType == "bootstrap";
 
+  patchBootstrapCargo = ''
+    ${optionalString (stdenv.isLinux && bootstrapping) ''
+      patchelf \
+        --set-rpath "${stdenv.lib.makeLibraryPath [ curl zlib ]}" \
+        --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
+        "$out/bin/cargo"
+    ''}
+    ${optionalString (stdenv.isDarwin && bootstrapping) ''
+      install_name_tool \
+        -change /usr/lib/libiconv.2.dylib '${getLib libiconv}/lib/libiconv.2.dylib' \
+        "$out/bin/cargo"
+      install_name_tool \
+        -change /usr/lib/libcurl.4.dylib '${getLib curl}/lib/libcurl.4.dylib' \
+        "$out/bin/cargo"
+      install_name_tool \
+        -change /usr/lib/libz.1.dylib '${getLib zlib}/lib/libz.1.dylib' \
+        "$out/bin/cargo"
+    ''}
+  '';
+
   installComponents
     = "rustc,rust-std-${platform}"
     + (optionalString bootstrapping ",rust-docs,cargo")
@@ -34,35 +54,31 @@ rec {
       license = [ licenses.mit licenses.asl20 ];
     };
 
-    phases = ["unpackPhase" "installPhase"];
+    phases = ["unpackPhase" "installPhase" "fixupPhase"];
+
+    propagatedBuildInputs = stdenv.lib.optional stdenv.isDarwin Security;
 
     installPhase = ''
       ./install.sh --prefix=$out \
         --components=${installComponents}
 
-      ${optionalString (needsPatchelf && bootstrapping) ''
+      ${optionalString (stdenv.isLinux && bootstrapping) ''
         patchelf \
           --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
-          "$out/bin/rustdoc"
+          "$out/bin/rustc"
         patchelf \
-          --set-rpath "${stdenv.lib.makeLibraryPath [ curl zlib ]}" \
           --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
-          "$out/bin/cargo"
+          "$out/bin/rustdoc"
       ''}
 
-      ${optionalString needsPatchelf ''
-        patchelf \
-          --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
-          "$out/bin/rustc"
+      ${patchBootstrapCargo}
 
       # Do NOT, I repeat, DO NOT use `wrapProgram` on $out/bin/rustc
       # (or similar) here. It causes strange effects where rustc loads
       # the wrong libraries in a bootstrap-build causing failures that
       # are very hard to track dow. For details, see
       # https://github.com/rust-lang/rust/issues/34722#issuecomment-232164943
-      ''}
     '';
-
   };
 
   cargo = stdenv.mkDerivation rec {
@@ -78,19 +94,16 @@ rec {
       license = [ licenses.mit licenses.asl20 ];
     };
 
+    phases = ["unpackPhase" "installPhase" "fixupPhase"];
+
     buildInputs = [ makeWrapper ];
-    phases = ["unpackPhase" "installPhase"];
+    propagatedBuildInputs = stdenv.lib.optional stdenv.isDarwin Security;
 
     installPhase = ''
       ./install.sh --prefix=$out \
         --components=cargo
 
-      ${optionalString needsPatchelf ''
-        patchelf \
-          --set-rpath "${stdenv.lib.makeLibraryPath [ curl zlib ]}" \
-          --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
-          "$out/bin/cargo"
-      ''}
+      ${patchBootstrapCargo}
 
       wrapProgram "$out/bin/cargo" \
         --suffix PATH : "${rustc}/bin"
diff --git a/pkgs/development/compilers/rust/bootstrap.nix b/pkgs/development/compilers/rust/bootstrap.nix
index fbcac09fc458..14995005e123 100644
--- a/pkgs/development/compilers/rust/bootstrap.nix
+++ b/pkgs/development/compilers/rust/bootstrap.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, makeWrapper, cacert, zlib, curl }:
+{ stdenv, fetchurl, callPackage }:
 
 let
   # Note: the version MUST be one version prior to the version we're
@@ -29,9 +29,8 @@ let
      sha256 = hashes."${platform}";
   };
 
-in import ./binaryBuild.nix
-  { inherit stdenv fetchurl makeWrapper cacert zlib curl;
+in callPackage ./binaryBuild.nix
+  { inherit version src platform;
     buildRustPackage = null;
-    inherit version src platform;
     versionType = "bootstrap";
   }