From ca8a6d8c19ed6534c6e4b088e2348c261cc2bc33 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sun, 17 Dec 2023 01:22:04 +0100 Subject: [PATCH] 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") --- .../rust/rustc-wrapper/rustc-wrapper.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/pkgs/build-support/rust/rustc-wrapper/rustc-wrapper.sh b/pkgs/build-support/rust/rustc-wrapper/rustc-wrapper.sh index a62e35b8736f..2082f3126a53 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.