···3333expandResponseParams "$@"3434linkType=$(checkLinkType "${params[@]}")35353636+declare -ag positionalArgs=()3637declare -i n=03738nParams=${#params[@]}3839while (( "$n" < "$nParams" )); do···5453 *-header) dontLink=1 ;;5554 c++*) isCxx=1 ;;5655 esac5656+ ;;5757+ --) # Everything else is positional args!5858+ # See: https://github.com/llvm/llvm-project/commit/ed1d07282cc9d8e4c25d585e03e5c8a1b6f63a745959+6060+ # Any positional arg (i.e. any argument after `--`) will be6161+ # interpreted as a "non flag" arg:6262+ if [[ -v "params[$n]" ]]; then nonFlagArgs=1; fi6363+6464+ positionalArgs=("${params[@]:$n}")6565+ params=("${params[@]:0:$((n - 1))}")6666+ break;5767 ;;5868 -?*) ;;5969 *) nonFlagArgs=1 ;; # Includes a solitary dash (`-`) which signifies standard input; it is not a flag···217205if [ "$cc1" = 1 ]; then218206 extraAfter=()219207 extraBefore=()208208+fi209209+210210+# Finally, if we got any positional args, append them to `extraAfter`211211+# now:212212+if [[ "${#positionalArgs[@]}" -gt 0 ]]; then213213+ extraAfter+=(-- "${positionalArgs[@]}")220214fi221215222216# Optionally print debug info.
+23
pkgs/test/cc-wrapper/default.nix
···1313 name = "cc-wrapper-test";14141515 buildCommand = ''1616+ set -o pipefail1717+1618 NIX_DEBUG=1 $CC -v1719 NIX_DEBUG=1 $CXX -v1820···4341 $CC ${staticLibc} -static-pie -o cc-static-pie ${./cc-main.c}4442 ${emulator} ./cc-static-pie4543 ''}4444+ ''}4545+4646+ ${# See: https://github.com/llvm/llvm-project/commit/ed1d07282cc9d8e4c25d585e03e5c8a1b6f63a744747+ # `gcc` does not support this so we gate the test on `clang`4848+ lib.optionalString stdenv.cc.isClang ''4949+ printf "checking whether cc-wrapper accepts -- followed by positional (file) args..." >&25050+ mkdir -p positional5151+5252+ # Make sure `--` is not parsed as a "non flag arg"; we should get an5353+ # input file error here and *not* a linker error.5454+ { ! $CC --; } |& grep -q "no input files"5555+5656+ # And that positional file args _must_ be files (this is just testing5757+ # that we remembered to put the `--` back in the args to the compiler):5858+ { ! $CC -c -- -o foo ${./foo.c}; } \5959+ |& grep -q "no such file or directory: '-o'"6060+6161+ # Now check that we accept single and multiple positional file args:6262+ $CC -c -DVALUE=42 -o positional/foo.o -- ${./foo.c}6363+ $CC -o positional/main -- positional/foo.o ${./ldflags-main.c}6464+ ${emulator} ./positional/main4665 ''}47664867 printf "checking whether compiler uses NIX_CFLAGS_COMPILE... " >&2