Skip to content

Commit 80013f9

Browse files
authored
Merge pull request #503 from swiftlang/automerge/merge-main-2025-05-12_09-02
Merge `main` into `release/6.2`
2 parents 6a0f7f2 + ed66ddc commit 80013f9

File tree

45 files changed

+754
-450
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+754
-450
lines changed

.github/workflows/pull_request.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,4 @@ jobs:
6666
with:
6767
license_header_check_project_name: "Swift"
6868
api_breakage_check_enabled: false
69-
unacceptable_language_check_enabled: false
7069
format_check_enabled: false

Package.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,13 @@ let package = Package(
413413
verb: "cmake-smoke-test",
414414
description: "Build Swift Build using CMake for validation purposes"
415415
))
416+
),
417+
.plugin(
418+
name: "generate-windows-installer-component-groups",
419+
capability: .command(intent: .custom(
420+
verb: "generate-windows-installer-component-groups",
421+
description: "Generate XML fragments for cli.wxs in swift-installer-scripts"
422+
))
416423
)
417424
],
418425
swiftLanguageModes: [.v5, .v6],

Plugins/cmake-smoke-test/cmake-smoke-test.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ extension Process {
191191
Diagnostics.progress("Using process spawning workaround")
192192
// Linux workaround for https://github.com/swiftlang/swift-corelibs-foundation/issues/4772
193193
// Foundation.Process on Linux seems to inherit the Process.run()-calling thread's signal mask, creating processes that even have SIGTERM blocked
194-
// This manifests as CMake hanging when invoking 'uname' with incorrectly configured signal handlers.
194+
// This manifests as CMake getting stuck when invoking 'uname' with incorrectly configured signal handlers.
195195
var fileActions = posix_spawn_file_actions_t()
196196
defer { posix_spawn_file_actions_destroy(&fileActions) }
197197
var attrs: posix_spawnattr_t = posix_spawnattr_t()
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift open source project
4+
//
5+
// Copyright (c) 2025 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See http://swift.org/LICENSE.txt for license information
9+
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
import PackagePlugin
14+
import Foundation
15+
16+
@main
17+
struct GenerateWindowsInstallerComponentGroups: CommandPlugin {
18+
func performCommand(context: PluginContext, arguments: [String]) async throws {
19+
var librariesComponent = #" <ComponentGroup Id="SwiftBuild" Directory="_usr_bin">\#n"#
20+
var resourcesComponents = ""
21+
var groupRefs = #" <ComponentGroupRef Id="SwiftBuild" />\#n"#
22+
var directories = #" <Directory Id="_usr_share_pm" Name="pm">\#n"#
23+
for target in context.package.targets.sorted(by: { $0.name < $1.name }).filter({ !["SWBTestSupport", "SwiftBuildTestSupport"].contains($0.name) }) {
24+
guard let sourceModule = target.sourceModule, sourceModule.kind == .generic else {
25+
continue
26+
}
27+
librariesComponent += #"""
28+
<Component>
29+
<File Source="$(ToolchainRoot)\usr\bin\\#(sourceModule.name).dll" />
30+
</Component>
31+
32+
"""#
33+
34+
let resources = sourceModule.sourceFiles.filter { resource in resource.type == .resource && ["xcspec", "xcbuildrules"].contains(resource.url.pathExtension) }
35+
if !resources.isEmpty {
36+
groupRefs += #" <ComponentGroupRef Id="\#(sourceModule.name)Resources" />\#n"#
37+
directories += #" <Directory Id="_usr_share_pm_\#(sourceModule.name)" Name="SwiftBuild_\#(sourceModule.name).resources" />\#n"#
38+
resourcesComponents += #" <ComponentGroup Id="\#(sourceModule.name)Resources" Directory="_usr_share_pm_\#(sourceModule.name)">\#n"#
39+
for resource in resources {
40+
resourcesComponents += #"""
41+
<Component>
42+
<File Source="$(ToolchainRoot)\usr\share\pm\SwiftBuild_\#(sourceModule.name).resources\\#(resource.url.lastPathComponent)" />
43+
</Component>
44+
45+
"""#
46+
}
47+
resourcesComponents += " </ComponentGroup>\n"
48+
}
49+
}
50+
librariesComponent += " </ComponentGroup>\n"
51+
directories += " </Directory>\n"
52+
53+
print("Component Groups")
54+
print(String(repeating: "-", count: 80))
55+
print(librariesComponent)
56+
print(resourcesComponents)
57+
print("Group Refs")
58+
print(String(repeating: "-", count: 80))
59+
print(groupRefs)
60+
print("Directories")
61+
print(String(repeating: "-", count: 80))
62+
print(directories)
63+
}
64+
}

Sources/CMakeLists.txt

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,48 @@ See http://swift.org/LICENSE.txt for license information
88
See http://swift.org/CONTRIBUTORS.txt for Swift project authors
99
]]
1010

11+
include(CMakeParseArguments)
12+
function(SwiftBuild_Bundle)
13+
set(Options)
14+
set(OneValueArguments MODULE)
15+
set(MultiValueArguments FILES)
16+
cmake_parse_arguments(PARSE_ARGV 0 BundleXCSpecs
17+
"${Options}" "${OneValueArguments}" "${MultiValueArguments}")
18+
19+
list(TRANSFORM BundleXCSpecs_FILES PREPEND "${CMAKE_CURRENT_SOURCE_DIR}/")
20+
add_custom_command(TARGET ${BundleXCSpecs_MODULE} POST_BUILD
21+
COMMAND
22+
${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/share/pm/SwiftBuild_${BundleXCSpecs_MODULE}.resources"
23+
COMMAND
24+
${CMAKE_COMMAND} -E copy_if_different ${BundleXCSpecs_FILES} "${CMAKE_BINARY_DIR}/share/pm/SwiftBuild_${BundleXCSpecs_MODULE}.resources/")
25+
26+
file(TO_NATIVE_PATH "${CMAKE_BINARY_DIR}/share/pm/SwiftBuild_${BundleXCSpecs_MODULE}.resources" _SWIFT_BUILD_RESOURCE_BUNDLE_BUILD_PATH)
27+
file(CONFIGURE
28+
OUTPUT "${CMAKE_BINARY_DIR}/resource_accessors/SwiftBuild_${BundleXCSpecs_MODULE}_resource_bundle_accessor.swift"
29+
CONTENT [[
30+
import Foundation
31+
extension Foundation.Bundle {
32+
static let module: Bundle = {
33+
let mainPath = Bundle.main.bundleURL.appendingPathComponent("SwiftBuild_@[email protected]").path
34+
let buildPath = #"@_SWIFT_BUILD_RESOURCE_BUNDLE_BUILD_PATH@"#
35+
let preferredBundle = Bundle(path: mainPath)
36+
guard let bundle = preferredBundle ?? Bundle(path: buildPath) else {
37+
Swift.fatalError("could not load resource bundle: from \(mainPath) or \(buildPath)")
38+
}
39+
return bundle
40+
}()
41+
}
42+
]]
43+
ESCAPE_QUOTES @ONLY NEWLINE_STYLE LF)
44+
45+
target_sources("${BundleXCSpecs_MODULE}" PRIVATE
46+
"${CMAKE_BINARY_DIR}/resource_accessors/SwiftBuild_${BundleXCSpecs_MODULE}_resource_bundle_accessor.swift")
47+
48+
install(DIRECTORY
49+
"${CMAKE_BINARY_DIR}/share/pm/SwiftBuild_${BundleXCSpecs_MODULE}.resources/"
50+
DESTINATION share/pm/SwiftBuild_${BundleXCSpecs_MODULE}.resources/)
51+
endfunction()
52+
1153
add_subdirectory(SWBCSupport)
1254
add_subdirectory(SWBCLibc)
1355
add_subdirectory(SWBLibc)

Sources/SWBAndroidPlatform/CMakeLists.txt

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,35 +8,15 @@ See http://swift.org/LICENSE.txt for license information
88
See http://swift.org/CONTRIBUTORS.txt for Swift project authors
99
]]
1010

11-
file(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}"
12-
_SWBAndroidPlatform_NATIVE_CMAKE_CURRENT_BINARY_DIR)
13-
file(CONFIGURE
14-
OUTPUT resource_bundle_accessor.swift
15-
CONTENT [[
16-
import Foundation
17-
extension Foundation.Bundle {
18-
static let module: Bundle = {
19-
let mainPath = Bundle.main.bundleURL.appendingPathComponent("SwiftBuild_SWBAndroidPlatform.resources").path
20-
let buildPath = #"@_SWBAndroidPlatform_NATIVE_CMAKE_CURRENT_BINARY_DIR@\SwiftBuild_SWBAndroidPlatform.resources"#
21-
let preferredBundle = Bundle(path: mainPath)
22-
guard let bundle = preferredBundle ?? Bundle(path: buildPath) else {
23-
Swift.fatalError("could not load resource bundle: from \(mainPath) or \(buildPath)")
24-
}
25-
return bundle
26-
}()
27-
}
28-
]]
29-
ESCAPE_QUOTES @ONLY NEWLINE_STYLE LF)
30-
3111
add_library(SWBAndroidPlatform
3212
AndroidSDK.swift
3313
Plugin.swift)
14+
SwiftBuild_Bundle(MODULE SWBAndroidPlatform FILES
15+
Specs/Android.xcspec)
3416
target_link_libraries(SWBAndroidPlatform PUBLIC
3517
SWBCore
3618
SWBMacro
3719
SWBUtil)
38-
target_sources(SWBAndroidPlatform PRIVATE
39-
"${CMAKE_CURRENT_BINARY_DIR}/resource_bundle_accessor.swift")
4020

4121
set_target_properties(SWBAndroidPlatform PROPERTIES
4222
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})

Sources/SWBApplePlatform/CMakeLists.txt

Lines changed: 71 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,6 @@ See http://swift.org/LICENSE.txt for license information
88
See http://swift.org/CONTRIBUTORS.txt for Swift project authors
99
]]
1010

11-
file(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}"
12-
_SWBApplePlatform_NATIVE_CMAKE_CURRENT_BINARY_DIR)
13-
file(CONFIGURE
14-
OUTPUT resource_bundle_accessor.swift
15-
CONTENT [[
16-
import Foundation
17-
extension Foundation.Bundle {
18-
static let module: Bundle = {
19-
let mainPath = Bundle.main.bundleURL.appendingPathComponent("SwiftBuild_SWBApplePlatform.resources").path
20-
let buildPath = #"@_SWBApplePlatform_NATIVE_CMAKE_CURRENT_BINARY_DIR@\SwiftBuild_SWBApplePlatform.resources"#
21-
let preferredBundle = Bundle(path: mainPath)
22-
guard let bundle = preferredBundle ?? Bundle(path: buildPath) else {
23-
Swift.fatalError("could not load resource bundle: from \(mainPath) or \(buildPath)")
24-
}
25-
return bundle
26-
}()
27-
}
28-
]]
29-
ESCAPE_QUOTES @ONLY NEWLINE_STYLE LF)
30-
3111
add_library(SWBApplePlatform
3212
AppIntentsMetadataCompiler.swift
3313
AppIntentsMetadataTaskProducer.swift
@@ -65,6 +45,77 @@ add_library(SWBApplePlatform
6545
StringCatalogCompilerOutputParser.swift
6646
StubBinaryTaskProducer.swift
6747
XCStringsInputFileGroupingStrategy.swift)
48+
SwiftBuild_Bundle(MODULE SWBApplePlatform FILES
49+
Specs/AppIntentsMetadata.xcspec
50+
Specs/AppIntentsNLTraining.xcspec
51+
Specs/AppShortcutStringsMetadata.xcspec
52+
Specs/AssetCatalogCompiler.xcspec
53+
Specs/CompileSkybox.xcspec
54+
Specs/CopyPNGFile.xcspec
55+
Specs/CopyTiffFile.xcspec
56+
"Specs/Core Data.xcspec"
57+
Specs/CoreML.xcspec
58+
"Specs/Darwin Package Types.xcspec"
59+
"Specs/Darwin Product Types.xcspec"
60+
Specs/DriverKit.xcspec
61+
Specs/DTrace.xcspec
62+
Specs/Embedded-Device.xcspec
63+
Specs/Embedded-Shared.xcspec
64+
Specs/Embedded-Simulator.xcspec
65+
Specs/EmbeddedBinaryValidationUtility.xcspec
66+
Specs/GenerateAppPlaygroundAssetCatalog.xcspec
67+
Specs/GenerateTextureAtlas.xcspec
68+
Specs/IBCompiler.xcspec
69+
Specs/IBPostprocessor.xcspec
70+
Specs/IBStoryboardCompiler.xcspec
71+
Specs/IBStoryboardLinker.xcspec
72+
Specs/IBStoryboardPostprocessor.xcspec
73+
Specs/Iconutil.xcspec
74+
Specs/Iig.xcspec
75+
Specs/InfoPlistUtility.xcspec
76+
Specs/InstrumentsPackage.xcspec
77+
Specs/Intents.xcspec
78+
"Specs/Interface Builder File Types.xcspec"
79+
"Specs/iOS Device.xcspec"
80+
"Specs/iOS Shared.xcspec"
81+
"Specs/iOS Simulator.xcspec"
82+
Specs/KernelExtension.xcspec
83+
Specs/Lipo.xcspec
84+
Specs/LSRegisterURL.xcspec
85+
"Specs/MacOSX Architectures.xcspec"
86+
"Specs/MacOSX Core Build System.xcspec"
87+
"Specs/MacOSX Native Build System.xcspec"
88+
"Specs/MacOSX Package Types.xcspec"
89+
"Specs/MacOSX Product Types.xcspec"
90+
Specs/MetalCompiler.xcspec
91+
Specs/MetalFileTypes.xcspec
92+
Specs/MetalLinker.xcspec
93+
Specs/MetalPackageTypes.xcspec
94+
Specs/MetalProductTypes.xcspec
95+
Specs/MiG.xcspec
96+
Specs/OpenCL.xcspec
97+
Specs/OSACompile.xcspec
98+
Specs/RCFileTypes.xcspec
99+
Specs/RealityAssets.xcspec
100+
Specs/ReferenceObject.xcspec
101+
Specs/ResMerger.xcspec
102+
Specs/Rez.xcspec
103+
"Specs/SceneKit FileTypes.xcspec"
104+
"Specs/SceneKit Tools.xcspec"
105+
Specs/SpriteKitFileTypes.xcspec
106+
Specs/TiffUtil.xcspec
107+
"Specs/tvOS Device.xcspec"
108+
"Specs/tvOS Shared.xcspec"
109+
"Specs/tvOS Simulator.xcspec"
110+
Specs/WatchKit1ProductTypes.xcspec
111+
"Specs/watchOS Device.xcspec"
112+
"Specs/watchOS Shared.xcspec"
113+
"Specs/watchOS Simulator.xcspec"
114+
Specs/XCAppExtensionPoints.xcspec
115+
Specs/XCStrings.xcspec
116+
"Specs/xrOS Device.xcspec"
117+
"Specs/xrOS Shared.xcspec"
118+
"Specs/xrOS Simulator.xcspec")
68119
set_target_properties(SWBApplePlatform PROPERTIES
69120
Swift_LANGUAGE_VERSION 6)
70121
target_link_libraries(SWBApplePlatform PUBLIC
@@ -73,8 +124,6 @@ target_link_libraries(SWBApplePlatform PUBLIC
73124
SWBUtil
74125
SWBProtocol
75126
SWBTaskConstruction)
76-
target_sources(SWBApplePlatform PRIVATE
77-
"${CMAKE_CURRENT_BINARY_DIR}/resource_bundle_accessor.swift")
78127

79128
set_target_properties(SWBApplePlatform PROPERTIES
80129
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})

Sources/SWBBuildSystem/BuildOperation.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,7 +1254,7 @@ private class InProcessCommand: SWBLLBuild.ExternalCommand, SWBLLBuild.ExternalD
12541254
// Get the current output delegate from the adaptor.
12551255
//
12561256
// FIXME: This should never fail (since we are executing), but we have seen a crash here with that assumption. For now we are defensive until the source can be tracked down: <rdar://problem/31670274> Diagnose unexpected missing output delegate from: <rdar://problem/31669245> Crash in InProcessCommand.execute()
1257-
guard let outputDelegate = adaptor.getActiveOutputDelegate(command) else {
1257+
guard let outputDelegate = await adaptor.getActiveOutputDelegate(command) else {
12581258
return .failed
12591259
}
12601260

@@ -1604,9 +1604,9 @@ internal final class OperationSystemAdaptor: SWBLLBuild.BuildSystemDelegate, Act
16041604
/// Get the active output delegate for an executing command.
16051605
///
16061606
/// - returns: The active delegate, or nil if not found.
1607-
func getActiveOutputDelegate(_ command: Command) -> (any TaskOutputDelegate)? {
1607+
func getActiveOutputDelegate(_ command: Command) async -> (any TaskOutputDelegate)? {
16081608
// FIXME: This is a very bad idea, doing a sync against the response queue is introducing artificial latency when an in-process command needs to wait for the response queue to flush. However, we also can't simply move to a decoupled lock, because we don't want the command to start reporting output before it has been fully reported as having started. We need to move in-process task to another model.
1609-
return queue.blocking_sync {
1609+
return await queue.sync {
16101610
self.commandOutputDelegates[command]
16111611
}
16121612
}

Sources/SWBCore/CMakeLists.txt

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,6 @@ See http://swift.org/LICENSE.txt for license information
88
See http://swift.org/CONTRIBUTORS.txt for Swift project authors
99
]]
1010

11-
file(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}"
12-
_SWBCore_NATIVE_CMAKE_CURRENT_BINARY_DIR)
13-
file(CONFIGURE
14-
OUTPUT resource_bundle_accessor.swift
15-
CONTENT [[
16-
import Foundation
17-
extension Foundation.Bundle {
18-
static let module: Bundle = {
19-
let mainPath = Bundle.main.bundleURL.appendingPathComponent("SwiftBuild_SWBCore.resources").path
20-
let buildPath = #"@_SWBCore_NATIVE_CMAKE_CURRENT_BINARY_DIR@\SwiftBuild_SWBCore.resources"#
21-
let preferredBundle = Bundle(path: mainPath)
22-
guard let bundle = preferredBundle ?? Bundle(path: buildPath) else {
23-
Swift.fatalError("could not load resource bundle: from \(mainPath) or \(buildPath)")
24-
}
25-
return bundle
26-
}()
27-
}
28-
]]
29-
ESCAPE_QUOTES @ONLY NEWLINE_STYLE LF)
30-
3111
add_library(SWBCore
3212
ActivityReporting.swift
3313
Apple/DeviceFamily.swift
@@ -195,6 +175,10 @@ add_library(SWBCore
195175
WorkspaceContext.swift
196176
WorkspaceSettingsCache.swift
197177
XCFramework.swift)
178+
SwiftBuild_Bundle(MODULE SWBCore FILES
179+
Specs/CoreBuildSystem.xcspec
180+
Specs/ExternalBuildSystem.xcspec
181+
Specs/NativeBuildSystem.xcspec)
198182
set_target_properties(SWBCore PROPERTIES
199183
Swift_LANGUAGE_VERSION 5)
200184
target_link_libraries(SWBCore PUBLIC
@@ -205,8 +189,6 @@ target_link_libraries(SWBCore PUBLIC
205189
SWBCAS
206190
SWBLLBuild
207191
SwiftDriver)
208-
target_sources(SWBCore PRIVATE
209-
"${CMAKE_CURRENT_BINARY_DIR}/resource_bundle_accessor.swift")
210192

211193
set_target_properties(SWBCore PROPERTIES
212194
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})

Sources/SWBCore/LibSwiftDriver/LibSwiftDriver.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,9 @@ public final class SwiftModuleDependencyGraph: SwiftGlobalExplicitDependencyGrap
238238
return fileDependencies
239239
}
240240

241-
public func queryTransitiveDependencyModuleNames(for key: String) throws -> [String] {
242-
let graph = try registryQueue.blocking_sync {
243-
guard let driver = registry[key] else {
241+
public func queryTransitiveDependencyModuleNames(for key: String) async throws -> [String] {
242+
let graph = try await registryQueue.sync {
243+
guard let driver = self.registry[key] else {
244244
throw StubError.error("Unable to find jobs for key \(key). Be sure to plan the build ahead of fetching results.")
245245
}
246246
return driver.intermoduleDependencyGraph

0 commit comments

Comments
 (0)