···11+needsTarget=true
22+33+for p in "${params[@]}"; do
44+ case "$p" in
55+ -target | --target=*) needsTarget=false ;;
66+ esac
77+done
88+99+if $needsTarget; then
1010+ extraBefore+=(-target @defaultTarget@)
1111+fi
+40-47
pkgs/build-support/cc-wrapper/cc-wrapper.sh
···3838while (( "$n" < "$nParams" )); do
3939 p=${params[n]}
4040 p2=${params[n+1]:-} # handle `p` being last one
4141- if [ "$p" = -c ]; then
4242- dontLink=1
4343- elif [ "$p" = -S ]; then
4444- dontLink=1
4545- elif [ "$p" = -E ]; then
4646- dontLink=1
4747- elif [ "$p" = -E ]; then
4848- dontLink=1
4949- elif [ "$p" = -M ]; then
5050- dontLink=1
5151- elif [ "$p" = -MM ]; then
5252- dontLink=1
5353- elif [[ "$p" = -x && "$p2" = *-header ]]; then
5454- dontLink=1
5555- elif [[ "$p" = -x && "$p2" = c++* && "$isCxx" = 0 ]]; then
5656- isCxx=1
5757- elif [ "$p" = -nostdlib ]; then
5858- cxxLibrary=0
5959- elif [ "$p" = -nostdinc ]; then
6060- cInclude=0
6161- cxxInclude=0
6262- elif [ "$p" = -nostdinc++ ]; then
6363- cxxInclude=0
6464- elif [[ "$p" != -?* ]]; then
6565- # A dash alone signifies standard input; it is not a flag
6666- nonFlagArgs=1
6767- elif [ "$p" = -cc1 ]; then
6868- cc1=1
6969- fi
7041 n+=1
4242+4343+ case "$p" in
4444+ -[cSEM] | -MM) dontLink=1 ;;
4545+ -cc1) cc1=1 ;;
4646+ -nostdinc) cInclude=0 cxxInclude=0 ;;
4747+ -nostdinc++) cxxInclude=0 ;;
4848+ -nostdlib) cxxLibrary=0 ;;
4949+ -x)
5050+ case "$p2" in
5151+ *-header) dontLink=1 ;;
5252+ c++*) isCxx=1 ;;
5353+ esac
5454+ ;;
5555+ -?*) ;;
5656+ *) nonFlagArgs=1 ;; # Includes a solitary dash (`-`) which signifies standard input; it is not a flag
5757+ esac
7158done
72597360# If we pass a flag like -Wl, then gcc will call the linker unless it
···81688269# Optionally filter out paths not refering to the store.
8370if [[ "${NIX_ENFORCE_PURITY:-}" = 1 && -n "$NIX_STORE" ]]; then
8484- rest=()
7171+ kept=()
8572 nParams=${#params[@]}
8673 declare -i n=0
8774 while (( "$n" < "$nParams" )); do
8875 p=${params[n]}
8976 p2=${params[n+1]:-} # handle `p` being last one
9090- if [ "${p:0:3}" = -L/ ] && badPath "${p:2}"; then
9191- skip "${p:2}"
9292- elif [ "$p" = -L ] && badPath "$p2"; then
9393- n+=1; skip "$p2"
9494- elif [ "${p:0:3}" = -I/ ] && badPath "${p:2}"; then
9595- skip "${p:2}"
9696- elif [ "$p" = -I ] && badPath "$p2"; then
9797- n+=1; skip "$p2"
9898- elif [ "$p" = -isystem ] && badPath "$p2"; then
9999- n+=1; skip "$p2"
100100- else
101101- rest+=("$p")
7777+ n+=1
7878+7979+ skipNext=false
8080+ path=""
8181+ case "$p" in
8282+ -[IL]/*) path=${p:2} ;;
8383+ -[IL] | -isystem) path=$p2 skipNext=true ;;
8484+ esac
8585+8686+ if [[ -n $path ]] && badPath "$path"; then
8787+ skip "$path"
8888+ $skipNext && n+=1
8989+ continue
10290 fi
103103- n+=1
9191+9292+ kept+=("$p")
10493 done
10594 # Old bash empty array hack
106106- params=(${rest+"${rest[@]}"})
9595+ params=(${kept+"${kept[@]}"})
10796fi
1089710998# Flirting with a layer violation here.
···118107119108# Clear march/mtune=native -- they bring impurity.
120109if [ "$NIX_ENFORCE_NO_NATIVE_@suffixSalt@" = 1 ]; then
121121- rest=()
110110+ kept=()
122111 # Old bash empty array hack
123112 for p in ${params+"${params[@]}"}; do
124113 if [[ "$p" = -m*=native ]]; then
125114 skip "$p"
126115 else
127127- rest+=("$p")
116116+ kept+=("$p")
128117 fi
129118 done
130119 # Old bash empty array hack
131131- params=(${rest+"${rest[@]}"})
120120+ params=(${kept+"${kept[@]}"})
132121fi
133122134123if [[ "$isCxx" = 1 ]]; then
···168157 fi
169158 done
170159 export NIX_LINK_TYPE_@suffixSalt@=$linkType
160160+fi
161161+162162+if [[ -e @out@/nix-support/add-local-cc-cflags-before.sh ]]; then
163163+ source @out@/nix-support/add-local-cflags-before.sh
171164fi
172165173166# As a very special hack, if the arguments are just `-v', then don't
+9-8
pkgs/build-support/cc-wrapper/default.nix
···298298 ''
299299300300 ##
301301- ## General Clang support
302302- ##
303303- + optionalString isClang ''
304304-305305- echo "-target ${targetPlatform.config}" >> $out/nix-support/cc-cflags
306306- ''
307307-308308- ##
309301 ## GCC libs for non-GCC support
310302 ##
311303 + optionalString useGccForLibs ''
···522514 substituteAll ${./add-flags.sh} $out/nix-support/add-flags.sh
523515 substituteAll ${./add-hardening.sh} $out/nix-support/add-hardening.sh
524516 substituteAll ${../wrapper-common/utils.bash} $out/nix-support/utils.bash
517517+ ''
518518+519519+ ##
520520+ ## General Clang support
521521+ ## Needs to go after ^ because the for loop eats \n and makes this file an invalid script
522522+ ##
523523+ + optionalString isClang ''
524524+ export defaultTarget=${targetPlatform.config}
525525+ substituteAll ${./add-clang-cc-cflags-before.sh} $out/nix-support/add-local-cc-cflags-before.sh
525526 ''
526527527528 ##