<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/70569>70569</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Confusing "module file out of date" errors with C++20 modules
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          rnikander
      </td>
    </tr>
</table>

<pre>
    I will attach a zipped up project, with some source code and a Makefile. At the top of the Makefile, there are some variables that point to my build of clang. Those need to be changed, but then I hope you can reproduce this.

[files.tgz](https://github.com/llvm/llvm-project/files/13196637/files.tgz)

The commands in the Makefile are my attempt to follow the docs [here]( https://clang.llvm.org/docs/StandardCPlusPlusModules.html).

### Steps to demonstrate the issue

1. Change this top part of the Makefile to fit your build of clang. I'm building on a Mac so I need that `macos_sdk` setting.

```make
CXX = /Users/rob/Dev/llvm-project/build_phase1/bin/clang++
macos_sdk = /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk
flags = -isysroot $(macos_sdk) -std=c++2b
```

2. Run `make`, and you should see this output.

```console
% make
Precompiling interface_part1.ccm -> interface_part1.pcm
Precompiling interface_part2.ccm -> interface_part2.pcm
Precompiling foo.ccm -> foo.pcm
Compiling main.cc -> main.o
Compiling foo.pcm -> foo.o
Compiling interface_part1.pcm -> interface_part1.o
Compiling interface_part2.pcm -> interface_part2.o
Linking program
```

3. You can run the `program` to confirm that it compiled.

```console
% ./program 
Starting main()
hello from foo:interface_part1
hello from foo:interface_part2
```

4. Now, change the variable name in the `other()` function in `interface_part1.ccm`. For example change `int a` to `int aa`. 

```c++
void other() {
    int aa = 1;
}
```

5. Run `make` again. I see this:

```console
% make     
Precompiling interface_part1.ccm -> interface_part1.pcm
Precompiling foo.ccm -> foo.pcm
foo.ccm:5:8: fatal error: module file 'interface_part1.pcm' is out of date and needs to be rebuilt: module file out of date
    5 | export import :interface_part2;
      |        ^
foo.ccm:5:8: note: imported by module 'foo:interface_part2' in 'interface_part2.pcm'
```

This seems like a problem to me, for a couple reasons:

1. The error is misleading. It says `interface_part1.pcm` is out of date and "needs to be rebuilt", but I just rebuilt it.
2. If `interface_part2.pcm` needs to be rebuilt, because it depends on part1, that seems like these modules are worse than headers at hiding implementation details. I changed a private non-exported function `other()`, and I changed an implementation detail - the name of the local variable. The exposed interface of `interface_part1` should not change in this case. And I don't think it should trigger the need to recompile things that depend on it.

It's interesting that if I only change the _value_ of `int a` in `other()`, say `int a = 1` to `int a = 2`, then then `make` rebuilds things as expected without a problem. 


</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysV0Fv4zoO_jXKhajhyLGTHnLopC9AsDu7g-0sMHsqFImO9SpLhiS3k_frF5TtJG3Tziywg0xS2yRNfiQ_UiIEfbCIa1Z-YeX9TPSxcX7trX4SVqGf7Z06rnfwoo0BEaOQDQj4S3cdKug76Lz7E2VkfAMvOjYQXIsQXO8lgnQKQVgFAr6KJ6y1wQzuIsQGIboOXJ3-nJ6RjdigRxAeB0PPwmuxNxggNiJC57SNEB20R9j32igyIY2whwy-Ny4gWERFAnsE2Qh7QEVW9316qYUdNK5DOLoepLDgsfNO9RIhNjpkLL9n-d34XX4hn0IWD3-x8p7xVRNjF1hxx_iW8e1Bx6bfZ9K1jG-NeZ5-bk6AbJM-49t5Mb-tqmI53Uom-e3l2743hFbbCqsCaPsKloRGeyTwse1S-LUzxr0kKeVkAFZ-IdwGP-G1owM85Frm_IHxLWkwvn2Iwirh1eab6QP9_-pUT941sTWM375GgxfDBx4idoF8UNg6G6IXEZMjOoQeL3XmGWxSChK4KeGd8PFt1lM8OlJO_Luk7hhftsNdbQ_gbColCcHBbsw11QWr8lZIFx6DemJVDgFj1PbwOoQqHz6teBr93Pz4Aay4B8a3_w7oCRXv9oxv7_H5fTqTF49dIwLO6VLbCV3Gv9An2Tz5MVm-6zqjp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