Skip to content

Commit 060b253

Browse files
committed
[clang][deps] Remove more codegen options
Codegen options are typically unused by modules. Reset some of them to increase sharing between TUs with different flags. Reviewed By: Bigcheese Differential Revision: https://reviews.llvm.org/D135720
1 parent adf36ea commit 060b253

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,15 @@ ModuleDepCollector::makeInvocationForModuleBuildWithoutOutputs(
9797
// units.
9898
CI.getFrontendOpts().Inputs.clear();
9999
CI.getFrontendOpts().OutputFile.clear();
100+
101+
// TODO: Figure out better way to set options to their default value.
100102
CI.getCodeGenOpts().MainFileName.clear();
101103
CI.getCodeGenOpts().DwarfDebugFlags.clear();
104+
if (!CI.getLangOpts()->ModulesCodegen) {
105+
CI.getCodeGenOpts().DebugCompilationDir.clear();
106+
CI.getCodeGenOpts().CoverageCompilationDir.clear();
107+
}
108+
102109
// Map output paths that affect behaviour to "-" so their existence is in the
103110
// context hash. The final path will be computed in addOutputPaths.
104111
if (!CI.getDiagnosticOpts().DiagnosticSerializationFile.empty())
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[
22
{
33
"directory": "DIR",
4-
"command": "clang -fsyntax-only DIR/tu.c -fmodules -fimplicit-module-maps -fmodules-validate-once-per-build-session -fbuild-session-file=DIR/build-session -fmodules-prune-interval=123 -fmodules-prune-after=123 -fmodules-cache-path=DIR/cache -include DIR/header.h -grecord-command-line -o DIR/tu.o -serialize-diagnostics DIR/tu.diag -MT tu -MD -MF DIR/tu.d",
4+
"command": "clang -fsyntax-only DIR/tu.c -fmodules -fimplicit-module-maps -fmodules-validate-once-per-build-session -fbuild-session-file=DIR/build-session -fmodules-prune-interval=123 -fmodules-prune-after=123 -fmodules-cache-path=DIR/cache -include DIR/header.h -grecord-command-line -fdebug-compilation-dir=DIR/debug -fcoverage-compilation-dir=DIR/coverage -o DIR/tu.o -serialize-diagnostics DIR/tu.diag -MT tu -MD -MF DIR/tu.d",
55
"file": "DIR/tu.c"
66
}
77
]

clang/test/ClangScanDeps/removed-args.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
// CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
2222
// CHECK-NEXT: "command-line": [
2323
// CHECK-NEXT: "-cc1"
24+
// CHECK-NOT: "-fdebug-compilation-dir="
25+
// CHECK-NOT: "-fcoverage-compilation-dir="
2426
// CHECK-NOT: "-dwarf-debug-flags"
2527
// CHECK-NOT: "-main-file-name"
2628
// CHECK-NOT: "-include"
@@ -42,6 +44,8 @@
4244
// CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
4345
// CHECK-NEXT: "command-line": [
4446
// CHECK-NEXT: "-cc1"
47+
// CHECK-NOT: "-fdebug-compilation-dir=
48+
// CHECK-NOT: "-fcoverage-compilation-dir=
4549
// CHECK-NOT: "-dwarf-debug-flags"
4650
// CHECK-NOT: "-main-file-name"
4751
// CHECK-NOT: "-include"

0 commit comments

Comments
 (0)