Skip to content

Commit 1eeb3fa

Browse files
authored
Merge pull request swiftlang#7928 from akyrtzi/akyrtzi/pr/stable-index-options-not-cas
[clang][cas] Ignore indexing options when computing the CAS key
2 parents 229f631 + 7e19643 commit 1eeb3fa

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

clang/lib/Frontend/CompileJobCacheKey.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,20 @@ createCompileJobCacheKeyImpl(ObjectStore &CAS, DiagnosticsEngine &Diags,
7474
// affect the actual compilation.
7575
DepOpts.ExtraDeps.clear();
7676

77+
// Canonicalize indexing options.
78+
79+
// Indexing data are allowed to "escape" the CAS sandbox without indexing
80+
// options affecting the CAS key. Essentially indexing data are produced when
81+
// the compilation is executed but they are not replayed if the compilation is
82+
// cached.
83+
84+
FrontendOpts.IndexStorePath.clear();
85+
FrontendOpts.IndexUnitOutputPath.clear();
86+
FrontendOpts.IndexIgnoreSystemSymbols = false;
87+
FrontendOpts.IndexRecordCodegenName = false;
88+
FrontendOpts.IndexIgnoreMacros = false;
89+
FrontendOpts.IndexIgnorePcms = false;
90+
7791
// Canonicalize diagnostic options.
7892

7993
DiagnosticOptions &DiagOpts = CI.getDiagnosticOpts();

clang/test/CAS/indexing.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Test that emitted indexing data are allowed to "escape" the CAS sandbox without indexing options affecting the CAS key
2+
// (essentially indexing data are produced when the compilation is executed but they are not replayed if the compilation is cached)
3+
4+
// RUN: rm -rf %t && mkdir %t
5+
6+
// RUN: %clang -cc1depscan -fdepscan=inline -fdepscan-include-tree -o %t/t.rsp -cc1-args \
7+
// RUN: -cc1 -triple x86_64-apple-macos12 -fcas-path %t/cas -emit-obj %s -o %t/t.o
8+
9+
// RUN: %clang @%t/t.rsp -Rcompile-job-cache -index-store-path %t/idx -index-unit-output-path t.o 2>&1 \
10+
// RUN: | FileCheck %s --check-prefix=CACHE-MISS
11+
// RUN: find %t/idx/*/records | count 1
12+
13+
// RUN: rm -rf %t/idx && mkdir %t/idx
14+
// RUN: %clang @%t/t.rsp -Rcompile-job-cache 2>&1 \
15+
// RUN: | FileCheck %s --check-prefix=CACHE-HIT
16+
// RUN: ls %t/idx | count 0
17+
18+
// CACHE-MISS: remark: compile job cache miss
19+
// CACHE-HIT: remark: compile job cache hit

0 commit comments

Comments
 (0)