rust: fix sandbox build on darwin
This commit is contained in:
parent
375f50fa11
commit
fdaab47d58
@ -12,26 +12,6 @@ let
|
||||
|
||||
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")
|
||||
@ -56,7 +36,7 @@ rec {
|
||||
|
||||
phases = ["unpackPhase" "installPhase" "fixupPhase"];
|
||||
|
||||
propagatedBuildInputs = stdenv.lib.optional stdenv.isDarwin Security;
|
||||
buildInputs = stdenv.lib.optional stdenv.isDarwin Security;
|
||||
|
||||
installPhase = ''
|
||||
./install.sh --prefix=$out \
|
||||
@ -69,14 +49,21 @@ rec {
|
||||
patchelf \
|
||||
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
|
||||
"$out/bin/rustdoc"
|
||||
''}
|
||||
${optionalString (stdenv.isDarwin && bootstrapping) ''
|
||||
install_name_tool -change /usr/lib/libiconv.2.dylib '${darwin.libiconv}/lib/libiconv.2.dylib' "$out/bin/cargo"
|
||||
install_name_tool -change /usr/lib/libcurl.4.dylib '${stdenv.lib.getLib curl}/lib/libcurl.4.dylib' "$out/bin/cargo"
|
||||
install_name_tool -change /usr/lib/libz.1.dylib '${stdenv.lib.getLib zlib}/lib/libz.1.dylib' "$out/bin/cargo"
|
||||
patchelf \
|
||||
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
|
||||
"$out/bin/cargo"
|
||||
''}
|
||||
|
||||
${patchBootstrapCargo}
|
||||
${optionalString (stdenv.isDarwin && bootstrapping) ''
|
||||
install_name_tool -change /usr/lib/libresolv.9.dylib '${darwin.libresolv}/lib/libresolv.9.dylib' "$out/bin/rustc"
|
||||
install_name_tool -change /usr/lib/libresolv.9.dylib '${darwin.libresolv}/lib/libresolv.9.dylib' "$out/bin/rustdoc"
|
||||
install_name_tool -change /usr/lib/libiconv.2.dylib '${darwin.libiconv}/lib/libiconv.2.dylib' "$out/bin/cargo"
|
||||
install_name_tool -change /usr/lib/libresolv.9.dylib '${darwin.libresolv}/lib/libresolv.9.dylib' "$out/bin/cargo"
|
||||
install_name_tool -change /usr/lib/libcurl.4.dylib '${stdenv.lib.getLib curl}/lib/libcurl.4.dylib' "$out/bin/cargo"
|
||||
for f in $out/lib/lib*.dylib; do
|
||||
install_name_tool -change /usr/lib/libresolv.9.dylib '${darwin.libresolv}/lib/libresolv.9.dylib' "$f"
|
||||
done
|
||||
''}
|
||||
|
||||
# Do NOT, I repeat, DO NOT use `wrapProgram` on $out/bin/rustc
|
||||
# (or similar) here. It causes strange effects where rustc loads
|
||||
@ -101,14 +88,23 @@ rec {
|
||||
|
||||
phases = ["unpackPhase" "installPhase" "fixupPhase"];
|
||||
|
||||
buildInputs = [ makeWrapper ];
|
||||
propagatedBuildInputs = stdenv.lib.optional stdenv.isDarwin Security;
|
||||
buildInputs = [ makeWrapper ] ++ stdenv.lib.optional stdenv.isDarwin Security;
|
||||
|
||||
installPhase = ''
|
||||
./install.sh --prefix=$out \
|
||||
--components=cargo
|
||||
|
||||
${patchBootstrapCargo}
|
||||
${optionalString (stdenv.isLinux && bootstrapping) ''
|
||||
patchelf \
|
||||
--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 '${darwin.libiconv}/lib/libiconv.2.dylib' "$out/bin/cargo"
|
||||
install_name_tool -change /usr/lib/libresolv.9.dylib '${darwin.libresolv}/lib/libresolv.9.dylib' "$out/bin/cargo"
|
||||
install_name_tool -change /usr/lib/libcurl.4.dylib '${stdenv.lib.getLib curl}/lib/libcurl.4.dylib' "$out/bin/cargo"
|
||||
''}
|
||||
|
||||
wrapProgram "$out/bin/cargo" \
|
||||
--suffix PATH : "${rustc}/bin"
|
||||
|
@ -17,13 +17,13 @@
|
||||
|
||||
let
|
||||
inherit (stdenv.lib) optional optionalString;
|
||||
inherit (darwin.apple_sdk.frameworks) Security;
|
||||
|
||||
procps = if stdenv.isDarwin then darwin.ps else args.procps;
|
||||
|
||||
llvmShared = llvm.override { enableSharedLibraries = true; };
|
||||
|
||||
target = builtins.replaceStrings [" "] [","] (builtins.toString targets);
|
||||
|
||||
in
|
||||
|
||||
stdenv.mkDerivation {
|
||||
@ -141,6 +141,7 @@ stdenv.mkDerivation {
|
||||
++ optional (!stdenv.isDarwin) gdb;
|
||||
|
||||
buildInputs = [ ncurses ] ++ targetToolchains
|
||||
++ optional stdenv.isDarwin Security
|
||||
++ optional (!forceBundledLLVM) llvmShared;
|
||||
|
||||
outputs = [ "out" "man" "doc" ];
|
||||
|
Loading…
Reference in New Issue
Block a user