Skip to content

[Modules][libc++] Using <filesystem> with -fmodules -fcxx-modules triggers missing‑import errors #138683

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
devajithvs opened this issue May 6, 2025 · 1 comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

Comments

@devajithvs
Copy link
Contributor

devajithvs commented May 6, 2025

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:

#include <filesystem>

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

with

$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 reproducer with AppleClang: root-project/root#16494 (comment)

@vgvassilev
Copy link
Contributor

Hi @ldionne, looks like libc++ released a broken modulemap. Can you help us with that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

No branches or pull requests

3 participants