Skip to content

Commit ca99d79

Browse files
committed
CAS fixes for clang cl mode.
Three changes: - Make depscan flags visible. - Fix an issue that a depscan reponse file is written in the current directory without a unique id/hash in its path, collides with another for an identical source file and causes a build error. - Fix an issue that causes unexpected cas cache misses due to a temp depscan reponse file path (with a unique id/hash) being specified (incorrectly/unnecessarily) specified as the output object file (the -object-file-name flag) when for code view / pdb debug info is emitted.
1 parent d18cb4f commit ca99d79

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8995,6 +8995,7 @@ def fsycl_is_host : Flag<["-"], "fsycl-is-host">,
89958995
// Driver CAS options.
89968996
def fdepscan_EQ : Joined<["-"], "fdepscan=">,
89978997
Group<f_Group>,
8998+
Visibility<[ClangOption, CLOption]>,
89988999
HelpText<"Scan for dependencies ahead of compiling, generating a"
89999000
" pruned CAS tree to send to -fcas-fs. Values are"
90009001
" 'auto',"
@@ -9048,6 +9049,7 @@ def fdepscan_daemon_EQ : Joined<["-"], "fdepscan-daemon=">, Group<f_Group>,
90489049
" parent processes.">;
90499050

90509051
def fdepscan_include_tree : Flag<["-"], "fdepscan-include-tree">,
9052+
Visibility<[ClangOption, CLOption]>,
90519053
Group<f_Group>, HelpText<"Set dep-scanner to produce the include tree">;
90529054

90539055
// CAS prefix map options.

clang/lib/Driver/Driver.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6362,7 +6362,11 @@ const char *Driver::GetNamedOutputPath(Compilation &C, const JobAction &JA,
63626362
// Output to a temporary file?
63636363
if ((!AtTopLevel && !isSaveTempsEnabled() &&
63646364
!C.getArgs().hasArg(options::OPT__SLASH_Fo)) ||
6365-
CCGenDiagnostics) {
6365+
CCGenDiagnostics ||
6366+
// Use a temp file for the depscan reponse file in CL mode
6367+
// (even with a /Fo flag).
6368+
(!AtTopLevel && isa<DepscanJobAction>(JA) &&
6369+
JA.getType() == types::TY_ResponseFile && IsCLMode())) {
63666370
StringRef Name = llvm::sys::path::filename(BaseInput);
63676371
std::pair<StringRef, StringRef> Split = Name.split('.');
63686372
const char *Suffix =

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4721,7 +4721,9 @@ renderDebugOptions(const ToolChain &TC, const Driver &D, const llvm::Triple &T,
47214721
addDebugPrefixMapArg(D, TC, Args, CmdArgs);
47224722

47234723
// Add the output path to the object file for CodeView debug infos.
4724-
if (EmitCodeView && Output.isFilename())
4724+
// Skip this for temp depscan reponse file name.
4725+
if (EmitCodeView && Output.isFilename() &&
4726+
Output.getType() != types::TY_ResponseFile)
47254727
addDebugObjectName(Args, CmdArgs, DebugCompilationDir,
47264728
Output.getFilename());
47274729
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// REQUIRES: ondisk_cas
2+
3+
// RUN: rm -rf %t
4+
// RUN: split-file %s %t
5+
6+
// RUN: %clang_cl -c /clang:-fdepscan=inline /clang:-fdepscan-include-tree -Xclang -fcas-path -Xclang %t/cas -Xclang -Rcompile-job-cache -- %t/test.c 2>&1 | FileCheck %s -check-prefix=CACHE-MISS
7+
// RUN: %clang_cl -c /clang:-fdepscan=inline /clang:-fdepscan-include-tree -Xclang -fcas-path -Xclang %t/cas -Xclang -Rcompile-job-cache -- %t/test.c 2>&1 | FileCheck %s -check-prefix=CACHE-HIT
8+
9+
// In debug mode
10+
// RUN: %clang_cl -c /clang:-fdepscan=inline /clang:-fdepscan-include-tree -Xclang -fcas-path -Xclang %t/cas -Xclang -Rcompile-job-cache /Z7 -- %t/test.c 2>&1 | FileCheck %s -check-prefix=CACHE-MISS
11+
// RUN: %clang_cl -c /clang:-fdepscan=inline /clang:-fdepscan-include-tree -Xclang -fcas-path -Xclang %t/cas -Xclang -Rcompile-job-cache /Z7 -- %t/test.c 2>&1 | FileCheck %s -check-prefix=CACHE-HIT
12+
13+
// CACHE-HIT: remark: compile job cache hit
14+
// CACHE-MISS: remark: compile job cache miss
15+
16+
//--- test.c
17+
int main() { return 0; }

0 commit comments

Comments
 (0)