Skip to content

Commit a1a7393

Browse files
[IncludeTree] Do not pass compilation directories
When using include-tree, all the relative paths references should be turned into absolute path already. There is no need to pass options like `-fdebug-compilation-dir` for debug info generation as it makes cache hit less likely when two identical compilations where performed with different compilation directories.
1 parent 61b3a90 commit a1a7393

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

clang/lib/Tooling/DependencyScanning/ScanAndUpdateArgs.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ void tooling::dependencies::configureInvocationForCaching(
103103
// Clear APINotes options.
104104
CI.getAPINotesOpts().ModuleSearchPaths = {};
105105

106+
// Reset debug/coverage compilation dir as include-tree uses absolute path.
107+
CodeGenOpts.DebugCompilationDir.clear();
108+
CodeGenOpts.CoverageCompilationDir.clear();
106109
// Update output paths, and clear working directory.
107110
auto CWD = FileSystemOpts.WorkingDir;
108111
updateRelativePath(FrontendOpts.OutputFile, CWD);

clang/test/ClangScanDeps/include-tree-preserve-pch-path.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// REQUIRES: ondisk_cas
22

3+
// RUN: rm -rf %t
34
// RUN: split-file %s %t
45
// RUN: sed -e "s|DIR|%/t|g" %t/cdb_pch.json.template > %t/cdb_pch.json
56
// RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json
@@ -10,6 +11,7 @@
1011

1112
// CHECK: "-fmodule-format=obj"
1213
// CHECK: "-dwarf-ext-refs"
14+
// CHECK-NOT: -fdebug-compilation-dir
1315

1416
// RUN: %deps-to-rsp %t/deps_pch.json --tu-index 0 > %t/pch.rsp
1517
// RUN: %clang @%t/pch.rsp
@@ -21,7 +23,9 @@
2123
// RUN: %clang @%t/tu.rsp
2224

2325
// RUN: cat %t/tu.ll | FileCheck %s -check-prefix=LLVMIR -DPREFIX=%/t
24-
// LLVMIR: !DICompileUnit({{.*}}, splitDebugFilename: "prefix.pch"
26+
// LLVMIR: !DIFile(filename: "[[PREFIX]]/tu.c", directory: "")
27+
// LLVMIR: !DICompileUnit({{.*}}, splitDebugFilename: "[[PREFIX]]/prefix.pch"
28+
// LLVMIR: !DIFile(filename: "prefix.h", directory: "")
2529

2630
// Extract include-tree casid
2731
// RUN: cat %t/tu.rsp | sed -E 's|.*"-fcas-include-tree" "(llvmcas://[[:xdigit:]]+)".*|\1|' > %t/tu.casid

0 commit comments

Comments
 (0)