From 9fd2efac08231b9a13459eafb597820b1023e23c Mon Sep 17 00:00:00 2001 From: Sam <30577766+Samasaur1@users.noreply.github.com> Date: Tue, 2 Apr 2024 18:25:04 -0700 Subject: swiftc: pass -Xcc before -march --- pkgs/development/compilers/swift/wrapper/wrapper.sh | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'pkgs/development/compilers/swift/wrapper') 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 -- cgit 1.4.1