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,36 @@
Disable rpath for the bootstrap build with CMake.
--- a/Sources/PackageDescription/CMakeLists.txt
+++ b/Sources/PackageDescription/CMakeLists.txt
@@ -31,14 +31,11 @@ if(CMAKE_HOST_SYSTEM_NAME STREQUAL Darwin)
set(SWIFT_INTERFACE_PATH ${CMAKE_BINARY_DIR}/pm/ManifestAPI/PackageDescription.swiftinterface)
target_compile_options(PackageDescription PUBLIC
$<$<COMPILE_LANGUAGE:Swift>:-emit-module-interface-path$<SEMICOLON>${SWIFT_INTERFACE_PATH}>)
- target_link_options(PackageDescription PRIVATE
- "SHELL:-Xlinker -install_name -Xlinker @rpath/libPackageDescription.dylib")
endif()
set_target_properties(PackageDescription PROPERTIES
Swift_MODULE_NAME PackageDescription
Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/pm/ManifestAPI
- INSTALL_NAME_DIR \\@rpath
OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/pm/ManifestAPI
OUTPUT_NAME PackageDescription
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/pm/ManifestAPI
--- a/Sources/PackagePlugin/CMakeLists.txt
+++ b/Sources/PackagePlugin/CMakeLists.txt
@@ -29,14 +29,11 @@ if(CMAKE_HOST_SYSTEM_NAME STREQUAL Darwin)
set(SWIFT_INTERFACE_PATH ${CMAKE_BINARY_DIR}/pm/PluginAPI/PackagePlugin.swiftinterface)
target_compile_options(PackagePlugin PUBLIC
$<$<COMPILE_LANGUAGE:Swift>:-emit-module-interface-path$<SEMICOLON>${SWIFT_INTERFACE_PATH}>)
- target_link_options(PackagePlugin PRIVATE
- "SHELL:-Xlinker -install_name -Xlinker @rpath/libPackagePlugin.dylib")
endif()
set_target_properties(PackagePlugin PROPERTIES
Swift_MODULE_NAME PackagePlugin
Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/pm/PluginAPI
- INSTALL_NAME_DIR \\@rpath
OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/pm/PluginAPI
OUTPUT_NAME PackagePlugin
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/pm/PluginAPI

View File

@@ -0,0 +1,12 @@
--- a/Sources/PackageCollectionsSigning/CMakeLists.txt
+++ b/Sources/PackageCollectionsSigning/CMakeLists.txt
@@ -43,6 +43,7 @@ target_link_libraries(PackageCollectionsSigning PUBLIC
PackageCollectionsModel
TSCBasic)
target_link_libraries(PackageCollectionsSigning PRIVATE
- PackageCollectionsSigningLibc
- $<$<PLATFORM_ID:Darwin>:SHELL:-Xlinker -framework -Xlinker Security>)
+ PackageCollectionsSigningLibc)
+target_link_options(PackageCollectionsSigning PRIVATE
+ "$<$<PLATFORM_ID:Darwin>:SHELL:-Xlinker -framework -Xlinker Security>")

View File

@@ -0,0 +1,23 @@
The `-index-store-path` option is an Apple extension not available in our
Clang. Make it opt-in by default.
(It is assumed the `target.type == test` check is for Xcode support, because
there is no evidence of it in swift-corelibs-xctest.)
--- a/Sources/Build/BuildPlan.swift
+++ b/Sources/Build/BuildPlan.swift
@@ -103,14 +103,7 @@ extension BuildParameters {
case .off:
addIndexStoreArguments = false
case .auto:
- if configuration == .debug {
- addIndexStoreArguments = true
- } else if target.type == .test {
- // Test discovery requires an index store for the test target to discover the tests
- addIndexStoreArguments = true
- } else {
addIndexStoreArguments = false
- }
}
if addIndexStoreArguments {

View File

@@ -0,0 +1,21 @@
Nix may already sandbox the build, in which case sandbox_apply will fail.
--- a/Sources/Basics/Sandbox.swift
+++ b/Sources/Basics/Sandbox.swift
@@ -33,12 +33,14 @@ public enum Sandbox {
readOnlyDirectories: [AbsolutePath] = []
) throws -> [String] {
#if os(macOS)
+ let env = ProcessInfo.processInfo.environment
+ if env["NIX_BUILD_TOP"] == nil || env["IN_NIX_SHELL"] != nil {
let profile = try macOSSandboxProfile(strictness: strictness, writableDirectories: writableDirectories, readOnlyDirectories: readOnlyDirectories)
return ["/usr/bin/sandbox-exec", "-p", profile] + command
- #else
+ }
+ #endif
// rdar://40235432, rdar://75636874 tracks implementing sandboxes for other platforms.
return command
- #endif
}
/// Basic strictness level of a sandbox applied to a command line.

View File

@@ -0,0 +1,37 @@
XCTest is not fully open-source, only the Swift library parts. We don't have a
command-line runner available, so disable support.
--- a/Sources/Commands/Utilities/TestingSupport.swift
+++ b/Sources/Commands/Utilities/TestingSupport.swift
@@ -72,7 +72,7 @@ enum TestingSupport {
/// - Returns: Array of TestSuite
static func getTestSuites(fromTestAt path: AbsolutePath, swiftTool: SwiftTool, enableCodeCoverage: Bool, sanitizers: [Sanitizer]) throws -> [TestSuite] {
// Run the correct tool.
- #if os(macOS)
+ #if false
let data: String = try withTemporaryFile { tempFile in
let args = [try Self.xctestHelperPath(swiftTool: swiftTool).pathString, path.pathString, tempFile.path.pathString]
var env = try Self.constructTestEnvironment(
--- a/Sources/swiftpm-xctest-helper/main.swift
+++ b/Sources/swiftpm-xctest-helper/main.swift
@@ -11,8 +11,11 @@
//===----------------------------------------------------------------------===//
#if os(macOS)
-import XCTest
import func Darwin.C.exit
+print("Not supported in Nix.")
+exit(1)
+#if false
+import XCTest
/// A helper tool to get list of tests from a XCTest Bundle on macOS.
///
@@ -134,6 +137,7 @@ do {
exit(1)
}
+#endif // nix
#else
#if os(Windows)

View File

@@ -0,0 +1,121 @@
Swiftpm may invoke clang, not clang++, to compile C++. Our cc-wrapper also
doesn't pick up the arguments that enable C++ compilation in this case. Patch
swiftpm to properly invoke clang++.
--- a/Sources/Build/BuildPlan.swift
+++ b/Sources/Build/BuildPlan.swift
@@ -2089,7 +2089,7 @@ public class BuildPlan: SPMBuildCore.BuildPlan {
for target in dependencies.staticTargets {
if case let target as ClangTarget = target.underlyingTarget, target.isCXX {
if buildParameters.hostTriple.isDarwin() {
- buildProduct.additionalFlags += ["-lc++"]
+ buildProduct.additionalFlags += ["-lc++", "-lc++abi"]
} else if buildParameters.hostTriple.isWindows() {
// Don't link any C++ library.
} else {
--- a/Sources/Build/LLBuildManifestBuilder.swift
+++ b/Sources/Build/LLBuildManifestBuilder.swift
@@ -786,7 +786,7 @@ extension LLBuildManifestBuilder {
args += ["-c", path.source.pathString, "-o", path.object.pathString]
- let clangCompiler = try buildParameters.toolchain.getClangCompiler().pathString
+ let clangCompiler = try buildParameters.toolchain.getClangCompiler(isCXX: isCXX).pathString
args.insert(clangCompiler, at: 0)
let objectFileNode: Node = .file(path.object)
--- a/Sources/PackageModel/Toolchain.swift
+++ b/Sources/PackageModel/Toolchain.swift
@@ -23,7 +23,7 @@ public protocol Toolchain {
var macosSwiftStdlib: AbsolutePath { get throws }
/// Path of the `clang` compiler.
- func getClangCompiler() throws -> AbsolutePath
+ func getClangCompiler(isCXX: Bool) throws -> AbsolutePath
// FIXME: This is a temporary API until index store is widely available in
// the OSS clang compiler. This API should not used for any other purpose.
--- a/Sources/PackageModel/UserToolchain.swift
+++ b/Sources/PackageModel/UserToolchain.swift
@@ -57,7 +57,7 @@ public final class UserToolchain: Toolchain {
/// Only use search paths, do not fall back to `xcrun`.
let useXcrun: Bool
- private var _clangCompiler: AbsolutePath?
+ private var _clangCompiler: [Bool: AbsolutePath] = [:]
private let environment: EnvironmentVariables
@@ -196,29 +196,31 @@ public final class UserToolchain: Toolchain {
}
/// Returns the path to clang compiler tool.
- public func getClangCompiler() throws -> AbsolutePath {
+ public func getClangCompiler(isCXX: Bool) throws -> AbsolutePath {
// Check if we already computed.
- if let clang = self._clangCompiler {
+ if let clang = self._clangCompiler[isCXX] {
return clang
}
// Check in the environment variable first.
- if let toolPath = UserToolchain.lookup(variable: "CC", searchPaths: self.envSearchPaths, environment: environment) {
- self._clangCompiler = toolPath
+ let envVar = isCXX ? "CXX" : "CC";
+ if let toolPath = UserToolchain.lookup(variable: envVar, searchPaths: self.envSearchPaths, environment: environment) {
+ self._clangCompiler[isCXX] = toolPath
return toolPath
}
// Then, check the toolchain.
+ let tool = isCXX ? "clang++" : "clang";
do {
- if let toolPath = try? UserToolchain.getTool("clang", binDir: self.destination.toolchainBinDir) {
- self._clangCompiler = toolPath
+ if let toolPath = try? UserToolchain.getTool(tool, binDir: self.destination.binDir) {
+ self._clangCompiler[isCXX] = toolPath
return toolPath
}
}
// Otherwise, lookup it up on the system.
- let toolPath = try UserToolchain.findTool("clang", envSearchPaths: self.envSearchPaths, useXcrun: useXcrun)
- self._clangCompiler = toolPath
+ let toolPath = try UserToolchain.findTool(tool, envSearchPaths: self.envSearchPaths, useXcrun: useXcrun)
+ self._clangCompiler[isCXX] = toolPath
return toolPath
}
--- a/Sources/SPMBuildCore/BuildParameters.swift
+++ b/Sources/SPMBuildCore/BuildParameters.swift
@@ -394,7 +394,7 @@ private struct _Toolchain: Encodable {
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(toolchain.swiftCompilerPath, forKey: .swiftCompiler)
- try container.encode(toolchain.getClangCompiler(), forKey: .clangCompiler)
+ try container.encode(toolchain.getClangCompiler(isCXX: false), forKey: .clangCompiler)
try container.encode(toolchain.extraFlags.cCompilerFlags, forKey: .extraCCFlags)
// Maintaining `extraCPPFlags` key for compatibility with older encoding.
--- a/Sources/XCBuildSupport/XcodeBuildSystem.swift
+++ b/Sources/XCBuildSupport/XcodeBuildSystem.swift
@@ -182,7 +182,7 @@ public final class XcodeBuildSystem: SPMBuildCore.BuildSystem {
// Generate a table of any overriding build settings.
var settings: [String: String] = [:]
// An error with determining the override should not be fatal here.
- settings["CC"] = try? buildParameters.toolchain.getClangCompiler().pathString
+ settings["CC"] = try? buildParameters.toolchain.getClangCompiler(isCXX: false).pathString
// Always specify the path of the effective Swift compiler, which was determined in the same way as for the native build system.
settings["SWIFT_EXEC"] = buildParameters.toolchain.swiftCompilerPath.pathString
settings["LIBRARY_SEARCH_PATHS"] = "$(inherited) \(try buildParameters.toolchain.toolchainLibDir.pathString)"
--- a/Tests/BuildTests/MockBuildTestHelper.swift
+++ b/Tests/BuildTests/MockBuildTestHelper.swift
@@ -23,7 +23,7 @@ struct MockToolchain: PackageModel.Toolchain {
#else
let extraFlags = BuildFlags(cxxCompilerFlags: ["-lstdc++"])
#endif
- func getClangCompiler() throws -> AbsolutePath {
+ func getClangCompiler(isCXX: Bool) throws -> AbsolutePath {
return AbsolutePath(path: "/fake/path/to/clang")
}

View File

@@ -0,0 +1,25 @@
Swiftpm looks for the Swift stdlib relative to the swift compiler, but that's a
wrapper in our case. It wants to add the stdlib to the rpath, which is
necessary for back-deployment of some features.
--- a/Sources/PackageModel/Toolchain.swift
+++ b/Sources/PackageModel/Toolchain.swift
@@ -53,12 +53,18 @@ extension Toolchain {
public var macosSwiftStdlib: AbsolutePath {
get throws {
+ if swiftCompilerPath.pathString.starts(with: "@storeDir@") {
+ return AbsolutePath("@swiftLib@/lib/swift/macosx")
+ }
return try AbsolutePath(validating: "../../lib/swift/macosx", relativeTo: resolveSymlinks(swiftCompilerPath))
}
}
public var toolchainLibDir: AbsolutePath {
get throws {
+ if swiftCompilerPath.pathString.starts(with: "@storeDir@") {
+ return AbsolutePath("@swiftLib@/lib")
+ }
// FIXME: Not sure if it's better to base this off of Swift compiler or our own binary.
return try AbsolutePath(validating: "../../lib", relativeTo: resolveSymlinks(swiftCompilerPath))
}

View File

@@ -0,0 +1,14 @@
Specifying `-platform_version` targeting macos before 10.15 causes cctools ld
to link with `@rpath`. This may have something to do with Swift ABI stability.
--- a/products/llbuildSwift/CMakeLists.txt
+++ b/products/llbuildSwift/CMakeLists.txt
@@ -22,7 +17,7 @@ endif()
# TODO(compnerd) move both of these outside of the CMake into the invocation
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
- add_compile_options(-target ${CMAKE_OSX_ARCHITECTURES}-apple-macosx10.10)
+ add_compile_options(-target ${CMAKE_OSX_ARCHITECTURES}-apple-macosx10.15)
if(NOT CMAKE_OSX_SYSROOT STREQUAL "")
add_compile_options(-sdk ${CMAKE_OSX_SYSROOT})
endif()

View File

@@ -0,0 +1,28 @@
Swift parses .pc files manually, but this means it bypasses our pkg-config
wrapper. That wrapper normally takes care of introducing the correct
PKG_CONFIG_PATH for cross compiling.
--- a/Sources/PackageLoading/PkgConfig.swift
+++ b/Sources/PackageLoading/PkgConfig.swift
@@ -123,14 +123,17 @@ public struct PkgConfig {
private static var envSearchPaths: [AbsolutePath] {
get throws {
- if let configPath = ProcessEnv.vars["PKG_CONFIG_PATH"] {
+ var result: [AbsolutePath] = []
+ for envVar in ["PKG_CONFIG_PATH", "PKG_CONFIG_PATH_FOR_TARGET"] {
+ if let configPath = ProcessEnv.vars[envVar] {
#if os(Windows)
- return try configPath.split(separator: ";").map({ try AbsolutePath(validating: String($0)) })
+ result += try configPath.split(separator: ";").map({ try AbsolutePath(validating: String($0)) })
#else
- return try configPath.split(separator: ":").map({ try AbsolutePath(validating: String($0)) })
+ result += try configPath.split(separator: ":").map({ try AbsolutePath(validating: String($0)) })
#endif
}
- return []
+ }
+ return result
}
}
}