about summary refs log tree commit diff
path: root/pkgs/development/compilers/swift/wrapper
diff options
context:
space:
mode:
authorSam <30577766+Samasaur1@users.noreply.github.com>2024-04-02 18:25:04 -0700
committerSam <30577766+Samasaur1@users.noreply.github.com>2024-04-02 21:41:45 -0700
commit9fd2efac08231b9a13459eafb597820b1023e23c (patch)
tree12969c86e272c745859d59b1c859d5563b7e385e /pkgs/development/compilers/swift/wrapper
parent3d784fc78a4582e48d77a105242b049fe9065b75 (diff)
swiftc: pass -Xcc before -march
Diffstat (limited to 'pkgs/development/compilers/swift/wrapper')
-rw-r--r--pkgs/development/compilers/swift/wrapper/wrapper.sh19
1 files changed, 14 insertions, 5 deletions
diff --git a/pkgs/development/compilers/swift/wrapper/wrapper.sh b/pkgs/development/compilers/swift/wrapper/wrapper.sh
index 0ac066d340d6f..5836dea397874 100644
--- a/pkgs/development/compilers/swift/wrapper/wrapper.sh
+++ b/pkgs/development/compilers/swift/wrapper/wrapper.sh
@@ -242,17 +242,26 @@ if [[ -e $cc_wrapper/nix-support/add-local-cc-cflags-before.sh ]]; then
     source $cc_wrapper/nix-support/add-local-cc-cflags-before.sh
 fi
 
-# May need to transform the triple injected by the above.
-for ((i = 1; i < ${#extraBefore[@]}; i++)); do
-    if [[ "${extraBefore[i]}" = -target ]]; then
+for ((i=0; i < ${#extraBefore[@]}; i++));do
+    case "${extraBefore[i]}" in
+    -target)
         i=$((i + 1))
         # On Darwin only, need to change 'aarch64' to 'arm64'.
         extraBefore[i]="${extraBefore[i]/aarch64-apple-/arm64-apple-}"
         # On Darwin, Swift requires the triple to be annotated with a version.
         # TODO: Assumes macOS.
         extraBefore[i]="${extraBefore[i]/-apple-darwin/-apple-macosx${MACOSX_DEPLOYMENT_TARGET:-11.0}}"
-        break
-    fi
+        ;;
+    -march=*)
+        [[ i -gt 0 && ${extraBefore[i-1]} == -Xcc ]] && continue
+        extraBefore=(
+            "${extraBefore[@]:0:i}"
+            -Xcc
+            "${extraBefore[@]:i:${#extraBefore[@]}}"
+        )
+        i=$((i + 1))
+        ;;
+    esac
 done
 
 # As a very special hack, if the arguments are just `-v', then don't