Skip to content

Commit 72550ae

Browse files
authored
Merge pull request swiftlang#1418 from owenv/owenv/update-main-2
Merge release/6.4.x into main
2 parents e58e4bb + 4c2516c commit 72550ae

8 files changed

Lines changed: 97 additions & 29 deletions

File tree

Sources/SWBBuildService/BuildService.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ private struct CoreCacheKey: Equatable, Hashable {
3737
/// The path of the developer directory.
3838
let developerPath: SWBProtocol.DeveloperPath?
3939

40+
/// Additional search paths for resource bundles.
41+
let resourceSearchPaths: [Path]
42+
4043
/// The inferior build products path, if defined.
4144
let inferiorProducts: Path?
4245

@@ -150,7 +153,7 @@ open class BuildService: Service, @unchecked Sendable {
150153
///
151154
/// We use an explicit cache so that we can minimize the number of cores we load while still keeping a flexible public interface that doesn't require all clients to provide all possible required parameters for core initialization (which is useful for testing and debug purposes).
152155
func sharedCore(developerPath: SWBProtocol.DeveloperPath?, resourceSearchPaths: [Path] = [], inferiorProducts: Path? = nil, environment: [String: String] = [:]) async -> (Core?, [Diagnostic]) {
153-
let key = CoreCacheKey(developerPath: developerPath, inferiorProducts: inferiorProducts, environment: environment)
156+
let key = CoreCacheKey(developerPath: developerPath, resourceSearchPaths: resourceSearchPaths, inferiorProducts: inferiorProducts, environment: environment)
154157
do {
155158
return try await sharedCoreCache.value(forKey: key) {
156159
let buildServiceModTime: Date

Sources/SWBCore/Settings/Settings.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ public final class Settings: PlatformBuildContext, Sendable {
742742
supportsMacCatalystMacros.formUnion(sdkVariantInfoExtension.supportsMacCatalystMacroNames)
743743
}
744744

745-
return supportsMacCatalystMacros.contains { scope.evaluate(scope.namespace.parseString("$(\($0)")).boolValue } ||
745+
return supportsMacCatalystMacros.contains { scope.evaluate(scope.namespace.parseString("$(\($0))")).boolValue } ||
746746
// For index build ensure zippered frameworks can be configured separately for both macOS and macCatalyst.
747747
(scope.evaluate(BuiltinMacros.IS_ZIPPERED) && scope.evaluate(BuiltinMacros.INDEX_ENABLE_BUILD_ARENA))
748748
}
@@ -2928,7 +2928,7 @@ private class SettingsBuilder: ProjectMatchLookup {
29282928
for sdkVariantInfoExtension in core.pluginManager.extensions(of: SDKVariantInfoExtensionPoint.self) {
29292929
macCatalystDeriveBundleIDMacros.formUnion(sdkVariantInfoExtension.macCatalystDeriveBundleIDMacroNames)
29302930
}
2931-
let wantsDerivedMacCatalystBundleId = macCatalystDeriveBundleIDMacros.contains { scope.evaluate(scope.namespace.parseString("$(\($0)")).boolValue }
2931+
let wantsDerivedMacCatalystBundleId = macCatalystDeriveBundleIDMacros.contains { scope.evaluate(scope.namespace.parseString("$(\($0))")).boolValue }
29322932
if let sdkVariant, sdkVariant.isMacCatalyst {
29332933
if wantsDerivedMacCatalystBundleId {
29342934
pushTable(.exported) { table in
@@ -3077,7 +3077,7 @@ private class SettingsBuilder: ProjectMatchLookup {
30773077
}
30783078

30793079
for macro in disallowedMacCatalystMacros {
3080-
if scope.evaluate(scope.namespace.parseString("$(\(macro)")).boolValue {
3080+
if scope.evaluate(scope.namespace.parseString("$(\(macro))")).boolValue {
30813081
let message = "`\(macro)` is not supported. Remove the build setting and conditionalize `PRODUCT_BUNDLE_IDENTIFIER` instead."
30823082
if scope.evaluate(BuiltinMacros.__DIAGNOSE_DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER_ERROR) {
30833083
self.errors.append(message)

Sources/SWBCore/SpecImplementations/Tools/PrelinkedObjectLink.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public final class PrelinkedObjectLinkSpec: CommandLineToolSpec, SpecImplementat
3838
if let sdk = cbc.producer.sdk, let sdkVersion = sdk.version {
3939
for buildPlatform in cbc.producer.targetBuildVersionPlatforms(in: cbc.scope)?.sorted() ?? [] {
4040
let deploymentTargetSettingName = buildPlatform.deploymentTargetSettingName(infoLookup: cbc.producer)
41-
if let minDeploymentTarget = cbc.scope.evaluate(cbc.scope.namespace.parseString("$(\(deploymentTargetSettingName)")).nilIfEmpty {
41+
if let minDeploymentTarget = cbc.scope.evaluate(cbc.scope.namespace.parseString("$(\(deploymentTargetSettingName))")).nilIfEmpty {
4242
let version: Version
4343
if cbc.scope.evaluate(BuiltinMacros.IS_ZIPPERED) && buildPlatform == .macCatalyst {
4444
guard let correspondingVersion = sdk.versionMap["macOS_iOSMac"]?[sdkVersion] else {

Sources/SWBTaskConstruction/TaskProducers/OtherTaskProducers/ProductPostprocessingTaskProducer.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,11 @@ package final class ProductPostprocessingTaskProducer: PhasedTaskProducer, TaskP
241241
let phaseEndTask = self.phaseEndTask
242242

243243
context.addDeferredProducer {
244+
// Skip stripping for object libraries (.objlib), which are directories containing object files, not single binaries
245+
if scope.evaluate(BuiltinMacros.MACH_O_TYPE) == "objectlib" {
246+
return []
247+
}
248+
244249
guard let inputPath = self.context.producedBinary(forVariant: scope.evaluate(BuiltinMacros.CURRENT_VARIANT)) else { return [] }
245250

246251
let input = FileToBuild(context: self.context, absolutePath: inputPath)

Sources/SWBTestSupport/RunDestinationTestSupport.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ extension _RunDestinationInfo {
251251
guard let arch = Architecture.hostStringValue else {
252252
preconditionFailure("Unknown architecture \(Architecture.host.stringValue ?? "<nil>")")
253253
}
254-
return .init(platform: "windows", sdk: "windows", sdkVariant: "windows", targetArchitecture: arch, supportedArchitectures: ["x86_64, aarch64"], disableOnlyActiveArch: false)
254+
return .init(platform: "windows", sdk: "windows", sdkVariant: "windows", targetArchitecture: arch, supportedArchitectures: ["x86_64", "aarch64"], disableOnlyActiveArch: false)
255255
}
256256

257257
/// A run destination targeting Linux generic device, using the public SDK.

Sources/SWBUniversalPlatform/Specs/Clang.xcspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4133,7 +4133,7 @@
41334133
);
41344134
NO = ();
41354135
};
4136-
// Category is hidden.
4136+
Category = SASecurityCheckers;
41374137
},
41384138
// Sanitizers should not be enabled while using the static analyzer.
41394139
{

Sources/SWBUniversalPlatform/Specs/Ld.xcspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@
276276
"-no_warn_duplicate_libraries",
277277
);
278278
};
279+
SupportedVersionRanges = ( "1015.3" );
279280
},
280281
{
281282
Name = "LIBRARY_SEARCH_PATHS";

Tests/SWBTaskConstructionTests/ObjectLibraryTaskConstructionTests.swift

Lines changed: 81 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,25 @@ fileprivate struct ObjectLibraryTaskConstructionTests: CoreBasedTests {
3030
TestFile("b.c"),
3131
]),
3232
buildConfigurations: [
33-
TestBuildConfiguration("Debug", buildSettings: [
34-
"PRODUCT_NAME": "$(TARGET_NAME)",
35-
"SWIFT_EXEC": try await swiftCompilerPath.str,
36-
"SWIFT_VERSION": try await swiftVersion
37-
]),
33+
TestBuildConfiguration(
34+
"Debug",
35+
buildSettings: [
36+
"PRODUCT_NAME": "$(TARGET_NAME)",
37+
"SWIFT_EXEC": try await swiftCompilerPath.str,
38+
"SWIFT_VERSION": try await swiftVersion,
39+
])
3840
],
3941
targets: [
4042
TestStandardTarget(
4143
"Library",
4244
type: .objectLibrary,
4345
buildConfigurations: [
44-
TestBuildConfiguration("Debug", buildSettings: [:]),
46+
TestBuildConfiguration("Debug", buildSettings: [:])
4547
],
4648
buildPhases: [
47-
TestSourcesBuildPhase(["a.c", "b.c"]),
49+
TestSourcesBuildPhase(["a.c", "b.c"])
4850
]
49-
),
51+
)
5052
])
5153
let core = try await getCore()
5254
let tester = try TaskConstructionTester(core, testProject)
@@ -61,7 +63,7 @@ fileprivate struct ObjectLibraryTaskConstructionTests: CoreBasedTests {
6163
.suffix("a.o"),
6264
.suffix("b.o"),
6365
"--output",
64-
.suffix("Library.objlib")
66+
.suffix("Library.objlib"),
6567
])
6668
task.checkInputs([
6769
.pathPattern(.suffix("a.o")),
@@ -76,6 +78,63 @@ fileprivate struct ObjectLibraryTaskConstructionTests: CoreBasedTests {
7678
}
7779
}
7880

81+
@Test(
82+
.requireSDKs(.host),
83+
arguments: [
84+
true,
85+
false,
86+
],
87+
)
88+
func objectLibraryDoesNotProductStipTaskWhenBinaryStripInstalledProductSetOrUnset(
89+
isStrippingEnabled: Bool,
90+
) async throws {
91+
let buildConfiguration = "Debug"
92+
let testProject = TestProject(
93+
"aProject",
94+
groupTree: TestGroup(
95+
"SomeFiles",
96+
children: [
97+
TestFile("a.c"),
98+
TestFile("b.c"),
99+
],
100+
),
101+
buildConfigurations: [
102+
TestBuildConfiguration(
103+
buildConfiguration,
104+
buildSettings: [
105+
"PRODUCT_NAME": "$(TARGET_NAME)",
106+
"SWIFT_EXEC": try await swiftCompilerPath.str,
107+
"SWIFT_VERSION": try await swiftVersion,
108+
"DEPLOYMENT_POSTPROCESSING": "YES",
109+
"STRIP_INSTALLED_PRODUCT": (isStrippingEnabled ? "YES" : "NO"),
110+
],
111+
),
112+
],
113+
targets: [
114+
TestStandardTarget(
115+
"Library",
116+
type: .objectLibrary,
117+
buildConfigurations: [
118+
TestBuildConfiguration(buildConfiguration, buildSettings: [:]),
119+
],
120+
buildPhases: [
121+
TestSourcesBuildPhase(["a.c", "b.c"]),
122+
],
123+
),
124+
],
125+
)
126+
let core = try await getCore()
127+
let tester: TaskConstructionTester = try TaskConstructionTester(core, testProject)
128+
129+
await tester.checkBuild(
130+
BuildParameters(configuration: buildConfiguration, overrides: [:]),
131+
runDestination: .host
132+
) { results in
133+
results.checkNoDiagnostics()
134+
results.checkNoTask(.matchRuleType("Strip"))
135+
}
136+
}
137+
79138
@Test(.requireSDKs(.host))
80139
func objectLibraryConsumer() async throws {
81140
let testWorkspace = TestWorkspace(
@@ -96,32 +155,32 @@ fileprivate struct ObjectLibraryTaskConstructionTests: CoreBasedTests {
96155
"CODE_SIGNING_ALLOWED": "NO",
97156
"PRODUCT_NAME": "$(TARGET_NAME)",
98157
"SWIFT_VERSION": try await swiftVersion,
99-
"SWIFT_EXEC": try await swiftCompilerPath.str
100-
]),
158+
"SWIFT_EXEC": try await swiftCompilerPath.str,
159+
])
101160
],
102161
targets: [
103162
TestStandardTarget(
104163
"Tool",
105164
type: .commandLineTool,
106165
buildPhases: [
107166
TestSourcesBuildPhase([
108-
"b.swift",
167+
"b.swift"
109168
]),
110169
TestFrameworksBuildPhase([
111170
"Library.objlib"
112-
])
171+
]),
113172
],
114173
dependencies: [
115-
"Library",
174+
"Library"
116175
]
117176
),
118177
TestStandardTarget(
119178
"Library",
120179
type: .objectLibrary,
121180
buildPhases: [
122181
TestSourcesBuildPhase([
123-
"a.swift",
124-
]),
182+
"a.swift"
183+
])
125184
]
126185
),
127186
])
@@ -148,7 +207,7 @@ fileprivate struct ObjectLibraryTaskConstructionTests: CoreBasedTests {
148207
groupTree: TestGroup(
149208
"Sources",
150209
children: [
151-
TestFile("a.swift"),
210+
TestFile("a.swift")
152211
]),
153212
buildConfigurations: [
154213
TestBuildConfiguration(
@@ -157,8 +216,8 @@ fileprivate struct ObjectLibraryTaskConstructionTests: CoreBasedTests {
157216
"CODE_SIGNING_ALLOWED": "NO",
158217
"PRODUCT_NAME": "$(TARGET_NAME)",
159218
"SWIFT_VERSION": try await swiftVersion,
160-
"SWIFT_EXEC": try await swiftCompilerPath.str
161-
]),
219+
"SWIFT_EXEC": try await swiftCompilerPath.str,
220+
])
162221
],
163222
targets: [
164223
TestStandardTarget(
@@ -174,16 +233,16 @@ fileprivate struct ObjectLibraryTaskConstructionTests: CoreBasedTests {
174233
TestSourcesBuildPhase([]),
175234
],
176235
dependencies: [
177-
"Library",
236+
"Library"
178237
]
179238
),
180239
TestStandardTarget(
181240
"Library",
182241
type: .objectLibrary,
183242
buildPhases: [
184243
TestSourcesBuildPhase([
185-
"a.swift",
186-
]),
244+
"a.swift"
245+
])
187246
]
188247
),
189248
])

0 commit comments

Comments
 (0)