Skip to content

Merge release/6.2 into main #544

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Jun 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
65eed71
[6.2] Update the swift-driver to release/6.2 branch (#407)
shahmishal Apr 12, 2025
2fa7228
Update the swift-llbuild in Package.swift to release/6.2 branch (#409)
shahmishal Apr 14, 2025
09d78a5
Merge remote-tracking branch 'origin/release/6.2' into owenv/update-6.2
owenv Apr 24, 2025
0118c59
Merge pull request #404 from swiftlang/owenv/update-6.2
owenv Apr 24, 2025
7ce677e
Merge pull request #472 from swiftlang/automerge/merge-main-2025-04-3…
owenv May 1, 2025
6a0f7f2
Merge pull request #487 from swiftlang/automerge/merge-main-2025-05-0…
owenv May 5, 2025
80013f9
Merge pull request #503 from swiftlang/automerge/merge-main-2025-05-1…
owenv May 12, 2025
51369cd
Merge pull request #504 from swiftlang/automerge/merge-main-2025-05-1…
owenv May 12, 2025
56bb6cb
Merge pull request #512 from swiftlang/automerge/merge-main-2025-05-1…
owenv May 19, 2025
d4ff33b
Introduce SWIFT_ENABLE_LANGUAGE_FEATURE_ENABLEMENT_DIAGNOSTICS settin…
tshortli May 27, 2025
5684bd7
Merge pull request #532 from swiftlang/automerge/merge-main-2025-05-2…
owenv May 28, 2025
82a4683
[Swift C++ Interop] Propagate hardening build setting to Swift
susmonteiro May 7, 2025
b7aac2e
Merge pull request #539 from swiftlang/egorzhdan/6.2-hardening
egorzhdan May 29, 2025
6ca7864
Simplify fallback developer directory calculation
jakepetroules May 28, 2025
818b886
Ensure unique tasks with the same description aren't diagnosed as dup…
owenv May 30, 2025
ffab126
Merge pull request #541 from swiftlang/owenv/custom-task-dupes
owenv May 30, 2025
561e474
Revert "Update the swift-llbuild in Package.swift to release/6.2 bran…
owenv Jun 2, 2025
b51f812
Revert "[6.2] Update the swift-driver to release/6.2 branch (#407)"
owenv Jun 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Sources/SWBApplePlatform/Plugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import SWBTaskConstruction
}

struct AppleDeveloperDirectoryExtension: DeveloperDirectoryExtension {
func fallbackDeveloperDirectory(hostOperatingSystem: OperatingSystem) async throws -> Path? {
try await hostOperatingSystem == .macOS ? Xcode.getActiveDeveloperDirectoryPath() : nil
func fallbackDeveloperDirectory(hostOperatingSystem: OperatingSystem) async throws -> Core.DeveloperPath? {
try await hostOperatingSystem == .macOS ? .xcode(Xcode.getActiveDeveloperDirectoryPath()) : nil
}
}

Expand Down
28 changes: 10 additions & 18 deletions Sources/SWBCore/Core.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,9 @@ public final class Core: Sendable {
delegate.error("Could not determine path to developer directory because no extensions provided a fallback value")
return nil
case 1:
let path = values[0]
if path.str.hasSuffix(".app/Contents/Developer") {
resolvedDeveloperPath = .xcode(path)
} else {
resolvedDeveloperPath = .fallback(values[0])
}
resolvedDeveloperPath = values[0]
default:
delegate.error("Could not determine path to developer directory because multiple extensions provided conflicting fallback values: \(values.sorted().map { $0.str }.joined(separator: ", "))")
delegate.error("Could not determine path to developer directory because multiple extensions provided conflicting fallback values: \(values.map { $0.path.str }.sorted().joined(separator: ", "))")
return nil
}
}
Expand Down Expand Up @@ -181,12 +176,9 @@ public final class Core: Sendable {
// A path to the root of a Swift toolchain, optionally paired with the developer path of an installed Xcode
case swiftToolchain(Path, xcodeDeveloperPath: Path?)

// A fallback resolved path.
case fallback(Path)

public var path: Path {
switch self {
case .xcode(let path), .swiftToolchain(let path, xcodeDeveloperPath: _), .fallback(let path):
case .xcode(let path), .swiftToolchain(let path, xcodeDeveloperPath: _):
return path
}
}
Expand Down Expand Up @@ -259,7 +251,7 @@ public final class Core: Sendable {
self.xcodeProductBuildVersion = ProductBuildVersion(major: 99, train: "T", build: 999)
self.xcodeProductBuildVersionString = xcodeProductBuildVersion.description
}
case .swiftToolchain, .fallback:
case .swiftToolchain:
// FIXME: Eliminate this requirment for Swift toolchains
self.xcodeVersion = Version(99, 99, 99)
self.xcodeProductBuildVersion = ProductBuildVersion(major: 99, train: "T", build: 999)
Expand All @@ -277,12 +269,14 @@ public final class Core: Sendable {
case .xcode(let path):
toolchainPaths.append((path.join("Toolchains"), strict: path.str.hasSuffix(".app/Contents/Developer")))
case .swiftToolchain(let path, xcodeDeveloperPath: let xcodeDeveloperPath):
toolchainPaths.append((path, strict: true))
if hostOperatingSystem == .windows {
toolchainPaths.append((path.join("Toolchains"), strict: true))
} else {
toolchainPaths.append((path, strict: true))
}
if let xcodeDeveloperPath {
toolchainPaths.append((xcodeDeveloperPath.join("Toolchains"), strict: xcodeDeveloperPath.str.hasSuffix(".app/Contents/Developer")))
}
case .fallback(let path):
toolchainPaths.append((path.join("Toolchains"), strict: false))
}

// FIXME: We should support building the toolchain locally (for `inferiorProductsPath`).
Expand Down Expand Up @@ -418,7 +412,7 @@ public final class Core: Sendable {
let pluginPath = path.join("usr/lib/libToolchainCASPlugin.dylib")
let plugin = try? ToolchainCASPlugin(dylib: pluginPath)
casPlugin = plugin
case .swiftToolchain, .fallback:
case .swiftToolchain:
// Unimplemented
break
}
Expand Down Expand Up @@ -454,8 +448,6 @@ public final class Core: Sendable {
} else {
searchPaths = []
}
case .fallback:
searchPaths = []
}
}
if let additionalPlatformSearchPaths = getEnvironmentVariable("XCODE_EXTRA_PLATFORM_FOLDERS") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ public struct DeveloperDirectoryExtensionPoint: ExtensionPoint {
}

public protocol DeveloperDirectoryExtension: Sendable {
func fallbackDeveloperDirectory(hostOperatingSystem: OperatingSystem) async throws -> Path?
func fallbackDeveloperDirectory(hostOperatingSystem: OperatingSystem) async throws -> Core.DeveloperPath?
}
2 changes: 1 addition & 1 deletion Sources/SWBCore/MacroConfigFileLoader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ final class MacroConfigFileLoader: Sendable {
// FIXME: Move this to its proper home, and support the other special cases Xcode has (PLATFORM_DIR and SDK_DIR). This should move to using a generic facility, e.g., source trees: <rdar://problem/23576831> Add search paths for .xcconfig macros to match what Xcode has
if path.str.hasPrefix("<DEVELOPER_DIR>") {
switch developerPath {
case .xcode(let developerPath), .swiftToolchain(let developerPath, _), .fallback(let developerPath):
case .xcode(let developerPath), .swiftToolchain(let developerPath, _):
path = Path(path.str.replacingOccurrences(of: "<DEVELOPER_DIR>", with: developerPath.str))
}
}
Expand Down
2 changes: 2 additions & 0 deletions Sources/SWBCore/Settings/BuiltinMacros.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1009,6 +1009,7 @@ public final class BuiltinMacros {
public static let SWIFT_ENABLE_BARE_SLASH_REGEX = BuiltinMacros.declareBooleanMacro("SWIFT_ENABLE_BARE_SLASH_REGEX")
public static let SWIFT_ENABLE_EMIT_CONST_VALUES = BuiltinMacros.declareBooleanMacro("SWIFT_ENABLE_EMIT_CONST_VALUES")
public static let SWIFT_ENABLE_OPAQUE_TYPE_ERASURE = BuiltinMacros.declareBooleanMacro("SWIFT_ENABLE_OPAQUE_TYPE_ERASURE")
public static let SWIFT_ENABLE_LANGUAGE_FEATURE_ENABLEMENT_DIAGNOSTICS = BuiltinMacros.declareBooleanMacro("SWIFT_ENABLE_LANGUAGE_FEATURE_ENABLEMENT_DIAGNOSTICS")
public static let SWIFT_EMIT_CONST_VALUE_PROTOCOLS = BuiltinMacros.declareStringListMacro("SWIFT_EMIT_CONST_VALUE_PROTOCOLS")
public static let SWIFT_GENERATE_ADDITIONAL_LINKER_ARGS = BuiltinMacros.declareBooleanMacro("SWIFT_GENERATE_ADDITIONAL_LINKER_ARGS")
public static let SWIFT_USE_INTEGRATED_DRIVER = BuiltinMacros.declareBooleanMacro("SWIFT_USE_INTEGRATED_DRIVER")
Expand Down Expand Up @@ -2180,6 +2181,7 @@ public final class BuiltinMacros {
SWIFT_ENABLE_BARE_SLASH_REGEX,
SWIFT_ENABLE_EMIT_CONST_VALUES,
SWIFT_ENABLE_OPAQUE_TYPE_ERASURE,
SWIFT_ENABLE_LANGUAGE_FEATURE_ENABLEMENT_DIAGNOSTICS,
SWIFT_EMIT_CONST_VALUE_PROTOCOLS,
SWIFT_GENERATE_ADDITIONAL_LINKER_ARGS,
SWIFT_ENABLE_TESTABILITY,
Expand Down
2 changes: 1 addition & 1 deletion Sources/SWBCore/Settings/Settings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,7 @@ extension WorkspaceContext {

// Add the standard search paths.
switch core.developerPath {
case .xcode(let path), .fallback(let path):
case .xcode(let path):
paths.append(path.join("usr").join("bin"))
paths.append(path.join("usr").join("local").join("bin"))
case .swiftToolchain(let path, let xcodeDeveloperPath):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1443,6 +1443,9 @@ public final class SwiftCompilerSpec : CompilerSpec, SpecIdentifierType, SwiftDi
}

private func diagnoseFeatureEnablement(_ cbc: CommandBuildContext, _ languageFeatureEnablementInfo: SwiftBlocklists.LanguageFeatureEnablementInfo, _ delegate: any TaskGenerationDelegate) {
guard cbc.scope.evaluate(BuiltinMacros.SWIFT_ENABLE_LANGUAGE_FEATURE_ENABLEMENT_DIAGNOSTICS) else {
return
}
let moduleName = cbc.scope.evaluate(BuiltinMacros.SWIFT_MODULE_NAME)
let otherFlags = cbc.scope.evaluate(BuiltinMacros.OTHER_SWIFT_FLAGS)
var otherFlagsFeatures: [String] = []
Expand Down
4 changes: 2 additions & 2 deletions Sources/SWBGenericUnixPlatform/Plugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ import Foundation
}

struct GenericUnixDeveloperDirectoryExtension: DeveloperDirectoryExtension {
func fallbackDeveloperDirectory(hostOperatingSystem: OperatingSystem) async throws -> Path? {
func fallbackDeveloperDirectory(hostOperatingSystem: OperatingSystem) async throws -> Core.DeveloperPath? {
if hostOperatingSystem == .windows || hostOperatingSystem == .macOS {
// Handled by the Windows and Apple plugins
return nil
}

return .root
return .swiftToolchain(.root, xcodeDeveloperPath: nil)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,43 @@ final class CustomTaskProducer: PhasedTaskProducer, TaskProducer {
let workingDirectory = customTask.workingDirectory.map { Path(context.settings.globalScope.evaluate($0)).normalize() } ?? context.defaultWorkingDirectory
let inputPaths = customTask.inputFilePaths.map { Path(context.settings.globalScope.evaluate($0)).normalize() }
let inputs = inputPaths.map { delegate.createNode($0) }
var outputs: [any PlannedNode] = customTask.outputFilePaths.map { Path(context.settings.globalScope.evaluate($0)).normalize() }.map { delegate.createNode($0) }

let outputPaths = customTask.outputFilePaths.map { Path(context.settings.globalScope.evaluate($0)).normalize() }
var outputs: [any PlannedNode] = outputPaths.map { delegate.createNode($0) }

let md5Context = InsecureHashContext()
for arg in commandLine {
md5Context.add(string: arg)
md5Context.add(number: 0)
}
md5Context.add(number: 1)
for (key, value) in environment.bindingsDictionary {
md5Context.add(string: key)
md5Context.add(number: 0)
md5Context.add(string: value)
md5Context.add(number: 0)
}
md5Context.add(number: 1)
md5Context.add(string: workingDirectory.str)
md5Context.add(number: 1)
for input in inputPaths {
md5Context.add(string: input.str)
md5Context.add(number: 0)
}
md5Context.add(number: 1)
for output in outputPaths {
md5Context.add(string: output.str)
md5Context.add(number: 0)
}
let taskSignature = md5Context.signature.asString

if outputs.isEmpty {
// If there are no outputs, create a virtual output that can be wired up to gates
let md5Context = InsecureHashContext()
for arg in commandLine {
md5Context.add(string: arg)
}
for (key, value) in environment.bindingsDictionary {
md5Context.add(string: key)
md5Context.add(string: value)
}
md5Context.add(string: workingDirectory.str)
for input in inputPaths {
md5Context.add(string: input.str)
}
outputs.append(delegate.createVirtualNode("CustomTask-\(md5Context.signature.asString)"))
outputs.append(delegate.createVirtualNode("CustomTask-\(taskSignature)"))
}

delegate.createTask(
type: CustomTaskTypeDescription.only,
ruleInfo: ["CustomTask", context.settings.globalScope.evaluate(customTask.executionDescription)],
ruleInfo: ["CustomTask", context.settings.globalScope.evaluate(customTask.executionDescription), taskSignature],
commandLine: commandLine,
environment: environment,
workingDirectory: workingDirectory,
Expand Down
2 changes: 1 addition & 1 deletion Sources/SWBTestSupport/CoreTestSupport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ extension Core {
if hostOperatingSystem == .macOS {
developerPath = .xcode(try await Xcode.getActiveDeveloperDirectoryPath())
} else {
developerPath = .fallback(Path.root)
developerPath = .swiftToolchain(.root, xcodeDeveloperPath: nil)
}
let delegate = TestingCoreDelegate()
return await (try Core(delegate: delegate, hostOperatingSystem: hostOperatingSystem, pluginManager: PluginManager(skipLoadingPluginIdentifiers: []), developerPath: developerPath, resourceSearchPaths: [], inferiorProductsPath: nil, additionalContentPaths: [], environment: [:], buildServiceModTime: Date(), connectionMode: .inProcess), delegate.diagnostics)
Expand Down
2 changes: 1 addition & 1 deletion Sources/SWBTestSupport/DummyCommandProducer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ package struct MockCommandProducer: CommandProducer, Sendable {
paths.append(path)
}
switch core.developerPath {
case .xcode(let path), .fallback(let path):
case .xcode(let path):
paths.append(path.join("usr").join("bin"))
paths.append(path.join("usr").join("local").join("bin"))
case .swiftToolchain(let path, xcodeDeveloperPath: let xcodeDeveloperPath):
Expand Down
15 changes: 15 additions & 0 deletions Sources/SWBUniversalPlatform/Specs/Swift.xcspec
Original file line number Diff line number Diff line change
Expand Up @@ -1353,6 +1353,21 @@
};
},

// Hidden clang importer options to control C++ behavior
// in the clang importer, not visible in build settings.
{
Name = "SWIFT_CLANG_CXX_STANDARD_LIBRARY_HARDENING";
Type = String;
DefaultValue = "$(CLANG_CXX_STANDARD_LIBRARY_HARDENING)";
CommandLineArgs = {
"none" = ("-Xcc", "-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE");
"fast" = ("-Xcc", "-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_FAST");
"extensive" = ("-Xcc", "-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE");
"debug" = ("-Xcc", "-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG");
"<<otherwise>>" = ();
};
},

{
Name = "SWIFT_OVERLOAD_PREBUILT_MODULE_CACHE_PATH";
Type = Path;
Expand Down
14 changes: 3 additions & 11 deletions Sources/SWBWindowsPlatform/Plugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ public final class WindowsPlugin: Sendable {
}

struct WindowsDeveloperDirectoryExtension: DeveloperDirectoryExtension {
func fallbackDeveloperDirectory(hostOperatingSystem: OperatingSystem) async throws -> Path? {
func fallbackDeveloperDirectory(hostOperatingSystem: OperatingSystem) async throws -> Core.DeveloperPath? {
guard hostOperatingSystem == .windows else {
return nil
}
guard let userProgramFiles = URL.userProgramFiles, let swiftPath = try? userProgramFiles.appending(component: "Swift").filePath else {
throw StubError.error("Could not determine path to user program files")
}
return swiftPath
return .swiftToolchain(swiftPath, xcodeDeveloperPath: nil)
}
}

Expand Down Expand Up @@ -94,15 +94,7 @@ struct WindowsPlatformExtension: PlatformInfoExtension {
return []
}

let platformsPath: Path
switch context.developerPath {
case .xcode(let path):
platformsPath = path.join("Platforms")
case .swiftToolchain(let path, _):
platformsPath = path.join("Platforms")
case .fallback(let path):
platformsPath = path.join("Platforms")
}
let platformsPath = context.developerPath.path.join("Platforms")
return try context.fs.listdir(platformsPath).compactMap { version in
let versionedPlatformsPath = platformsPath.join(version)
guard context.fs.isDirectory(versionedPlatformsPath) else {
Expand Down
1 change: 1 addition & 0 deletions Tests/SWBBuildSystemTests/SwiftDriverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4821,6 +4821,7 @@ fileprivate struct SwiftDriverTests: CoreBasedTests {
TestBuildConfiguration(
"Debug",
buildSettings: [
"SWIFT_ENABLE_LANGUAGE_FEATURE_ENABLEMENT_DIAGNOSTICS": "YES",
"PRODUCT_NAME": "$(TARGET_NAME)",
"SWIFT_VERSION": "5",
"BUILD_VARIANTS": "normal",
Expand Down
Loading