Author: Cyndy Ishida
Date: 2026-09-24T18:00:15-07:00
New Revision: dd3534fd5af15575d0d8dea116740b2abb8f3328

URL: 
https://github.com/llvm/llvm-project/commit/dd3534fd5af15575d0d8dea116740b2abb8f3328
DIFF: 
https://github.com/llvm/llvm-project/commit/dd3534fd5af15575d0d8dea116740b2abb8f3328.diff

LOG: [clang][DepScan] Disable relocation checks (#225563)

This internally broke an incremental build. Disable while it gets
investigated.

This is partial revert of cf8597bd3b87 
resolves: rdar://188026923

Added: 
    

Modified: 
    clang/lib/DependencyScanning/DependencyScanningWorker.cpp
    clang/test/ClangScanDeps/modules-relocated-mm-macro.c

Removed: 
    clang/test/ClangScanDeps/build-session-validation-relocated-modules.c


################################################################################
diff  --git a/clang/lib/DependencyScanning/DependencyScanningWorker.cpp 
b/clang/lib/DependencyScanning/DependencyScanningWorker.cpp
index c681bb93b83146..c6855f605e1712 100644
--- a/clang/lib/DependencyScanning/DependencyScanningWorker.cpp
+++ b/clang/lib/DependencyScanning/DependencyScanningWorker.cpp
@@ -427,6 +427,9 @@ createScanCompilerInvocation(const CompilerInvocation 
&Invocation,
       true;
   ScanInvocation->getHeaderSearchOpts().ModulesForceValidateUserHeaders = 
false;
 
+  // Avoid some checks and module map parsing when loading PCM files.
+  ScanInvocation->getPreprocessorOpts().ModulesCheckRelocated = false;
+
   // FIXME: Do this even with PCHs by marking the option as something like
   // "preprocessor benign" in LangOptions.def so that it passes the
   // compatibility checks in ASTReader.

diff  --git 
a/clang/test/ClangScanDeps/build-session-validation-relocated-modules.c 
b/clang/test/ClangScanDeps/build-session-validation-relocated-modules.c
deleted file mode 100644
index 93f9d37cb00d19..00000000000000
--- a/clang/test/ClangScanDeps/build-session-validation-relocated-modules.c
+++ /dev/null
@@ -1,71 +0,0 @@
-// 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 ",
-  "file": "DIR/tu1.c"                                                          
             
-}
-]
-
-//--- session.timestamp
-
-//--- fallback_frameworks/MovedDep.framework/Modules/module.modulemap
-framework module MovedDep { header "MovedDep.h" }
-//--- fallback_frameworks/MovedDep.framework/Headers/MovedDep.h
-int foo(void);
-
-//--- fallback_frameworks/InvalidatedDep.framework/Modules/module.modulemap
-framework module InvalidatedDep { header "InvalidatedDep.h" }
-//--- fallback_frameworks/InvalidatedDep.framework/Headers/InvalidatedDep.h
-#include <MovedDep/MovedDep.h>
-
-//--- fallback_frameworks/DirectDep.framework/Modules/module.modulemap
-framework module DirectDep { header "DirectDep.h" }
-//--- fallback_frameworks/DirectDep.framework/Headers/DirectDep.h
-#include <DepThatLoadsOldPCMs/DepThatLoadsOldPCMs.h>
-#include <InvalidatedDep/InvalidatedDep.h>
-
-//--- 
fallback_frameworks/DepThatLoadsOldPCMs.framework/Modules/module.modulemap
-framework module DepThatLoadsOldPCMs { header "DepThatLoadsOldPCMs.h" }
-//--- 
fallback_frameworks/DepThatLoadsOldPCMs.framework/Headers/DepThatLoadsOldPCMs.h
-#include <MovedDep/MovedDep.h>
-
-//--- tu1.c
-#include <DirectDep/DirectDep.h>

diff  --git a/clang/test/ClangScanDeps/modules-relocated-mm-macro.c 
b/clang/test/ClangScanDeps/modules-relocated-mm-macro.c
index c5337ce6121243..6e69f7550d1ead 100644
--- a/clang/test/ClangScanDeps/modules-relocated-mm-macro.c
+++ b/clang/test/ClangScanDeps/modules-relocated-mm-macro.c
@@ -1,5 +1,5 @@
 // This test checks that we don't crash when we load two conflicting PCM files
-// and instead use the newer copy.
+// and instead emit the appropriate diagnostics.
 
 // RUN: rm -rf %t
 // RUN: split-file %s %t
@@ -13,11 +13,14 @@
 
 // RUN: cp -R %t/frameworks2/A.framework %t/frameworks1
 
-// RUN: clang-scan-deps -format experimental-full -o %t/deps2.json 2>&1 -- \
+// RUN: not clang-scan-deps -format experimental-full -o %t/deps2.json 
2>%t/errs -- \
 // RUN:   %clang -fmodules -fmodules-cache-path=%t/cache \
 // RUN:   -F %t/frameworks1 -F %t/frameworks2 \
-// RUN:   -c %t/tu2.m -o %t/tu2.o \
-// RUN: | FileCheck %s --allow-empty --implicit-check-not="warning"
+// RUN:   -c %t/tu2.m -o %t/tu2.o
+// RUN: FileCheck --input-file=%t/errs %s
+
+// CHECK:      fatal error: module 'A' is defined in both '{{.*}}.pcm' and 
'{{.*}}.pcm'
+// CHECK-NEXT: note: compiled from '{{.*}}frameworks1{{.*}}' and 
'{{.*}}frameworks2{{.*}}'
 
 //--- frameworks2/A.framework/Modules/module.modulemap
 framework module A { header "A.h" }
@@ -34,7 +37,7 @@ framework module B { header "B.h" }
 
 //--- tu2.m
 #include <A/A.h>
-#include <B/B.h> // This results in a rebuild of B. 
+#include <B/B.h> // This results in a conflict and a fatal loader error.
 
-#if MACRO_A // This previously crashed with lexer that does not respect 
`cutOfLexing()`.
+#if MACRO_A // This crashes with lexer that does not respect `cutOfLexing()`.
 #endif


        
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to