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.
This commit is contained in:
Alba Mendez
2025-03-28 10:49:11 +01:00
committed by Alyssa Ross
parent 4ab72ac13e
commit 923d687f99
@@ -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