Skip to content

[SwiftCaching] Don't drop -Xcc during dependency scanning #1501

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

Merged
merged 1 commit into from
Dec 10, 2023
Merged
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
3 changes: 2 additions & 1 deletion Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,8 @@ extension Driver {
// Pass through any subsystem flags.
try commandLine.appendAll(.Xllvm, from: &parsedOptions)

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

Expand Down
9 changes: 9 additions & 0 deletions Tests/SwiftDriverTests/CachingBuildTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,10 @@ final class CachingBuildTests: XCTestCase {
try localFileSystem.writeFileContents(main) {
$0.send("import C;import E;import G;")
}
let vfsoverlay = path.appending(component: "overlay.yaml")
try localFileSystem.writeFileContents(vfsoverlay) {
$0.send("{\"case-sensitive\":\"false\",\"roots\":[],\"version\":0}")
}

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

// Xcc commands are used for scanner command.
XCTAssertTrue(scannerCommand.contains("-Xcc"))
XCTAssertTrue(scannerCommand.contains("-ivfsoverlay"))

// Here purely to dump diagnostic output in a reasonable fashion when things go wrong.
let lock = NSLock()

Expand Down