mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 21:50:33 +03:00
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++.
This commit is contained in:
parent
9ae5c2de7f
commit
efdf4e9d1f
1 changed files with 18 additions and 2 deletions
|
@ -2,11 +2,14 @@
|
||||||
, pkgs
|
, pkgs
|
||||||
, newScope
|
, newScope
|
||||||
, darwin
|
, darwin
|
||||||
|
, llvmPackages
|
||||||
, llvmPackages_15
|
, llvmPackages_15
|
||||||
, overrideCC
|
, overrideCC
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
swiftLlvmPackages = llvmPackages_15;
|
||||||
|
|
||||||
self = rec {
|
self = rec {
|
||||||
|
|
||||||
callPackage = newScope self;
|
callPackage = newScope self;
|
||||||
|
@ -24,12 +27,25 @@ let
|
||||||
# used in Swift, and applies the same libc overrides as `apple_sdk.stdenv`.
|
# used in Swift, and applies the same libc overrides as `apple_sdk.stdenv`.
|
||||||
clang = if pkgs.stdenv.isDarwin
|
clang = if pkgs.stdenv.isDarwin
|
||||||
then
|
then
|
||||||
llvmPackages_15.clang.override rec {
|
swiftLlvmPackages.clang.override rec {
|
||||||
libc = apple_sdk.Libsystem;
|
libc = apple_sdk.Libsystem;
|
||||||
bintools = pkgs.bintools.override { inherit libc; };
|
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
|
else
|
||||||
llvmPackages_15.clang;
|
swiftLlvmPackages.clang;
|
||||||
|
|
||||||
# Overrides that create a useful environment for swift packages, allowing
|
# Overrides that create a useful environment for swift packages, allowing
|
||||||
# packaging with `swiftPackages.callPackage`. These are similar to
|
# packaging with `swiftPackages.callPackage`. These are similar to
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue