Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

swift: use stdenv libc++ on Darwin #245641

Merged
merged 1 commit into from
Aug 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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