[clang] [Modules][Diagnostic] Improve diagnostics for stale module dependencies (PR #167713)

via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 21 01:48:10 PST 2026


================
@@ -199,7 +199,10 @@ class ModuleManager {
     Missing,
 
     /// The module file is out-of-date.
-    OutOfDate
+    OutOfDate,
+
+    /// The importer file is out-of-date
+    ImporterOutOfDate
----------------
devajithvs wrote:

Hi @ChuanqiXu9, the original issue/bug is mentioned in detail here (also pasting it here): https://github.com/root-project/root/issues/7704#issuecomment-3501531825

```C++
/* A.h */
void a() {}
```

```C++
/* B.h */
#include "A.h"
```

```C++
/* use.c */
#include "B.h"
void use() { a();}
```

```C++
/* module.modulemap */
module A { header "A.h" }
module B { header "B.h" export * }

```

Build pcms:

```bash
rm -rf prebuilt ; mkdir prebuilt
clang -cc1 -emit-module -o prebuilt/A.pcm -fmodules module.modulemap -fmodule-name=A
clang -cc1 -emit-module -o prebuilt/B.pcm -fmodules module.modulemap -fmodule-name=B -fmodule-file=A=prebuilt/A.pcm
```

```bash
module_repro$ ls -lrt prebuilt/
total 32
-rw-rw-r-- 1 dvalapar dvalapar 16260 Nov  7 10:27 A.pcm
-rw-rw-r-- 1 dvalapar dvalapar 16252 Nov  7 10:27 B.pcm
```

Change `A.h` and rebuild only `A.pcm`

```
echo "void b() {};" >> A.h
clang -cc1 -emit-module -o prebuilt/A.pcm -fmodules module.modulemap -fmodule-name=A
clang -cc1 -emit-obj use.c -fmodules -fimplicit-module-maps -fprebuilt-module-path=prebuilt
```

Gives:
```bash
use.c:1:2: fatal error: module file '/tmp/module_repro/prebuilt/A.pcm' is out of date and needs to be rebuilt: module file out of date
    1 | #include "B.h"
      |  ^
use.c:1:2: note: imported by module 'B' in '/tmp/module_repro/prebuilt/B.pcm'
1 error generated.
```

Even though A is recent.
```bash
module_repro$ ls -lrt prebuilt/
total 36
-rw-rw-r-- 1 dvalapar dvalapar 16252 Nov  7 10:27 B.pcm
-rw-rw-r-- 1 dvalapar dvalapar 16396 Nov  7 10:28 A.pcm
```

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


More information about the cfe-commits mailing list