lol

swift: use stdenv libc++ on Darwin

Swift uses libc++ 15, but it should really be using the same libc++ from
the stdenv. While not strictly needed currently, Swift 5.9 will support
C++ interop. If Swift is not using the stdenv C++, any C++ library used
with interop would need to be rebuilt against the Swift libc++.

+18 -2
+18 -2
pkgs/development/compilers/swift/default.nix
··· 2 2 , pkgs 3 3 , newScope 4 4 , darwin 5 + , llvmPackages 5 6 , llvmPackages_15 6 7 , overrideCC 7 8 }: 8 9 9 10 let 11 + swiftLlvmPackages = llvmPackages_15; 12 + 10 13 self = rec { 11 14 12 15 callPackage = newScope self; ··· 24 27 # used in Swift, and applies the same libc overrides as `apple_sdk.stdenv`. 25 28 clang = if pkgs.stdenv.isDarwin 26 29 then 27 - llvmPackages_15.clang.override rec { 30 + swiftLlvmPackages.clang.override rec { 28 31 libc = apple_sdk.Libsystem; 29 32 bintools = pkgs.bintools.override { inherit libc; }; 33 + # Ensure that Swift’s internal clang uses the same libc++ and libc++abi as the 34 + # default Darwin stdenv. Using the default libc++ avoids issues (such as crashes) 35 + # that can happen when a Swift application dynamically links different versions 36 + # of libc++ and libc++abi than libraries it links are using. 37 + inherit (llvmPackages) libcxx; 38 + extraPackages = [ 39 + llvmPackages.libcxxabi 40 + # Use the compiler-rt associated with clang, but use the libc++abi from the stdenv 41 + # to avoid linking against two different versions (for the same reasons as above). 42 + (swiftLlvmPackages.compiler-rt.override { 43 + inherit (llvmPackages) libcxxabi; 44 + }) 45 + ]; 30 46 } 31 47 else 32 - llvmPackages_15.clang; 48 + swiftLlvmPackages.clang; 33 49 34 50 # Overrides that create a useful environment for swift packages, allowing 35 51 # packaging with `swiftPackages.callPackage`. These are similar to