diff --git a/pkgs/development/compilers/swift/compiler/default.nix b/pkgs/development/compilers/swift/compiler/default.nix index c71a22589d9f..5bb32d8496cd 100644 --- a/pkgs/development/compilers/swift/compiler/default.nix +++ b/pkgs/development/compilers/swift/compiler/default.nix @@ -523,8 +523,10 @@ stdenv.mkDerivation { # Add appleSwiftCore to the search paths. Adding the whole SDK results in build failures. OLD_NIX_SWIFTFLAGS_COMPILE="$NIX_SWIFTFLAGS_COMPILE" OLD_NIX_LDFLAGS="$NIX_LDFLAGS" + OLD_NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE" export NIX_SWIFTFLAGS_COMPILE=" -I ${appleSwiftCore}/lib/swift" export NIX_LDFLAGS+=" -L ${appleSwiftCore}/lib/swift" + export NIX_CFLAGS_COMPILE+=" -Wno-error=unguarded-availability" '' + '' @@ -568,6 +570,7 @@ stdenv.mkDerivation { # Restore search paths to remove appleSwiftCore. export NIX_SWIFTFLAGS_COMPILE="$OLD_NIX_SWIFTFLAGS_COMPILE" export NIX_LDFLAGS="$OLD_NIX_LDFLAGS" + export NIX_CFLAGS_COMPILE="$OLD_NIX_CFLAGS_COMPILE" '' + '' diff --git a/pkgs/development/compilers/swift/wrapper/wrapper.sh b/pkgs/development/compilers/swift/wrapper/wrapper.sh index 21fba5395123..2017f580cef2 100644 --- a/pkgs/development/compilers/swift/wrapper/wrapper.sh +++ b/pkgs/development/compilers/swift/wrapper/wrapper.sh @@ -248,6 +248,9 @@ fi # TODO: If we ever need to expand functionality of this hook, it may no longer # be compatible with Swift. Right now, it is only used on Darwin to force # -target, which also happens to work with Swift. +# As of 369cc5c66b1efdbca2f136aa0055fedca1117304 (#445119), this hook also sets +# the -Werror=unguarded-availability flag, which Swift can't accept. We prefix +# that flag with -Xcc in the for loop below 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 @@ -262,7 +265,7 @@ for ((i=0; i < ${#extraBefore[@]}; i++));do # TODO: Assumes macOS. extraBefore[i]="${extraBefore[i]/-apple-darwin/-apple-macosx${MACOSX_DEPLOYMENT_TARGET:-11.0}}" ;; - -march=*|-mcpu=*|-mfloat-abi=*|-mfpu=*|-mmode=*|-mthumb|-marm|-mtune=*) + -march=*|-mcpu=*|-mfloat-abi=*|-mfpu=*|-mmode=*|-mthumb|-marm|-mtune=*|-Werror=*) [[ i -gt 0 && ${extraBefore[i-1]} == -Xcc ]] && continue extraBefore=( "${extraBefore[@]:0:i}"