git.iko.soy/typeable/nixpkgs
on master help sign in
swift: Fix build for glibc 2.30
7d8a331Silvan Mosberger
pkgs/development/compilers/swift/default.nix+10
@@ -26,6 +26,7 @@
26, git
26, git
27, libgit2
27, libgit2
28, fetchFromGitHub
28, fetchFromGitHub
29+, fetchpatch
29, findutils
30, findutils
30, makeWrapper
31, makeWrapper
31, gnumake
32, gnumake
@@ -224,6 +225,15 @@ stdenv.mkDerivation {
224 # uuid.h is not part of glibc, but of libuuid
225 # uuid.h is not part of glibc, but of libuuid
225 sed -i 's|''${GLIBC_INCLUDE_PATH}/uuid/uuid.h|${libuuid.dev}/include/uuid/uuid.h|' swift/stdlib/public/Platform/glibc.modulemap.gyb
226 sed -i 's|''${GLIBC_INCLUDE_PATH}/uuid/uuid.h|${libuuid.dev}/include/uuid/uuid.h|' swift/stdlib/public/Platform/glibc.modulemap.gyb
226
227
228+ # Compatibility with glibc 2.30
229+ # Adapted from https://github.com/apple/swift-package-manager/pull/2408
230+ patch -p1 -d swiftpm -i ${./patches/swift-package-manager-glibc-2.30.patch}
231+ # https://github.com/apple/swift/pull/27288
232+ patch -p1 -d swift -i ${fetchpatch {
233+ url = "https://github.com/apple/swift/commit/f968f4282d53f487b29cf456415df46f9adf8748.patch";
234+ sha256 = "1aa7l66wlgip63i4r0zvi9072392bnj03s4cn12p706hbpq0k37c";
235+ }}
236+
227 PREFIX=''${out/#\/}
237 PREFIX=''${out/#\/}
228 substituteInPlace indexstore-db/Utilities/build-script-helper.py \
238 substituteInPlace indexstore-db/Utilities/build-script-helper.py \
229 --replace usr "$PREFIX"
239 --replace usr "$PREFIX"
pkgs/development/compilers/swift/patches/swift-package-manager-glibc-2.30.patchnew file+25
@@ -0,0 +1,25 @@
1+diff --git a/Sources/Basic/Process.swift b/Sources/Basic/Process.swift
2+index f388c769..8f208691 100644
3+--- a/Sources/Basic/Process.swift
4++++ b/Sources/Basic/Process.swift
5+@@ -322,7 +322,10 @@ public final class Process: ObjectIdentifierProtocol {
6+ defer { posix_spawn_file_actions_destroy(&fileActions) }
7+
8+ // Workaround for https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=89e435f3559c53084498e9baad22172b64429362
9+- let devNull = strdup("/dev/null")
10++ // Change allowing for newer version of glibc
11++ guard let devNull = strdup("/dev/null") else {
12++ throw SystemError.posix_spawn(0, arguments)
13++ }
14+ defer { free(devNull) }
15+ // Open /dev/null as stdin.
16+ posix_spawn_file_actions_addopen(&fileActions, 0, devNull, O_RDONLY, 0)
17+@@ -348,7 +351,7 @@ public final class Process: ObjectIdentifierProtocol {
18+
19+ let argv = CStringArray(arguments)
20+ let env = CStringArray(environment.map({ "\($0.0)=\($0.1)" }))
21+- let rv = posix_spawnp(&processID, argv.cArray[0], &fileActions, &attributes, argv.cArray, env.cArray)
22++ let rv = posix_spawnp(&processID, argv.cArray[0]!, &fileActions, &attributes, argv.cArray, env.cArray)
23+
24+ guard rv == 0 else {
25+ throw SystemError.posix_spawn(rv, arguments)