Skip to content

Commit 29c5214

Browse files
committed
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. (Cherry picked from commit f7af125)
1 parent 05c1f52 commit 29c5214

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
@@ -8932,6 +8932,7 @@ def fsycl_is_host : Flag<["-"], "fsycl-is-host">,
89328932
// Driver CAS options.
89338933
def fdepscan_EQ : Joined<["-"], "fdepscan=">,
89348934
Group<f_Group>,
8935+
Visibility<[ClangOption, CLOption]>,
89358936
HelpText<"Scan for dependencies ahead of compiling, generating a"
89368937
" pruned CAS tree to send to -fcas-fs. Values are"
89378938
" 'auto',"
@@ -8985,6 +8986,7 @@ def fdepscan_daemon_EQ : Joined<["-"], "fdepscan-daemon=">, Group<f_Group>,
89858986
" parent processes.">;
89868987

89878988
def fdepscan_include_tree : Flag<["-"], "fdepscan-include-tree">,
8989+
Visibility<[ClangOption, CLOption]>,
89888990
Group<f_Group>, HelpText<"Set dep-scanner to produce the include tree">;
89898991

89908992
// CAS prefix map options.

clang/lib/Driver/Driver.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6367,7 +6367,11 @@ const char *Driver::GetNamedOutputPath(Compilation &C, const JobAction &JA,
63676367
// Output to a temporary file?
63686368
if ((!AtTopLevel && !isSaveTempsEnabled() &&
63696369
!C.getArgs().hasArg(options::OPT__SLASH_Fo)) ||
6370-
CCGenDiagnostics) {
6370+
CCGenDiagnostics ||
6371+
// Use a temp file for the depscan reponse file in CL mode
6372+
// (even with a /Fo flag).
6373+
(!AtTopLevel && isa<DepscanJobAction>(JA) &&
6374+
JA.getType() == types::TY_ResponseFile && IsCLMode())) {
63716375
StringRef Name = llvm::sys::path::filename(BaseInput);
63726376
std::pair<StringRef, StringRef> Split = Name.split('.');
63736377
const char *Suffix =

clang/lib/Driver/ToolChains/Clang.cpp

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

48154815
// Add the output path to the object file for CodeView debug infos.
4816-
if (EmitCodeView && Output.isFilename())
4816+
// Skip this for temp depscan reponse file name.
4817+
if (EmitCodeView && Output.isFilename() &&
4818+
Output.getType() != types::TY_ResponseFile)
48174819
addDebugObjectName(Args, CmdArgs, DebugCompilationDir,
48184820
Output.getFilename());
48194821
}
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)