xmake-io / xmake

🔥 A cross-platform build utility based on Lua
https://xmake.io
Apache License 2.0
9.9k stars 776 forks source link

`user_headerunit` example failing to compile #5695

Open Tomcat-42 opened 1 day ago

Tomcat-42 commented 1 day ago

Xmake Version

v2.9.5+dev.124e091f9

Operating System Version and Architecture

Arch Linux @ 6.10.11

Describe Bug

Xmake fails to import header.hpp while building the project.

Expected Behavior

I should be able to import header units in my code (?, I don't know if it's fully implemented in xmake).

Project Configuration

add_rules("mode.release", "mode.debug")
set_languages("c++latest")
set_runtimes("c++_shared")
set_toolchains("clang")
add_headerfiles("src/*.hpp")
add_cxxflags("-fmodules", "-fimplicit-modules", "-fimplicit-module-maps")
set_policy("build.c++.modules", true)

target("user_headerunit")
set_kind("binary")
add_files("src/*.cpp", "src/*.mpp")

Additional Information and Error Logs

I'm using clang, libc++ and clang-scan-deps from trunk (20.0.0).

checking for architecture ... x86_64                                                                             
[  0%]: <user_headerunit> generating.module.deps src/main.cpp                                                    
[  0%]: <user_headerunit> generating.module.deps src/hello.mpp                                                   
[  0%]: <user_headerunit> generating.module.deps /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../lib
64/../share/libc++/v1/std.cppm                                                                                   
[  0%]: <user_headerunit> generating.module.deps /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../lib
64/../share/libc++/v1/std.compat.cppm                                                                            
error: Error while scanning dependencies for src/main.cpp:                                                       
src/main.cpp:4:8: error: header file "header.hpp" (aka 'src/header.hpp') cannot be imported because it is not kno
wn to be a header unit                         
Arthapz commented 1 day ago

to use header unit u need to enable fallback scanner (which enable other problem like C++ version detection), clang-scan-deps doesn't support header unit currently

headerunit are highly experimental on clang, i suggest to use only named modules

Arthapz commented 1 day ago

see https://reviews.llvm.org/D139168