Skip to content

Commit 6189b0e

Browse files
committed
SwiftModuleBuildDescription: Fix diagnostic file paths for WMO builds
WMO builds have a single frontend invocation and produce a single diagnostic file named after the module.
1 parent b6a3d95 commit 6189b0e

File tree

2 files changed

+38
-6
lines changed

2 files changed

+38
-6
lines changed

Sources/Build/BuildDescription/SwiftModuleBuildDescription.swift

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,10 +1126,22 @@ extension SwiftModuleBuildDescription {
11261126

11271127
extension SwiftModuleBuildDescription {
11281128
package var diagnosticFiles: [AbsolutePath] {
1129-
self.sources.compactMap { self.diagnosticFile(sourceFile: $0) }
1129+
// WMO builds have a single frontend invocation and produce a single
1130+
// diagnostic file named after the module.
1131+
if self.useWholeModuleOptimization {
1132+
return [
1133+
self.diagnosticFile(name: self.target.name)
1134+
]
1135+
}
1136+
1137+
return self.sources.map(self.diagnosticFile(sourceFile:))
1138+
}
1139+
1140+
private func diagnosticFile(name: String) -> AbsolutePath {
1141+
self.tempsPath.appending(component: "\(name).dia")
11301142
}
11311143

11321144
private func diagnosticFile(sourceFile: AbsolutePath) -> AbsolutePath {
1133-
self.tempsPath.appending(component: "\(sourceFile.basenameWithoutExt).dia")
1145+
self.diagnosticFile(name: sourceFile.basenameWithoutExt)
11341146
}
11351147
}

Tests/CommandsTests/PackageCommandTests.swift

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2168,7 +2168,7 @@ class PackageCommandTestCase: CommandsBuildProviderTestCase {
21682168
}
21692169
}
21702170

2171-
func testMigrateCommand() async throws {
2171+
func _testMigrateCommand(configuration: BuildConfiguration) async throws {
21722172
try XCTSkipIf(
21732173
!UserToolchain.default.supportesSupportedFeatures,
21742174
"skipping because test environment compiler doesn't support `-print-supported-features`"
@@ -2196,7 +2196,7 @@ class PackageCommandTestCase: CommandsBuildProviderTestCase {
21962196
}
21972197

21982198
let (stdout, _) = try await self.execute(
2199-
["migrate", "--to-feature", featureName],
2199+
["migrate", "-c", configuration.rawValue, "--to-feature", featureName],
22002200
packagePath: fixturePath
22012201
)
22022202

@@ -2220,6 +2220,14 @@ class PackageCommandTestCase: CommandsBuildProviderTestCase {
22202220
try await doMigration(featureName: "InferIsolatedConformances", expectedSummary: "Applied 3 fix-its in 2 files")
22212221
}
22222222

2223+
func testMigrateCommandDebug() async throws {
2224+
try await _testMigrateCommand(configuration: .debug)
2225+
}
2226+
2227+
func testMigrateCommandRelease() async throws {
2228+
try await _testMigrateCommand(configuration: .release)
2229+
}
2230+
22232231
func testMigrateCommandWithBuildToolPlugins() async throws {
22242232
try XCTSkipIf(
22252233
!UserToolchain.default.supportesSupportedFeatures,
@@ -4432,7 +4440,19 @@ class PackageCommandSwiftBuildTests: PackageCommandTestCase {
44324440
try await super.testNoParameters()
44334441
}
44344442

4435-
override func testMigrateCommand() async throws {
4443+
override func testMigrateCommandDebug() async throws {
4444+
try XCTSkipOnWindows(
4445+
because: """
4446+
Possibly https://github.com/swiftlang/swift-package-manager/issues/8602:
4447+
error: Could not choose a single platform for target 'AllIncludingTests' from the supported platforms 'android qnx webassembly'. Specialization parameters imposed by workspace: platform 'nil' sdkVariant 'nil' supportedPlatforms: 'nil' toolchain: 'nil'
4448+
""",
4449+
skipPlatformCi: true,
4450+
)
4451+
4452+
try await super.testMigrateCommandDebug()
4453+
}
4454+
4455+
override func testMigrateCommandRelease() async throws {
44364456
try XCTSkipOnWindows(
44374457
because: """
44384458
Possibly https://github.com/swiftlang/swift-package-manager/issues/8602:
@@ -4441,7 +4461,7 @@ class PackageCommandSwiftBuildTests: PackageCommandTestCase {
44414461
skipPlatformCi: true,
44424462
)
44434463

4444-
try await super.testMigrateCommand()
4464+
try await super.testMigrateCommandRelease()
44454465
}
44464466

44474467
override func testMigrateCommandUpdateManifest2Targets() async throws {

0 commit comments

Comments
 (0)