Skip to content

Commit 0c846ef

Browse files
Merge pull request #1501 from cachemeifyoucan/eng/PR-119391228
[SwiftCaching] Don't drop `-Xcc` during dependency scanning
2 parents 0afa340 + 99f1c1b commit 0c846ef

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,8 @@ extension Driver {
387387
// Pass through any subsystem flags.
388388
try commandLine.appendAll(.Xllvm, from: &parsedOptions)
389389

390-
if !(isCachingEnabled && useClangIncludeTree) {
390+
// If using clang-include-tree, `-Xcc` should only be passed to scanDependencies job.
391+
if (kind == .scanDependencies) || !(isCachingEnabled && useClangIncludeTree) {
391392
try commandLine.appendAll(.Xcc, from: &parsedOptions)
392393
}
393394

Tests/SwiftDriverTests/CachingBuildTests.swift

+9
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,10 @@ final class CachingBuildTests: XCTestCase {
599599
try localFileSystem.writeFileContents(main) {
600600
$0.send("import C;import E;import G;")
601601
}
602+
let vfsoverlay = path.appending(component: "overlay.yaml")
603+
try localFileSystem.writeFileContents(vfsoverlay) {
604+
$0.send("{\"case-sensitive\":\"false\",\"roots\":[],\"version\":0}")
605+
}
602606

603607
let cHeadersPath: AbsolutePath =
604608
try testInputsPath.appending(component: "ExplicitModuleBuilds")
@@ -615,6 +619,7 @@ final class CachingBuildTests: XCTestCase {
615619
"-explicit-module-build",
616620
"-cache-compile-job", "-cas-path", casPath.nativePathString(escaped: true),
617621
"-working-directory", path.nativePathString(escaped: true),
622+
"-Xcc", "-ivfsoverlay", "-Xcc", vfsoverlay.nativePathString(escaped: true),
618623
"-disable-clang-target",
619624
main.nativePathString(escaped: true)] + sdkArgumentsForTesting,
620625
env: ProcessEnv.vars)
@@ -642,6 +647,10 @@ final class CachingBuildTests: XCTestCase {
642647
XCTAssertFalse(scannerCommand.contains("-pch-output-dir"))
643648
XCTAssertFalse(scannerCommand.contains("Foo.o"))
644649

650+
// Xcc commands are used for scanner command.
651+
XCTAssertTrue(scannerCommand.contains("-Xcc"))
652+
XCTAssertTrue(scannerCommand.contains("-ivfsoverlay"))
653+
645654
// Here purely to dump diagnostic output in a reasonable fashion when things go wrong.
646655
let lock = NSLock()
647656

0 commit comments

Comments
 (0)