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

    <tr>
        <th>Summary</th>
        <td>
            [Modules][libc++] Using <filesystem> with -fmodules -fcxx-modules triggers missing‑import errors
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            libc++
      </td>
    </tr>

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

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

<pre>
    When compiling a minimal program using `<filesystem>` with `-fmodules -fcxx-modules` using libc++ built from upstream, the compiler fails with module import errors for `time_point` and ` _FilesystemClock.`

Compiling the below code:
```C++
#include <filesystem>

int main() {
    std::filesystem::file_time_type::clock::now();
    return 0;
}

```

with
```bash
$LLVM_INSTALL/bin/clang++ \
-stdlib=libc++ -nostdinc++ \
-isystem $LLVM_INSTALL/include/x86_64-unknown-linux-gnu/c++/v1 \
-isystem $LLVM_INSTALL/include/c++/v1 \
-fmodules -fcxx-modules \
reproducer.cpp
```

Raises:

```
reproducer.cpp:4:22: error: missing '#include <__chrono/time_point.h>'; 'time_point' must be defined before it is used
    4 |     std::filesystem::file_time_type::clock::now();
      |                      ^
.../include/c++/v1/__chrono/time_point.h:34:28: note: definition here is not reachable
   34 | class _LIBCPP_TEMPLATE_VIS time_point {
      |                            ^
reproducer.cpp:4:38: error: missing '#include <__chrono/file_clock.h>'; '_FilesystemClock' must be defined before it is used
    4 |     std::filesystem::file_time_type::clock::now();
      |                                      ^
.../include/c++/v1/__chrono/file_clock.h:49:8: note: definition here is not reachable
   49 | struct _FilesystemClock {
      |        ^
2 errors generated.
```

Similar failures/warnings were first observed with Apple’s libc++ module map on MacOS with Sonoma 14.6.1 and XCode 15.4 and clang-1500.3.9.4 - See a similar reproduce with AppleClang: https://github.com/root-project/root/pull/16494#issuecomment-2835071220
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJz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