Skip to content

Commit 997d97b

Browse files
committed
swiftPackages.stdenv: use the default standard environment
Swift now works fine with standard environments using GCC or other versions of LLVM. Some packages, like components of Swift itself or others that combine Swift with features like C++ modules or C blocks, may still need to use an LLVM‐based standard environment, but we do not need to enforce a uniform `swiftPackages.stdenv` any more.
1 parent a1a2f97 commit 997d97b

File tree

1 file changed

+24
-32
lines changed

1 file changed

+24
-32
lines changed

pkgs/development/compilers/swift/default.nix

Lines changed: 24 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,21 @@
11
{
22
lib,
3-
pkgs,
43
newScope,
5-
darwin,
4+
stdenv,
65
llvmPackages,
7-
overrideCC,
8-
overrideLibcxx,
6+
darwin,
97
}:
108

119
let
12-
swiftLlvmPackages = llvmPackages;
13-
1410
self = rec {
1511

1612
callPackage = newScope self;
1713

18-
# Swift builds its own Clang for internal use. We wrap that clang with a
19-
# cc-wrapper derived from the clang configured below. Because cc-wrapper
20-
# applies a specific resource-root, the two versions are best matched, or
21-
# we'll often run into compilation errors.
22-
#
23-
# The following selects the correct Clang version, matching the version
24-
# used in Swift.
25-
inherit (swiftLlvmPackages) clang;
26-
27-
# Overrides that create a useful environment for swift packages, allowing
28-
# packaging with `swiftPackages.callPackage`.
29-
inherit (clang) bintools;
30-
stdenv =
31-
let
32-
stdenv' = overrideCC pkgs.stdenv clang;
33-
in
34-
# Ensure that Swift’s internal clang uses the same libc++ and libc++abi as the
35-
# default clang’s stdenv. Using the default libc++ avoids issues (such as crashes)
36-
# that can happen when a Swift application dynamically links different versions
37-
# of libc++ and libc++abi than libraries it links are using.
38-
if stdenv'.cc.libcxx != null then overrideLibcxx stdenv' else stdenv';
14+
# Provided for backwards compatibility.
15+
inherit stdenv;
3916

4017
swift-unwrapped = callPackage ./compiler {
18+
inherit (llvmPackages) stdenv;
4119
inherit (darwin) DarwinTools sigtool;
4220
};
4321

@@ -50,13 +28,19 @@ let
5028
if stdenv.hostPlatform.isDarwin then
5129
null # part of apple-sdk
5230
else
53-
callPackage ./libdispatch { swift = swiftNoSwiftDriver; };
31+
callPackage ./libdispatch {
32+
inherit (llvmPackages) stdenv;
33+
swift = swiftNoSwiftDriver;
34+
};
5435

5536
Foundation =
5637
if stdenv.hostPlatform.isDarwin then
5738
null # part of apple-sdk
5839
else
59-
callPackage ./foundation { swift = swiftNoSwiftDriver; };
40+
callPackage ./foundation {
41+
inherit (llvmPackages) stdenv;
42+
swift = swiftNoSwiftDriver;
43+
};
6044

6145
# TODO: Apple distributes a binary XCTest with Xcode, but it is not part of
6246
# CLTools (or SUS), so would have to figure out how to fetch it. The binary
@@ -67,23 +51,31 @@ let
6751
};
6852

6953
swiftpm = callPackage ./swiftpm {
54+
inherit (llvmPackages) stdenv;
7055
inherit (darwin) DarwinTools;
7156
swift = swiftNoSwiftDriver;
7257
};
7358

7459
swift-driver = callPackage ./swift-driver {
60+
inherit (llvmPackages) stdenv;
7561
swift = swiftNoSwiftDriver;
7662
};
7763

7864
swift = callPackage ./wrapper {
7965
swift = swift-unwrapped;
8066
};
8167

82-
sourcekit-lsp = callPackage ./sourcekit-lsp { };
68+
sourcekit-lsp = callPackage ./sourcekit-lsp {
69+
inherit (llvmPackages) stdenv;
70+
};
8371

84-
swift-docc = callPackage ./swift-docc { };
72+
swift-docc = callPackage ./swift-docc {
73+
inherit (llvmPackages) stdenv;
74+
};
8575

86-
swift-format = callPackage ./swift-format { };
76+
swift-format = callPackage ./swift-format {
77+
inherit (llvmPackages) stdenv;
78+
};
8779

8880
swiftpm2nix = callPackage ./swiftpm2nix { };
8981

0 commit comments

Comments
 (0)