Skip to content

Commit 08b92a9

Browse files
Remove MCCAS options in Scanner if not emitting Obj
Remove the MCCAS options in the dependency scanner if the FrontendAction is not EmitObj. MCCAS should only be turned on when the compiler is emitting an object file.
1 parent 2cf0120 commit 08b92a9

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

clang/lib/Tooling/DependencyScanning/ScanAndUpdateArgs.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,19 @@ void tooling::dependencies::configureInvocationForCaching(
2626
auto &FrontendOpts = CI.getFrontendOpts();
2727
FrontendOpts.CacheCompileJob = true;
2828
FrontendOpts.IncludeTimestamps = false;
29+
2930
// Clear this otherwise it defeats the purpose of making the compilation key
3031
// independent of certain arguments.
31-
CI.getCodeGenOpts().DwarfDebugFlags.clear();
32+
auto &CodeGenOpts = CI.getCodeGenOpts();
33+
if (CI.getFrontendOpts().ProgramAction != frontend::ActionKind::EmitObj) {
34+
CodeGenOpts.UseCASBackend = false;
35+
CodeGenOpts.EmitCASIDFile = false;
36+
auto &LLVMArgs = FrontendOpts.LLVMArgs;
37+
llvm::erase(LLVMArgs, "-cas-friendly-debug-info");
38+
}
39+
CodeGenOpts.DwarfDebugFlags.clear();
3240
resetBenignCodeGenOptions(FrontendOpts.ProgramAction, CI.getLangOpts(),
33-
CI.getCodeGenOpts());
41+
CodeGenOpts);
3442

3543
HeaderSearchOptions &HSOpts = CI.getHeaderSearchOpts();
3644
// Avoid writing potentially volatile diagnostic options into pcms.
@@ -78,7 +86,7 @@ void tooling::dependencies::configureInvocationForCaching(
7886
// Disable `-gmodules` to avoid debug info referencing a non-existent PCH
7987
// filename.
8088
// FIXME: we should also allow -gmodules if there is no PCH involved.
81-
CI.getCodeGenOpts().DebugTypeExtRefs = false;
89+
CodeGenOpts.DebugTypeExtRefs = false;
8290
HSOpts.ModuleFormat = "raw";
8391
}
8492
// Clear APINotes options.

clang/test/CAS/depscan-update-mccas.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// RUN: %clang -cc1depscan -o - -cc1-args -cc1 -triple \
2+
// RUN: x86_64-apple-darwin10 -debug-info-kind=standalone -dwarf-version=4 \
3+
// RUN: -debugger-tuning=lldb -emit-obj -fcas-backend -fcas-path %t/cas \
4+
// RUN: -fcas-emit-casid-file -mllvm -cas-friendly-debug-info %s | FileCheck %s --check-prefix=MCCAS_ON
5+
6+
// MCCAS_ON: -mllvm
7+
// MCCAS_ON: -cas-friendly-debug-info
8+
// MCCAS_ON: -fcas-backend
9+
// MCCAS_ON: -fcas-emit-casid-file
10+
11+
// RUN: %clang -cc1depscan -o - -cc1-args -cc1 -triple \
12+
// RUN: x86_64-apple-darwin10 -debug-info-kind=standalone -dwarf-version=4 \
13+
// RUN: -debugger-tuning=lldb -emit-llvm -fcas-backend -fcas-path %t/cas \
14+
// RUN: -fcas-emit-casid-file -mllvm -cas-friendly-debug-info %s | FileCheck %s --check-prefix=MCCAS_OFF
15+
16+
// MCCAS_OFF-NOT: -mllvm
17+
// MCCAS_OFF-NOT: -cas-friendly-debug-info
18+
// MCCAS_OFF-NOT: -fcas-backend
19+
// MCCAS_OFF-NOT: -fcas-emit-casid-file
20+
21+
22+
int foo(int x) {
23+
return x+1;
24+
}

0 commit comments

Comments
 (0)