Skip to content

Commit b09a52d

Browse files
authored
Merge pull request #64913 from artemcm/59AlwaysClangDepScanGModules
[5.9] Always specify `-gmodules` on built-in Clang invocations
2 parents 9d4a19d + a51ea60 commit b09a52d

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

lib/ClangImporter/ClangModuleDependencyScanner.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,8 @@ static void addSearchPathInvocationArguments(
7575
static std::vector<std::string> getClangDepScanningInvocationArguments(
7676
ASTContext &ctx,
7777
Optional<StringRef> sourceFileName = None) {
78-
std::vector<std::string> commandLineArgs;
79-
80-
// Form the basic command line.
81-
commandLineArgs.push_back("clang");
82-
importer::getNormalInvocationArguments(commandLineArgs, ctx);
83-
importer::addCommonInvocationArguments(commandLineArgs, ctx);
78+
std::vector<std::string> commandLineArgs =
79+
ClangImporter::getClangArguments(ctx);
8480
addSearchPathInvocationArguments(commandLineArgs, ctx);
8581

8682
auto sourceFilePos = std::find(
@@ -114,6 +110,10 @@ static std::vector<std::string> getClangDepScanningInvocationArguments(
114110
*syntaxOnlyPos = "-c";
115111
}
116112

113+
// The Clang modules produced by ClangImporter are always embedded in an
114+
// ObjectFilePCHContainer and contain -gmodules debug info.
115+
commandLineArgs.push_back("-gmodules");
116+
117117
return commandLineArgs;
118118
}
119119

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %empty-directory(%t/module-cache)
3+
// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t/module-cache %s -o %t/deps.json -I %S/Inputs/CHeaders -I %S/Inputs/Swift -target %target-cpu-apple-macosx10.14
4+
// RUN: %FileCheck %s < %t/deps.json
5+
6+
import X
7+
8+
// CHECK: "clang": "X"
9+
// CHECK: "clang": "X"
10+
// CHECK: "commandLine": [
11+
// CHECK-DAG: "-fmodule-format=obj"
12+
// CHECK-DAG: "-dwarf-ext-refs"

0 commit comments

Comments
 (0)