Skip to content

Commit

Permalink
Merge pull request #245641 from reckenrode/swift-libc++
Browse files Browse the repository at this point in the history
swift: use stdenv libc++ on Darwin
  • Loading branch information
wegank authored Aug 5, 2023
2 parents 9c475de + efdf4e9 commit c839b1f
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions pkgs/development/compilers/swift/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
, pkgs
, newScope
, darwin
, llvmPackages
, llvmPackages_15
, overrideCC
}:

let
swiftLlvmPackages = llvmPackages_15;

self = rec {

callPackage = newScope self;
Expand All @@ -24,12 +27,25 @@ let
# used in Swift, and applies the same libc overrides as `apple_sdk.stdenv`.
clang = if pkgs.stdenv.isDarwin
then
llvmPackages_15.clang.override rec {
swiftLlvmPackages.clang.override rec {
libc = apple_sdk.Libsystem;
bintools = pkgs.bintools.override { inherit libc; };
# Ensure that Swift’s internal clang uses the same libc++ and libc++abi as the
# default Darwin stdenv. Using the default libc++ avoids issues (such as crashes)
# that can happen when a Swift application dynamically links different versions
# of libc++ and libc++abi than libraries it links are using.
inherit (llvmPackages) libcxx;
extraPackages = [
llvmPackages.libcxxabi
# Use the compiler-rt associated with clang, but use the libc++abi from the stdenv
# to avoid linking against two different versions (for the same reasons as above).
(swiftLlvmPackages.compiler-rt.override {
inherit (llvmPackages) libcxxabi;
})
];
}
else
llvmPackages_15.clang;
swiftLlvmPackages.clang;

# Overrides that create a useful environment for swift packages, allowing
# packaging with `swiftPackages.callPackage`. These are similar to
Expand Down

0 comments on commit c839b1f

Please sign in to comment.