push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1,91 @@
{
lib,
stdenv,
callPackage,
fetchpatch,
swift,
swiftpm,
swiftpm2nix,
Foundation,
XCTest,
sqlite,
ncurses,
clang,
replaceVars,
}:
let
sources = callPackage ../sources.nix { };
generated = swiftpm2nix.helpers ./generated;
# On Darwin, we only want ncurses in the linker search path, because headers
# are part of libsystem. Adding its headers to the search path causes strange
# mixing and errors.
# TODO: Find a better way to prevent this conflict.
ncursesInput = if stdenv.hostPlatform.isDarwin then ncurses.out else ncurses;
in
stdenv.mkDerivation {
pname = "swift-driver";
inherit (sources) version;
src = sources.swift-driver;
nativeBuildInputs = [
swift
swiftpm
];
buildInputs = [
Foundation
XCTest
sqlite
ncursesInput
];
patches = [
./patches/disable-catalyst.patch
(replaceVars ./patches/linux-fix-linking.patch {
inherit clang;
})
# TODO: Replace with branch patch once merged:
# https://github.com/apple/swift-driver/pull/1197
(fetchpatch {
url = "https://github.com/apple/swift-driver/commit/d3ef9cdf4871a58eddec7ff0e28fe611130da3f9.patch";
hash = "sha256-eVBaKN6uzj48ZnHtwGV0k5ChKjak1tDCyE+wTdyGq2c=";
})
# Prevent a warning about SDK directories we don't have.
(replaceVars ./patches/prevent-sdk-dirs-warnings.patch {
inherit (builtins) storeDir;
})
];
configurePhase = generated.configure + ''
swiftpmMakeMutable swift-tools-support-core
patch -p1 -d .build/checkouts/swift-tools-support-core -i ${
fetchpatch {
url = "https://github.com/apple/swift-tools-support-core/commit/990afca47e75cce136d2f59e464577e68a164035.patch";
hash = "sha256-PLzWsp+syiUBHhEFS8+WyUcSae5p0Lhk7SSRdNvfouE=";
includes = [ "Sources/TSCBasic/FileSystem.swift" ];
}
}
'';
# TODO: Tests depend on indexstore-db being provided by an existing Swift
# toolchain. (ie. looks for `../lib/libIndexStore.so` relative to swiftc.
#doCheck = true;
# TODO: Darwin-specific installation includes more, but not sure why.
installPhase = ''
binPath="$(swiftpmBinPath)"
mkdir -p $out/bin
for executable in swift-driver swift-help swift-build-sdk-interfaces; do
cp $binPath/$executable $out/bin/
done
'';
meta = {
description = "Swift compiler driver";
homepage = "https://github.com/apple/swift-driver";
platforms = with lib.platforms; linux ++ darwin;
license = lib.licenses.asl20;
teams = [ lib.teams.swift ];
};
}

View File

@@ -0,0 +1,11 @@
# This file was generated by swiftpm2nix.
{
workspaceStateFile = ./workspace-state.json;
hashes = {
"swift-argument-parser" = "1jph9w7lk9nr20fsv2c8p4hisx3dda817fh7pybd0r0j1jwa9nmw";
"swift-llbuild" = "106vnssh6pgy5s9dnq1hi1c9v2wkfydqgncg5dy7c9n23iisjy3s";
"swift-system" = "0402hkx2q2dv27gccnn8ma79ngvwiwzkhcv4zlcdldmy6cgi0px7";
"swift-tools-support-core" = "1qvblyiazv58qwyxgyk2dh5ymbab3y70vm2q81qs6rmv43hs8ciz";
"Yams" = "11abhcfkmqm3cmh7vp7rqzvxd1zj02j2866a2pp6v9m89456xb76";
};
}

View File

@@ -0,0 +1,93 @@
{
"object": {
"artifacts": [],
"dependencies": [
{
"basedOn": null,
"packageRef": {
"identity": "swift-argument-parser",
"kind": "remoteSourceControl",
"location": "https://github.com/apple/swift-argument-parser.git",
"name": "swift-argument-parser"
},
"state": {
"checkoutState": {
"revision": "e394bf350e38cb100b6bc4172834770ede1b7232",
"version": "1.0.3"
},
"name": "sourceControlCheckout"
},
"subpath": "swift-argument-parser"
},
{
"basedOn": null,
"packageRef": {
"identity": "swift-llbuild",
"kind": "remoteSourceControl",
"location": "https://github.com/apple/swift-llbuild.git",
"name": "llbuild"
},
"state": {
"checkoutState": {
"branch": "release/5.8",
"revision": "dccfc2e127a34b89a849407594cf2d604b598ba9"
},
"name": "sourceControlCheckout"
},
"subpath": "swift-llbuild"
},
{
"basedOn": null,
"packageRef": {
"identity": "swift-system",
"kind": "remoteSourceControl",
"location": "https://github.com/apple/swift-system.git",
"name": "swift-system"
},
"state": {
"checkoutState": {
"revision": "836bc4557b74fe6d2660218d56e3ce96aff76574",
"version": "1.1.1"
},
"name": "sourceControlCheckout"
},
"subpath": "swift-system"
},
{
"basedOn": null,
"packageRef": {
"identity": "swift-tools-support-core",
"kind": "remoteSourceControl",
"location": "https://github.com/apple/swift-tools-support-core.git",
"name": "swift-tools-support-core"
},
"state": {
"checkoutState": {
"branch": "release/5.8",
"revision": "ac4871e01ef338cb95b5d28328cab0ec1dfae935"
},
"name": "sourceControlCheckout"
},
"subpath": "swift-tools-support-core"
},
{
"basedOn": null,
"packageRef": {
"identity": "yams",
"kind": "remoteSourceControl",
"location": "https://github.com/jpsim/Yams.git",
"name": "Yams"
},
"state": {
"checkoutState": {
"revision": "01835dc202670b5bb90d07f3eae41867e9ed29f6",
"version": "5.0.1"
},
"name": "sourceControlCheckout"
},
"subpath": "Yams"
}
]
},
"version": 6
}

View File

@@ -0,0 +1,17 @@
Tries to parse SDKSettings.plist looking for a Catalyst version map, but we
don't currently support this.
--- a/Sources/SwiftDriver/Toolchains/DarwinToolchain.swift
+++ b/Sources/SwiftDriver/Toolchains/DarwinToolchain.swift
@@ -297,11 +297,7 @@ public final class DarwinToolchain: Toolchain {
debugDescription: "Malformed version string")
}
self.version = version
- if self.canonicalName.hasPrefix("macosx") {
- self.versionMap = try keyedContainer.decode(VersionMap.self, forKey: .versionMap)
- } else {
self.versionMap = VersionMap()
- }
}

View File

@@ -0,0 +1,40 @@
diff --git a/Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift b/Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift
index a4a735f498..381522cc1f 100644
--- a/Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift
+++ b/Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift
@@ -10,6 +10,7 @@
//
//===----------------------------------------------------------------------===//
+import Foundation
import SwiftOptions
import func TSCBasic.lookupExecutablePath
@@ -120,7 +121,18 @@
// just using `clang` and avoid a dependency on the C++ runtime.
let clangTool: Tool =
parsedOptions.hasArgument(.enableExperimentalCxxInterop) ? .clangxx : .clang
- var clangPath = try getToolPath(clangTool)
+
+ // For Nix, prefer linking using the wrapped Nixpkgs clang, instead of using
+ // the unwrapped clang packaged with swift. The latter is unable to link, but
+ // we still want to use it for other purposes (clang importer).
+ var clangPath: AbsolutePath
+ if let binPath = try? AbsolutePath(validating: "@clang@/bin"),
+ let tool = lookupExecutablePath(filename: parsedOptions.hasArgument(.enableExperimentalCxxInterop)
+ ? "clang++" : "clang",
+ searchPaths: [binPath]) {
+ clangPath = tool
+ } else {
+ clangPath = try getToolPath(clangTool)
if let toolsDirPath = parsedOptions.getLastArgument(.toolsDirectory) {
// FIXME: What if this isn't an absolute path?
let toolsDir = try AbsolutePath(validating: toolsDirPath.asSingle)
@@ -136,6 +148,7 @@
commandLine.appendFlag("-B")
commandLine.appendPath(toolsDir)
}
+ } // Nix
// Executables on Linux get -pie
if targetTriple.os == .linux && linkerOutputType == .executable {

View File

@@ -0,0 +1,16 @@
Prevents a user-visible warning on every compilation:
ld: warning: directory not found for option '-L.../MacOSX11.0.sdk/usr/lib/swift'
--- a/Sources/SwiftDriver/Jobs/Toolchain+LinkerSupport.swift
+++ b/Sources/SwiftDriver/Jobs/Toolchain+LinkerSupport.swift
@@ -50,7 +50,9 @@ extension Toolchain {
result.append(sdkPath.appending(components: "System", "iOSSupport", "usr", "lib", "swift"))
}
+ if sdkPath.absolutePath?.pathString.starts(with: "@storeDir@") == false {
result.append(sdkPath.appending(components: "usr", "lib", "swift"))
+ }
}
return result