Skip to content

Commit e58e4bb

Browse files
authored
Merge pull request swiftlang#1414 from rjmansfield/default-pcm-pruning-toolchain-libclang
Default PCM pruning to the target's toolchain libclang
2 parents 2e8bb07 + 380c941 commit e58e4bb

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

Sources/SWBBuildSystem/BuildOperation.swift

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1666,9 +1666,16 @@ internal final class OperationSystemAdaptor: SWBLLBuild.BuildSystemDelegate, Act
16661666
if let value = TimeInterval(targetSettings.globalScope.evaluate(BuiltinMacros.CLANG_MODULES_PRUNE_INTERVAL)) {
16671667
pruneInterval = value
16681668
}
1669-
let path = targetSettings.globalScope.evaluate(BuiltinMacros.CLANG_EXPLICIT_MODULES_LIBCLANG_PATH)
1670-
if !path.isEmpty {
1671-
libclangPath = Path(path)
1669+
let configuredLibclangPath = targetSettings.globalScope.evaluate(BuiltinMacros.CLANG_EXPLICIT_MODULES_LIBCLANG_PATH)
1670+
if !configuredLibclangPath.isEmpty {
1671+
libclangPath = Path(configuredLibclangPath)
1672+
} else if libclangPath == nil {
1673+
for toolchain in targetSettings.toolchains {
1674+
if let path = toolchain.librarySearchPaths.findLibrary(operatingSystem: core.hostOperatingSystem, basename: "clang") {
1675+
libclangPath = path
1676+
break
1677+
}
1678+
}
16721679
}
16731680
}
16741681

Tests/SwiftBuildTests/BuildOperationTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -987,7 +987,7 @@ fileprivate struct BuildOperationTests: CoreBasedTests {
987987
try await tester.checkResults(events: events) { results in
988988
results.checkNote(.equal("Building targets in dependency order"))
989989
results.checkNoDiagnostics()
990-
results.consumeTasksMatchingRuleTypes(["ComputeTargetDependencyGraph", "GatherProvisioningInputs"])
990+
results.consumeTasksMatchingRuleTypes(["ComputeTargetDependencyGraph", "GatherProvisioningInputs", "PruneExplicitPrecompiledModules"])
991991
results.checkTasks(.matchRuleType("ClangStatCache")) { _ in }
992992
results.checkNoTask()
993993

@@ -1009,7 +1009,7 @@ fileprivate struct BuildOperationTests: CoreBasedTests {
10091009
let events = try await testSession.runBuildOperation(request: request, delegate: TestBuildOperationDelegate())
10101010

10111011
try await tester.checkResults(events: events) { results in
1012-
results.consumeTasksMatchingRuleTypes(["WriteAuxiliaryFile", "MkDir", "SymLink", "CreateBuildDirectory", "ClangStatCache"])
1012+
results.consumeTasksMatchingRuleTypes(["WriteAuxiliaryFile", "MkDir", "SymLink", "CreateBuildDirectory", "ClangStatCache", "PruneExplicitPrecompiledModules"])
10131013
results.checkTask(.matchRule(["ComputeTargetDependencyGraph"])) { task in
10141014
#expect(task.executionDescription == "Compute target dependency graph")
10151015
}
@@ -1033,7 +1033,7 @@ fileprivate struct BuildOperationTests: CoreBasedTests {
10331033
let events = try await testSession.runBuildOperation(request: request, delegate: TestBuildOperationDelegate())
10341034

10351035
try await tester.checkResults(events: events) { results in
1036-
results.consumeTasksMatchingRuleTypes(["ComputeTargetDependencyGraph", "GatherProvisioningInputs", "WriteAuxiliaryFile", "ClangStatCache", "ProcessInfoPlistFile", "CodeSign"])
1036+
results.consumeTasksMatchingRuleTypes(["ComputeTargetDependencyGraph", "GatherProvisioningInputs", "WriteAuxiliaryFile", "ClangStatCache", "ProcessInfoPlistFile", "CodeSign", "PruneExplicitPrecompiledModules"])
10371037
results.checkNoTask()
10381038

10391039
results.checkNote(.equal("Building targets in dependency order"))

0 commit comments

Comments
 (0)