Skip to content

Commit a17d5ee

Browse files
committed
[Dependency Scanning] Emit path to clang from PCM build command-line
It gets interpreted as just an executable we feed to the linker, since we launch `emit-pcm` actions via `swift-frontend` invocations, not `clang`.
1 parent 14eefd1 commit a17d5ee

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

lib/ClangImporter/ClangModuleDependencyScanner.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,13 @@ void ClangImporter::recordModuleDependencies(
242242
// from the depending Swift modules.
243243
if (arg == "-target") {
244244
It += 2;
245+
} else if (arg == "clang" ||
246+
arg.endswith(llvm::sys::path::get_separator().str() + "clang")) {
247+
// Remove the initial path to clang executable argument, to avoid
248+
// treating it as an executable input to compilation. It is not needed
249+
// because the consumer of this command-line will invoke the emit-PCM
250+
// action via swift-frontend.
251+
It += 1;
245252
} else if (arg.startswith("-fapinotes-swift-version=")) {
246253
// Remove the apinotes version because we should use the language version
247254
// specified in the interface file.

test/ScanDependencies/module_deps.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,7 @@ import SubE
126126
// CHECK: "commandLine": [
127127
// CHECK-NEXT: "-frontend"
128128
// CHECK-NEXT: "-only-use-extra-clang-opts"
129-
// CHECK-NEXT: "-Xcc"
130-
// CHECK-NEXT: "BUILD_DIR/bin/clang"
129+
// CHECK-NOT: "BUILD_DIR/bin/clang"
131130
// CHECK: "-fsystem-module",
132131
// CHECK-NEXT: "-emit-pcm",
133132
// CHECK-NEXT: "-module-name",

test/ScanDependencies/module_deps_cache_reuse.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,8 @@ import SubE
109109

110110
// CHECK: "commandLine": [
111111
// CHECK-NEXT: "-frontend"
112-
// CHECK-NEXT: "-only-use-extra-clang-opts"
113-
// CHECK-NEXT: "-Xcc"
114-
// CHECK-NEXT: "BUILD_DIR/bin/clang"
112+
// CHECK-NEXT: "-only-use-extra-clang-opts
113+
// CHECK-NOT: "BUILD_DIR/bin/clang"
115114
// CHECK-NEXT: "-Xcc"
116115
// CHECK-NEXT: "-fsyntax-only",
117116
// CHECK: "-fsystem-module",

0 commit comments

Comments
 (0)