about summary refs log tree commit diff
path: root/pkgs/build-support/rust
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2023-12-17 01:22:04 +0100
committerAlyssa Ross <hi@alyssa.is>2023-12-19 11:34:02 +0100
commitca8a6d8c19ed6534c6e4b088e2348c261cc2bc33 (patch)
tree29c5b58d068ec76a20fba0df07e0def2cbc8b2c6 /pkgs/build-support/rust
parent1f30be411f2f3e3aa7cc614eea659dcdeaad1d7e (diff)
wrapRustcWith: allow --sysroot to be overridden
It turns out that unlike a normal Unix program, if the --sysroot
option is given more than once, rustc will error rather than using the
last value given.  Therefore, we need to ensure we only add our
default --sysroot argument if one hasn't been given explicitly on the
wrapper's command line.

This fixes cross compilation of rustc.

Closes: https://github.com/NixOS/nixpkgs/issues/271736
Fixes: 8b51cdd3bea1 ("rustc: add a compiler wrapper")
Diffstat (limited to 'pkgs/build-support/rust')
-rw-r--r--pkgs/build-support/rust/rustc-wrapper/rustc-wrapper.sh15
1 files changed, 14 insertions, 1 deletions
diff --git a/pkgs/build-support/rust/rustc-wrapper/rustc-wrapper.sh b/pkgs/build-support/rust/rustc-wrapper/rustc-wrapper.sh
index a62e35b8736f7..2082f3126a538 100644
--- a/pkgs/build-support/rust/rustc-wrapper/rustc-wrapper.sh
+++ b/pkgs/build-support/rust/rustc-wrapper/rustc-wrapper.sh
@@ -1,6 +1,19 @@
 #!@shell@
 
-extraBefore=(@sysroot@)
+defaultSysroot=(@sysroot@)
+
+for arg; do
+    case "$arg" in
+        --sysroot)
+            defaultSysroot=()
+            ;;
+        --)
+            break
+            ;;
+    esac
+done
+
+extraBefore=("${defaultSysroot[@]}")
 extraAfter=($NIX_RUSTFLAGS)
 
 # Optionally print debug info.