[clang] [clang][modules] Introduce a flag to keep redundant module lookups on relocation checks (PR #219107)

Cyndy Ishida via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 27 12:02:55 PDT 2026


================
@@ -0,0 +1,21 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+// Verify a module that is built in the same session was looked up during a relocation 
+// check when forced. 
+
+// RUN: touch %t/session.timestamp
+// RUN: %clang -fmodules -fimplicit-module-maps -fsyntax-only %t/tu1.c \
+// RUN:   -fmodules-cache-path=%t/cache -I%t/include \
+// RUN:   -fbuild-session-file=%t/session.timestamp -fmodules-validate-once-per-build-session \
+// RUN:   -Xclang -fmodules-force-redundant-lookup -Rmodule-validation 2>&1 | FileCheck %s
+
+// CHECK: checking if module 'Dep' from '{{.*}}Dep-{{.*}}.pcm' has relocated
----------------
cyndyishida wrote:

Just acceptable because it's preexisting. In a well-behaved compilation, there should be no reason to validate a just-built module, so the default is not to. This is what I changed as part of supporting relocation checks. But a project not using explicit modules depends on this behavior.


So basically, before https://github.com/llvm/llvm-project/commit/cf8597bd3b87aeed6696454f22311e86ed70138f, relocation checks only happened on implicit modules and were not gated on build session flags. 

To be able to do this for dependency scans with reasonable perf traits, I added the build session gate generally, and that's what made a project break. 



https://github.com/llvm/llvm-project/pull/219107


More information about the cfe-commits mailing list