Skip to content

The module support file for libc++ cannot be found. #7073

@SnowinterCat

Description

@SnowinterCat

Xmake Version

3.0.5

Operating System Version and Architecture

ubuntu24.04

Describe Bug

The following error occurred when using clang compiler with runtimes=c++_shared:

std and std.compat modules not found! maybe try to add --sdk=<PATH/TO/LLVM> or install libc++

I discovered that the path searched by the get_stdmodules function in xmake/rules/c++/modules/clang/support.lua is incorrect.
My LLVM is installed at /usr/lib/llvm-21.
The module support file is located at /usr/lib/llvm-21/share/libc++/v1/std.compat.cppm.
However, the function searches at this location: /usr/bin/../lib/x86_64-linux-gnu/usr/bin/../lib/llvm-21/bin/../share/libc++/v1

Expected Behavior

I believe this is most likely an issue with relative path resolution. The relative path in the /usr/bin/../lib/x86_64-linux-gnu/libc++.modules.json file should be relative to the directory containing Clang++ within the LLVM installation path.
The get_stdmodules function in xmake/rules/c++/modules/clang/support.lua is incorrect.

Project Configuration

set_languages(c++23, c23)
set_warnings("allextra")
set_encodings("utf-8")
set_exceptions("cxx")

target("test_module")
    set_kind("binary")
    add_files("src/**.cppm")
target_end()

Additional Information and Error Logs

~/Code/Demo$ proxychains xmake f -p linux -a x86_64 -m debug -k shared --runtimes=c++_shared --3rd_kind=shared --toolchain=clang-21 -c
ProxyChains-3.1 (http://proxychains.sf.net)
checking for plugindir ... /home/ubuntu/Code/Demo/bin/plugin/linux-x86_64-shared-c++_shared
checking for datadir ... /home/ubuntu/Code/Demo/bin/data
checking for testdir ... /home/ubuntu/Code/Demo/bin/test/linux-x86_64-shared-c++_shared
checking for libdir ... /home/ubuntu/Code/Demo/bin/lib/linux-x86_64-shared-c++_shared
checking for bindir ... /home/ubuntu/Code/Demo/bin/bin/linux-x86_64-shared-c++_shared
checking for has_std_expected ... ok
checking for has_std_out_ptr ... ok
checking for has_std_runtime_format ... no
warning: std and std.compat modules not found! maybe try to add --sdk=<PATH/TO/LLVM> or install libc++

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions