From 923d687f99047e902012db0ffa27563c1c1c7f85 Mon Sep 17 00:00:00 2001 From: Alba Mendez Date: Thu, 27 Mar 2025 17:38:51 +0100 Subject: [PATCH] cc-wrapper: keep local cflags if the same target is passed 12b0e8a/6f756b4 work around clang errors when a nix-wrapped compiler is used like a multi-target compiler. it does so by dropping the machineFlags whenever -target/--target is found in the arguments. however this breaks compiler-rt, which is designed to acommodate multi-target builds and always passes `--target`. in its packaging we make sure to only build it for the target we need, essentially disabling the multi-target aspect, but because it still passes --target, the machineFlags are dropped and compiler-rt could end up being for an invalid ABI, producing an unusable stdenv.cc. we could manually pass machineFlags to compiler-rt's cmake build, but IMO it makes more sense to tolerate --target arguments whose value coincides with the wrapper's, keeping the machineFlags in this case. --- pkgs/build-support/cc-wrapper/add-clang-cc-cflags-before.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pkgs/build-support/cc-wrapper/add-clang-cc-cflags-before.sh b/pkgs/build-support/cc-wrapper/add-clang-cc-cflags-before.sh index 029e5e6ae29c..6a8c86258284 100644 --- a/pkgs/build-support/cc-wrapper/add-clang-cc-cflags-before.sh +++ b/pkgs/build-support/cc-wrapper/add-clang-cc-cflags-before.sh @@ -28,8 +28,6 @@ done if $targetPassed && [[ "$targetValue" != "@defaultTarget@" ]]; then echo "Warning: supplying the --target $targetValue != @defaultTarget@ argument to a nix-wrapped compiler may not work correctly - cc-wrapper is currently not designed with multi-target compilers in mind. You may want to use an un-wrapped compiler instead." >&2 -fi - -if ! $targetPassed && [[ $0 != *cpp ]]; then +elif [[ $0 != *cpp ]]; then extraBefore+=(-target @defaultTarget@ @machineFlags@) fi