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: 8b51cdd3be ("rustc: add a compiler wrapper")
This commit is contained in:
Alyssa Ross 2023-12-17 01:22:04 +01:00
parent 1f30be411f
commit ca8a6d8c19

View File

@ -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.