[clang] Revert "[clang][DepScan] Disable relocation checks" (PR #231244)
Lei Huang via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 2 11:56:57 PST 2026
================
@@ -0,0 +1,71 @@
+// Check that a relocated module is rebuilt and no error occurs.
+// This is required when a incremental build adds a newer version of an
+// already built library into a preexisting search path.
+// In this example, on the second scan, `DepThatLoadsOldPCMs` is resolved first and
+// populates `MovedDep` into memory.
+// Then when `InvalidatedDep` is loaded, it's input file is out of date
+// and requires a rebuild.
+// When that happens the compiler notices `MovedDep` is in a earlier search path.
+
+
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s|DIR|%/t|g" %t/compile-commands.json.in > %t/compile-commands.json
+
+// RUN: clang-scan-deps -format experimental-full -j 1 \
+// RUN: -compilation-database %t/compile-commands.json -o %t/deps1.json
+// RUN: cat %t/deps1.json | FileCheck %s --check-prefix=DEPS1
+
+// Model update where same framework appears in earlier search path.
+// This can occur on an incremental build where dependency relationships are updated.
+// RUN: sleep 1
+// RUN: mkdir %t/preferred_frameworks/
+// RUN: cp -R %t/fallback_frameworks/MovedDep.framework %t/preferred_frameworks/
+// RUN: touch %t/fallback_frameworks/InvalidatedDep.framework/Modules/module.modulemap
+
+// RUN: clang-scan-deps -format experimental-full -j 1 \
+// RUN: -compilation-database %t/compile-commands.json -o %t/deps2.json
+// RUN: cat %t/deps2.json | FileCheck %s --check-prefix=DEPS2
+
+// DEPS1: "clang-module-deps": [],
+// DEPS1-NEXT: "clang-modulemap-file": "{{.*}}fallback_frameworks{{.*}}MovedDep.framework
+// DEPS1: "name": "MovedDep"
+
+// DEPS2: "clang-module-deps": [],
+// DEPS2-NEXT: "clang-modulemap-file": "{{.*}}preferred_frameworks{{.*}}MovedDep.framework
+// DEPS2: "name": "MovedDep"
+
+//--- compile-commands.json.in
+[
+{
+ "directory": "DIR",
+ "command": "clang -c DIR/tu1.c -fmodules -fmodules-cache-path=DIR/cache -FDIR/preferred_frameworks -FDIR/fallback_frameworks -fbuild-session-file=DIR/session.timestamp -fmodules-validate-once-per-build-session -o DIR/tu1.o ",
----------------
lei137 wrote:
`-F` is a Darwin/Apple-specific option and is unsupported by Clang when targeting Linux . Is this only entended for Darwin targets?
https://github.com/llvm/llvm-project/pull/231244
More information about the cfe-commits
mailing list