Skip to content

Commit bbf0402

Browse files
[clang-cache] Don't issue -Wreproducible-caching by default
Don't enable the caching warning by default since it changes the behavior and can cause issues for projects using `-Werror`. Instead, add an option to enable -Werror for the option in clang-cache. rdar://102043619
1 parent fe9bc18 commit bbf0402

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

clang/include/clang/Basic/DiagnosticLexKinds.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ def warn_pp_date_time : Warning<
719719

720720
def warn_pp_encounter_nonreproducible: Warning<
721721
"encountered non-reproducible token, caching will be skipped">,
722-
InGroup<DiagGroup<"reproducible-caching">>;
722+
InGroup<DiagGroup<"reproducible-caching">>, DefaultIgnore;
723723
def err_pp_encounter_nonreproducible: Error<
724724
"encountered non-reproducible token, caching failed">;
725725

clang/test/CAS/test-for-deterministic-outputs.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
// CACHE-SKIPPED: remark: compile job cache skipped
1111

1212
// RUN: env LLVM_CACHE_CAS_PATH=%t/cas %clang-cache \
13-
// RUN: %clang -target x86_64-apple-macos11 -c %s -o %t/t.o -Rcompile-job-cache 2> %t/out.txt
13+
// RUN: %clang -target x86_64-apple-macos11 -c %s -o %t/t.o -Rcompile-job-cache -Wreproducible-caching 2> %t/out.txt
1414
// RUN: FileCheck %s --check-prefix=CACHE-WARN --input-file=%t/out.txt
1515

1616
/// Check still a cache miss.
1717
// RUN: env LLVM_CACHE_CAS_PATH=%t/cas %clang-cache \
18-
// RUN: %clang -target x86_64-apple-macos11 -c %s -o %t/t.o -Rcompile-job-cache 2> %t/out.txt
18+
// RUN: %clang -target x86_64-apple-macos11 -c %s -o %t/t.o -Rcompile-job-cache -Wreproducible-caching 2> %t/out.txt
1919
// RUN: FileCheck %s --check-prefix=CACHE-WARN --input-file=%t/out.txt
2020

2121
// CACHE-WARN: remark: compile job cache miss
@@ -24,6 +24,17 @@
2424
// CACHE-WARN: warning: encountered non-reproducible token, caching will be skipped
2525
// CACHE-WARN: remark: compile job cache skipped
2626

27+
/// Check -Werror doesn't actually error when we use the launcher.
28+
// RUN: env LLVM_CACHE_CAS_PATH=%t/cas %clang-cache \
29+
// RUN: %clang -target x86_64-apple-macos11 -c %s -o %t/t.o -Werror -Rcompile-job-cache 2> %t/out.txt
30+
// RUN: FileCheck %s --check-prefix=NOERROR --input-file=%t/out.txt
31+
// RUN: not env LLVM_CACHE_CAS_PATH=%t/cas CLANG_CACHE_CHECK_REPRODUCIBLE_CACHING_ISSUES=1 %clang-cache \
32+
// RUN: %clang -target x86_64-apple-macos11 -c %s -o %t/t.o -Rcompile-job-cache 2> %t/out.txt
33+
// RUN: FileCheck %s --check-prefix=ERROR --input-file=%t/out.txt
34+
35+
// NOERROR-NOT: error:
36+
// ERROR: error: encountered non-reproducible token, caching will be skipped
37+
2738
void getit(const char **p1, const char **p2, const char **p3) {
2839
*p1 = __DATE__;
2940
*p2 = __TIMESTAMP__;

clang/tools/driver/CacheLauncherMode.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,10 @@ clang::handleClangCacheInvocation(SmallVectorImpl<const char *> &Args,
189189
Args.append({"-Wno-builtin-macro-redefined", "-D__DATE__=\"redacted\"",
190190
"-D__TIMESTAMP__=\"redacted\"", "-D__TIME__=\"redacted\""});
191191
}
192+
if (llvm::sys::Process::GetEnv(
193+
"CLANG_CACHE_CHECK_REPRODUCIBLE_CACHING_ISSUES")) {
194+
Args.append({"-Werror=reproducible-caching"});
195+
}
192196
if (llvm::sys::Process::GetEnv("CLANG_CACHE_TEST_DETERMINISTIC_OUTPUTS")) {
193197
// Run the compilation twice, without replaying, to check that we get the
194198
// same compilation artifacts for the same key. If they are not the same

0 commit comments

Comments
 (0)