Skip to content

SwiftModuleBuildDescription: Fix diagnostic file paths for WMO builds #9020

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -1126,10 +1126,22 @@ extension SwiftModuleBuildDescription {

extension SwiftModuleBuildDescription {
package var diagnosticFiles: [AbsolutePath] {
self.sources.compactMap { self.diagnosticFile(sourceFile: $0) }
// WMO builds have a single frontend invocation and produce a single
// diagnostic file named after the module.
if self.useWholeModuleOptimization {
return [
self.diagnosticFile(name: self.target.name)
]
}

return self.sources.map(self.diagnosticFile(sourceFile:))
}

private func diagnosticFile(name: String) -> AbsolutePath {
self.tempsPath.appending(component: "\(name).dia")
}

private func diagnosticFile(sourceFile: AbsolutePath) -> AbsolutePath {
self.tempsPath.appending(component: "\(sourceFile.basenameWithoutExt).dia")
self.diagnosticFile(name: sourceFile.basenameWithoutExt)
}
}
28 changes: 24 additions & 4 deletions Tests/CommandsTests/PackageCommandTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2168,7 +2168,7 @@ class PackageCommandTestCase: CommandsBuildProviderTestCase {
}
}

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

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

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

func testMigrateCommandDebug() async throws {
try await _testMigrateCommand(configuration: .debug)
}

func testMigrateCommandRelease() async throws {
try await _testMigrateCommand(configuration: .release)
}

func testMigrateCommandWithBuildToolPlugins() async throws {
try XCTSkipIf(
!UserToolchain.default.supportesSupportedFeatures,
Expand Down Expand Up @@ -4432,7 +4440,19 @@ class PackageCommandSwiftBuildTests: PackageCommandTestCase {
try await super.testNoParameters()
}

override func testMigrateCommand() async throws {
override func testMigrateCommandDebug() async throws {
try XCTSkipOnWindows(
because: """
Possibly https://github.com/swiftlang/swift-package-manager/issues/8602:
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'
""",
skipPlatformCi: true,
)

try await super.testMigrateCommandDebug()
}

override func testMigrateCommandRelease() async throws {
try XCTSkipOnWindows(
because: """
Possibly https://github.com/swiftlang/swift-package-manager/issues/8602:
Expand All @@ -4441,7 +4461,7 @@ class PackageCommandSwiftBuildTests: PackageCommandTestCase {
skipPlatformCi: true,
)

try await super.testMigrateCommand()
try await super.testMigrateCommandRelease()
}

override func testMigrateCommandUpdateManifest2Targets() async throws {
Expand Down