Skip to content

Remove MCCAS options in Scanner if not emitting Obj #8666

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
May 1, 2024
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
14 changes: 11 additions & 3 deletions clang/lib/Tooling/DependencyScanning/ScanAndUpdateArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,19 @@ void tooling::dependencies::configureInvocationForCaching(
auto &FrontendOpts = CI.getFrontendOpts();
FrontendOpts.CacheCompileJob = true;
FrontendOpts.IncludeTimestamps = false;

// Clear this otherwise it defeats the purpose of making the compilation key
// independent of certain arguments.
CI.getCodeGenOpts().DwarfDebugFlags.clear();
auto &CodeGenOpts = CI.getCodeGenOpts();
if (CI.getFrontendOpts().ProgramAction != frontend::ActionKind::EmitObj) {
CodeGenOpts.UseCASBackend = false;
CodeGenOpts.EmitCASIDFile = false;
auto &LLVMArgs = FrontendOpts.LLVMArgs;
llvm::erase(LLVMArgs, "-cas-friendly-debug-info");
}
CodeGenOpts.DwarfDebugFlags.clear();
resetBenignCodeGenOptions(FrontendOpts.ProgramAction, CI.getLangOpts(),
CI.getCodeGenOpts());
CodeGenOpts);

HeaderSearchOptions &HSOpts = CI.getHeaderSearchOpts();
// Avoid writing potentially volatile diagnostic options into pcms.
Expand Down Expand Up @@ -78,7 +86,7 @@ void tooling::dependencies::configureInvocationForCaching(
// Disable `-gmodules` to avoid debug info referencing a non-existent PCH
// filename.
// FIXME: we should also allow -gmodules if there is no PCH involved.
CI.getCodeGenOpts().DebugTypeExtRefs = false;
CodeGenOpts.DebugTypeExtRefs = false;
HSOpts.ModuleFormat = "raw";
}
// Clear APINotes options.
Expand Down
24 changes: 24 additions & 0 deletions clang/test/CAS/depscan-update-mccas.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// RUN: %clang -cc1depscan -o - -cc1-args -cc1 -triple \
// RUN: x86_64-apple-darwin10 -debug-info-kind=standalone -dwarf-version=4 \
// RUN: -debugger-tuning=lldb -emit-obj -fcas-backend -fcas-path %t/cas \
// RUN: -fcas-emit-casid-file -mllvm -cas-friendly-debug-info %s | FileCheck %s --check-prefix=MCCAS_ON

// MCCAS_ON: -mllvm
// MCCAS_ON: -cas-friendly-debug-info
// MCCAS_ON: -fcas-backend
// MCCAS_ON: -fcas-emit-casid-file

// RUN: %clang -cc1depscan -o - -cc1-args -cc1 -triple \
// RUN: x86_64-apple-darwin10 -debug-info-kind=standalone -dwarf-version=4 \
// RUN: -debugger-tuning=lldb -emit-llvm -fcas-backend -fcas-path %t/cas \
// RUN: -fcas-emit-casid-file -mllvm -cas-friendly-debug-info %s | FileCheck %s --check-prefix=MCCAS_OFF

// MCCAS_OFF-NOT: -mllvm
// MCCAS_OFF-NOT: -cas-friendly-debug-info
// MCCAS_OFF-NOT: -fcas-backend
// MCCAS_OFF-NOT: -fcas-emit-casid-file


int foo(int x) {
return x+1;
}