mirror of
https://github.com/CHN-beta/nixpkgs.git
synced 2026-01-12 02:40:31 +08:00
cc-wrapper: warn about cross-compile only with non-default (#379593)
This commit is contained in:
@@ -1,15 +1,35 @@
|
||||
needsTarget=true
|
||||
targetValue=""
|
||||
|
||||
declare -i n=0
|
||||
nParams=${#params[@]}
|
||||
while (("$n" < "$nParams")); do
|
||||
p=${params[n]}
|
||||
v=${params[n + 1]:-} # handle `p` being last one
|
||||
n+=1
|
||||
|
||||
for p in "${params[@]}"; do
|
||||
case "$p" in
|
||||
-target | --target=*)
|
||||
-target)
|
||||
if [ -z "$v" ]; then
|
||||
echo "Error: -target requires an argument" >&2
|
||||
exit 1
|
||||
fi
|
||||
needsTarget=false
|
||||
|
||||
echo "Warning: supplying the --target 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
|
||||
targetValue=$v
|
||||
# skip parsing the value of -target
|
||||
n+=1
|
||||
;;
|
||||
--target=*)
|
||||
needsTarget=false
|
||||
targetValue="${p#*=}"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if ! $needsTarget && [[ "$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 $needsTarget && [[ $0 != *cpp ]]; then
|
||||
extraBefore+=(-target @defaultTarget@ @machineFlags@)
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user