Skip to content

libc++.modules.json resource does not exist #120215

Open
@h-2

Description

@h-2

I am trying this C++ Modules PoC:

CMakeLists.txt:

cmake_minimum_required(VERSION 3.30)

set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED YES)

set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "0e5b6991-d74f-4b3d-a41c-cf096e0b2508")
set(CMAKE_CXX_MODULE_STD ON)

project(example LANGUAGES CXX)
add_executable(main main.cpp)

main.cpp:

import std;

int main()
{
        std::print("foobar\n");
}

I have the following relevant packages installed:

ii  clang-19                                                 1:19.1.5~++20241203083347+ab4b5a2db582-1~exp1~20241203083401.69 amd64        C, C++ and Objective-C compiler
ii  cmake                                                    3.30.2-0kitware1ubuntu24.04.1                                   amd64        cross-platform, open-source make system
ii  cmake-data                                               3.30.2-0kitware1ubuntu24.04.1                                   all          CMake data files (modules, templates and documentation
ii  libc++-19-dev:amd64                                      1:19.1.5~++20241203083347+ab4b5a2db582-1~exp1~20241203083401.69 amd64        LLVM C++ Standard library (development files)
ii  libc++1-19:amd64                                         1:19.1.5~++20241203083347+ab4b5a2db582-1~exp1~20241203083401.69 amd64        LLVM C++ Standard library
ii  libc++abi-19-dev:amd64                                   1:19.1.5~++20241203083347+ab4b5a2db582-1~exp1~20241203083401.69 amd64        LLVM low level support for a standard C++ library (development files)
ii  libc++abi1-19:amd64

I build the project with:
cmake ../ -DCMAKE_CXX_COMPILER=clang++-19 -DCMAKE_CXX_FLAGS="-stdlib=libc++" -DCMAKE_BUILD_TYPE=Debug -G Ninja

It outputs:

-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/clang++-19 - skipped
-- Detecting CXX compile features
CMake Warning (dev) at /usr/share/cmake-3.30/Modules/Compiler/CMakeCommonCompilerMacros.cmake:248 (cmake_language):
  CMake's support for `import std;` in C++23 and newer is experimental.  It
  is meant only for experimentation and feedback to CMake developers.
Call Stack (most recent call first):
  /usr/share/cmake-3.30/Modules/CMakeDetermineCompilerSupport.cmake:113 (cmake_create_cxx_import_std)
  /usr/share/cmake-3.30/Modules/CMakeTestCXXCompiler.cmake:83 (CMAKE_DETERMINE_COMPILER_SUPPORT)
  CMakeLists.txt:10 (project)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Detecting CXX compile features - done
-- Configuring done (0.4s)
CMake Error in CMakeLists.txt:
  The "CXX_MODULE_STD" property on the target "main" requires that the
  "__CMAKE::CXX23" target exist, but it was not provided by the toolchain.
  Reason:

    `libc++.modules.json` resource does not exist


-- Generating done (0.0s)
CMake Generate step failed.  Build files cannot be regenerated correctly.

The requested file is installed by the official apt-package; it is located at: /usr/lib/llvm-19/lib/libc++.modules.json

But clang doesn't seem to be able to find it there.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:driver'clang' and 'clang++' user-facing binaries. Not 'clang-cl'clang:modulesC++20 modules and Clang Header Moduleshelp wantedIndicates that a maintainer wants help. Not [good first issue].libc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions