Skip to content

[clang][modules] Test for llvm#139751 #10661

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions clang/test/ClangScanDeps/modules-include-tree-sdk-settings.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// This test checks that the module cache gets invalidated when the
// SDKSettings.json file changes. This prevents "file changed during build"
// errors when the TU does get rescanned and recompiled.

// REQUIRES: ondisk_cas

// RUN: rm -rf %t
// RUN: split-file %s %t

//--- sdk/SDKSettings.json
{
"Version": "11.0",
"MaximumDeploymentTarget": "11.0.99"
}

//--- module.modulemap
module M { header "M.h" }
//--- M.h
//--- tu.c
#include "M.h"

// RUN: clang-scan-deps -format experimental-include-tree-full -cas-path %t/cas -o %t/deps_clean.json \
// RUN: -- %clang -target x86_64-apple-macos11 -isysroot %t/sdk \
// RUN: -c %t/tu.c -o %t/tu.o -fmodules -fmodules-cache-path=%t/cache

// RUN: sleep 1
// RUN: echo " " >> %t/sdk/SDKSettings.json
// RUN: echo " " >> %t/tu.c

// RUN: clang-scan-deps -format experimental-include-tree-full -cas-path %t/cas -o %t/deps_incremental.json \
// RUN: -- %clang -target x86_64-apple-macos11 -isysroot %t/sdk \
// RUN: -c %t/tu.c -o %t/tu.o -fmodules -fmodules-cache-path=%t/cache

// RUN: %deps-to-rsp %t/deps_incremental.json --module-name M > %t/M.rsp
// RUN: %deps-to-rsp %t/deps_incremental.json --tu-index 0 > %t/tu.rsp
// RUN: %clang @%t/M.rsp
// RUN: %clang @%t/tu.rsp
5 changes: 4 additions & 1 deletion clang/tools/c-index-test/core_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,10 @@ static int scanDeps(ArrayRef<const char *> Args, std::string WorkingDirectory,
llvm::outs() << " " << ModuleName << "\n";
llvm::outs() << " file-deps:\n";
for (const auto &FileName : ArrayRef(FileDeps.Strings, FileDeps.Count))
llvm::outs() << " " << FileName << "\n";
// Not reporting SDKSettings.json so that test checks can remain
// (mostly) platform-agnostic.
if (!StringRef(FileName).ends_with("SDKSettings.json"))
llvm::outs() << " " << FileName << "\n";
llvm::outs() << " build-args:";
for (const auto &Arg :
ArrayRef(BuildArguments.Strings, BuildArguments.Count))
Expand Down