diff options
author | Rahul Butani <rrbutani@users.noreply.github.com> | 2023-05-03 16:42:11 -0500 |
---|---|---|
committer | Rahul Butani <rrbutani@users.noreply.github.com> | 2023-05-03 16:42:15 -0500 |
commit | 53b268ad4a513decaad91d69483ac48319ed54cb (patch) | |
tree | 706629563ab5341e16a9da3f0d580e50b268ebaf /pkgs | |
parent | 788d0cbe5841a648ce4460859c8ab6603d9e3367 (diff) |
cc-wrapper: support `--`
Fixes #228136.
Diffstat (limited to 'pkgs')
-rw-r--r-- | pkgs/build-support/cc-wrapper/cc-wrapper.sh | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/pkgs/build-support/cc-wrapper/cc-wrapper.sh b/pkgs/build-support/cc-wrapper/cc-wrapper.sh index e8eb579e15add..5350fc3cc9ae5 100644 --- a/pkgs/build-support/cc-wrapper/cc-wrapper.sh +++ b/pkgs/build-support/cc-wrapper/cc-wrapper.sh @@ -33,6 +33,7 @@ cInclude=1 expandResponseParams "$@" linkType=$(checkLinkType "${params[@]}") +declare -ag positionalArgs=() declare -i n=0 nParams=${#params[@]} while (( "$n" < "$nParams" )); do @@ -54,6 +55,17 @@ while (( "$n" < "$nParams" )); do c++*) isCxx=1 ;; esac ;; + --) # Everything else is positional args! + # See: https://github.com/llvm/llvm-project/commit/ed1d07282cc9d8e4c25d585e03e5c8a1b6f63a74 + + # Any positional arg (i.e. any argument after `--`) will be + # interpreted as a "non flag" arg: + if [[ -v "params[$n]" ]]; then nonFlagArgs=1; fi + + positionalArgs=("${params[@]:$n}") + params=("${params[@]:0:$((n - 1))}") + break; + ;; -?*) ;; *) nonFlagArgs=1 ;; # Includes a solitary dash (`-`) which signifies standard input; it is not a flag esac @@ -207,6 +219,12 @@ if [ "$cc1" = 1 ]; then extraBefore=() fi +# Finally, if we got any positional args, append them to `extraAfter` +# now: +if [[ "${#positionalArgs[@]}" -gt 0 ]]; then + extraAfter+=(-- "${positionalArgs[@]}") +fi + # Optionally print debug info. if (( "${NIX_DEBUG:-0}" >= 1 )); then # Old bash workaround, see ld-wrapper for explanation. |