Skip to content

Commit ab4f5af

Browse files
authored
Merge pull request #10661 from swiftlang/jan_svoboda/sdk-settings-json-invalidation
[clang][modules] Test for llvm#139751
2 parents b56bd67 + 97afa65 commit ab4f5af

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// This test checks that the module cache gets invalidated when the
2+
// SDKSettings.json file changes. This prevents "file changed during build"
3+
// errors when the TU does get rescanned and recompiled.
4+
5+
// REQUIRES: ondisk_cas
6+
7+
// RUN: rm -rf %t
8+
// RUN: split-file %s %t
9+
10+
//--- sdk/SDKSettings.json
11+
{
12+
"Version": "11.0",
13+
"MaximumDeploymentTarget": "11.0.99"
14+
}
15+
16+
//--- module.modulemap
17+
module M { header "M.h" }
18+
//--- M.h
19+
//--- tu.c
20+
#include "M.h"
21+
22+
// RUN: clang-scan-deps -format experimental-include-tree-full -cas-path %t/cas -o %t/deps_clean.json \
23+
// RUN: -- %clang -target x86_64-apple-macos11 -isysroot %t/sdk \
24+
// RUN: -c %t/tu.c -o %t/tu.o -fmodules -fmodules-cache-path=%t/cache
25+
26+
// RUN: sleep 1
27+
// RUN: echo " " >> %t/sdk/SDKSettings.json
28+
// RUN: echo " " >> %t/tu.c
29+
30+
// RUN: clang-scan-deps -format experimental-include-tree-full -cas-path %t/cas -o %t/deps_incremental.json \
31+
// RUN: -- %clang -target x86_64-apple-macos11 -isysroot %t/sdk \
32+
// RUN: -c %t/tu.c -o %t/tu.o -fmodules -fmodules-cache-path=%t/cache
33+
34+
// RUN: %deps-to-rsp %t/deps_incremental.json --module-name M > %t/M.rsp
35+
// RUN: %deps-to-rsp %t/deps_incremental.json --tu-index 0 > %t/tu.rsp
36+
// RUN: %clang @%t/M.rsp
37+
// RUN: %clang @%t/tu.rsp

clang/tools/c-index-test/core_main.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,10 @@ static int scanDeps(ArrayRef<const char *> Args, std::string WorkingDirectory,
861861
llvm::outs() << " " << ModuleName << "\n";
862862
llvm::outs() << " file-deps:\n";
863863
for (const auto &FileName : ArrayRef(FileDeps.Strings, FileDeps.Count))
864-
llvm::outs() << " " << FileName << "\n";
864+
// Not reporting SDKSettings.json so that test checks can remain
865+
// (mostly) platform-agnostic.
866+
if (!StringRef(FileName).ends_with("SDKSettings.json"))
867+
llvm::outs() << " " << FileName << "\n";
865868
llvm::outs() << " build-args:";
866869
for (const auto &Arg :
867870
ArrayRef(BuildArguments.Strings, BuildArguments.Count))

0 commit comments

Comments
 (0)