Skip to content

Commit f7af125

Browse files
authored
CAS fixes for clang cl mode. (#11568)
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 2a134d6 commit f7af125

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
@@ -9000,6 +9000,7 @@ def fsycl_is_host : Flag<["-"], "fsycl-is-host">,
90009000
// Driver CAS options.
90019001
def fdepscan_EQ : Joined<["-"], "fdepscan=">,
90029002
Group<f_Group>,
9003+
Visibility<[ClangOption, CLOption]>,
90039004
HelpText<"Scan for dependencies ahead of compiling, generating a"
90049005
" pruned CAS tree to send to -fcas-fs. Values are"
90059006
" 'auto',"
@@ -9053,6 +9054,7 @@ def fdepscan_daemon_EQ : Joined<["-"], "fdepscan-daemon=">, Group<f_Group>,
90539054
" parent processes.">;
90549055

90559056
def fdepscan_include_tree : Flag<["-"], "fdepscan-include-tree">,
9057+
Visibility<[ClangOption, CLOption]>,
90569058
Group<f_Group>, HelpText<"Set dep-scanner to produce the include tree">;
90579059

90589060
// 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
@@ -4750,7 +4750,9 @@ renderDebugOptions(const ToolChain &TC, const Driver &D, const llvm::Triple &T,
47504750
addDebugPrefixMapArg(D, TC, Args, CmdArgs);
47514751

47524752
// Add the output path to the object file for CodeView debug infos.
4753-
if (EmitCodeView && Output.isFilename())
4753+
// Skip this for temp depscan reponse file name.
4754+
if (EmitCodeView && Output.isFilename() &&
4755+
Output.getType() != types::TY_ResponseFile)
47544756
addDebugObjectName(Args, CmdArgs, DebugCompilationDir,
47554757
Output.getFilename());
47564758
}
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)