rustc: use the wrapper for fastCross sysroot

This avoids having two layers of wrapper for cross rustc.
This commit is contained in:
Alyssa Ross
2023-11-30 09:23:06 +00:00
committed by Adam Joseph
parent 8b51cdd3be
commit 8929ba838f
5 changed files with 16 additions and 7 deletions
@@ -1,4 +1,4 @@
{ lib, runCommand, rustc-unwrapped }:
{ lib, runCommand, rustc-unwrapped, sysroot ? null }:
runCommand "${rustc-unwrapped.pname}-wrapper-${rustc-unwrapped.version}" {
preferLocalBuild = true;
@@ -7,6 +7,7 @@ runCommand "${rustc-unwrapped.pname}-wrapper-${rustc-unwrapped.version}" {
env = {
prog = "${rustc-unwrapped}/bin/rustc";
sysroot = lib.optionalString (sysroot != null) "--sysroot ${sysroot}";
};
passthru = {
@@ -1,11 +1,16 @@
#!@shell@
extraBefore=(@sysroot@)
extraAfter=($NIX_RUSTFLAGS)
# Optionally print debug info.
if (( "${NIX_DEBUG:-0}" >= 1 )); then
echo "extra flags before to @prog@:" >&2
printf " %q\n" "${extraBefore[@]}" >&2
echo "original flags to @prog@:" >&2
printf " %q\n" "$@" >&2
echo "extra flags after to @prog@:" >&2
printf " %q\n" $NIX_RUSTFLAGS >&2
printf " %q\n" "${extraAfter[@]}" >&2
fi
exec @prog@ "$@" $NIX_RUSTFLAGS
exec @prog@ "${extraBefore[@]}" "$@" "${extraAfter[@]}"
+1 -1
View File
@@ -16,7 +16,7 @@
, CoreFoundation, Security, SystemConfiguration
, pkgsBuildTarget, pkgsBuildBuild, pkgsBuildHost
, makeRustPlatform
, wrapRustc
, wrapRustcWith
, llvmPackages_16, llvm_16
} @ args:
+5 -2
View File
@@ -18,7 +18,7 @@
, CoreFoundation, Security, SystemConfiguration
, pkgsBuildBuild
, makeRustPlatform
, wrapRustc
, wrapRustcWith
}:
let
@@ -76,7 +76,10 @@ in
# Use boot package set to break cycle
inherit (bootstrapRustPackages) cargo rustc rustfmt;
});
rustc = wrapRustc self.rustc-unwrapped;
rustc = wrapRustcWith {
inherit (self) rustc-unwrapped;
sysroot = if fastCross then self.rustc-unwrapped else null;
};
rustfmt = self.callPackage ./rustfmt.nix {
inherit Security;
inherit (self.buildRustPackages) rustc;
+1 -1
View File
@@ -169,7 +169,7 @@ in stdenv.mkDerivation (finalAttrs: {
python ./x.py --keep-stage=0 --stage=1 install library/std
mkdir -v $out/bin $doc $man
makeWrapper ${rustc.unwrapped}/bin/rustc $out/bin/rustc --add-flags "--sysroot $out"
ln -s ${rustc.unwrapped}/bin/rustc $out/bin
makeWrapper ${rustc.unwrapped}/bin/rustdoc $out/bin/rustdoc --add-flags "--sysroot $out"
ln -s ${rustc.unwrapped}/lib/rustlib/{manifest-rust-std-,}${stdenv.hostPlatform.rust.rustcTargetSpec} $out/lib/rustlib/
echo rust-std-${stdenv.hostPlatform.rust.rustcTargetSpec} >> $out/lib/rustlib/components