I get an error when I build a c++ modules project that also uses a precompiled header with clang-19. I modified the test at tests/projects/c++/modules/hello to include a precompiled header.
I'm not very knowledgeable about xmake internals yet, but I tried diagnosing a bit and it just seems like the module scanning is running before the PCH is built.
I can provide the project, but I just changed the xmake.lua file to add PCH and use clang-19 and then I added a trivial header file at src/pch.h
~/projects/xmake/tests/projects/c++/modules/hello dev *$ /usr/bin/xmake b -vD
checking for platform ... linux
checking for architecture ... x86_64
checking for gcc ... /usr/bin/gcc
checkinfo: cannot runv(zig version), No such file or directory
checking for zig ... no
checkinfo: cannot runv(zig version), No such file or directory
checking for zig ... no
checkinfo: cannot runv(nim --version), No such file or directory
checking for nim ... no
checkinfo: cannot runv(nim --version), No such file or directory
checking for nim ... no
checkinfo: cannot runv(/usr/bin/clang --version), No such file or directory
checkinfo: cannot runv(clang --version), Not access because it is busy
checking for clang ... no
checking for clang-19 ... /usr/bin/clang-19
checking for clang-19 ... /usr/bin/clang-19
checking for the c++ compiler (cxx) ... clang-19
checking for /usr/bin/clang-19 ... ok
checking for flags (-fPIC) ... ok
> clang-19 "-fPIC" "-Qunused-arguments" "-m64"
checking for flags (clang_modules) ... ok
> clang-19 "-fmodules" "-Qunused-arguments" "-m64"
checking for flags (clang_modules_ts) ... no
> clang-19 "-fmodules-ts" "-Qunused-arguments" "-m64"
checkinfo: @programdir/core/sandbox/modules/os.lua:273: clang-19: error: unknown argument: '-fmodules-ts'
stack traceback:
[C]: in function 'error'
[@programdir/core/base/os.lua:1004]:
[@programdir/core/sandbox/modules/os.lua:273]: in function 'runv'
[@programdir/modules/detect/tools/gcc/has_flags.lua:42]:
checking for /usr/bin/clang-19 ... ok
checking for flags (-fvisibility-inlines-hidden) ... ok
> clang-19 "-fvisibility-inlines-hidden" "-Qunused-arguments" "-m64"
checking for flags (-O3) ... ok
> clang-19 "-O3" "-Qunused-arguments" "-m64"
checking for flags (-std=c++20) ... ok
> clang-19 "-std=c++20" "-Qunused-arguments" "-m64"
checking for flags (-DNDEBUG) ... ok
> clang-19 "-DNDEBUG" "-Qunused-arguments" "-m64"
[ 0%]: <hello> generating.module.deps src/main.cpp
checking for /usr/bin/clang-scan-deps-19 ... ok
/usr/bin/clang-scan-deps-19 --format=p1689 -- /usr/bin/clang-19 -x c++ -c src/main.cpp -o build/.objs/hello/linux/x86_64/release/src/main.cpp.o -Qunused-arguments -m64 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -std=c++20 -include src/pch.h -include-pch build/.objs/hello/linux/x86_64/release/src/cxx/pch.h.pch -DNDEBUG
[ 0%]: <hello> generating.module.deps src/hello.mpp
/usr/bin/clang-scan-deps-19 --format=p1689 -- /usr/bin/clang-19 -x c++ -c src/hello.mpp -o build/.objs/hello/linux/x86_64/release/src/hello.mpp.o -Qunused-arguments -m64 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -std=c++20 -include src/pch.h -include-pch build/.objs/hello/linux/x86_64/release/src/cxx/pch.h.pch -DNDEBUG
error: Error while scanning dependencies for src/main.cpp:
stack traceback:
[C]: in function 'error'
@programdir/core/base/os.lua:1008: in function 'base/os.raiselevel'
(...tail calls...)
@programdir/core/main.lua:329: in upvalue 'cotask'
@programdir/core/base/scheduler.lua:406: in function <@programdir/core/base/scheduler.lua:399>
warning: std and std.compat modules not found! maybe try to add --sdk=<PATH/TO/LLVM> or install libc++
When I try to run the command that clang_scan_deps is running:
~/projects/xmake/tests/projects/c++/modules/hello dev *$ /usr/bin/clang-19 -x c++ -c src/hello.mpp -o build/.objs/hello/linux/x86_64/release/src/hello.mpp.o -Qunused-arguments -m64 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -std=c++20 -include src/pch.h -include-pch build/.objs/hello/linux/x86_64/release/src/cxx/pch.h.pch -DNDEBUG
error: unable to read PCH file build/.objs/hello/linux/x86_64/release/src/cxx/pch.h.pch: 'No such file or directory'
error: unable to open output file 'build/.objs/hello/linux/x86_64/release/src/hello.mpp.o': 'No such file or directory'
2 errors generated.
Xmake Version
2.9.6
Operating System Version and Architecture
Ubuntu 22.04 x86_64
Describe Bug
I get an error when I build a c++ modules project that also uses a precompiled header with clang-19. I modified the test at tests/projects/c++/modules/hello to include a precompiled header.
I'm not very knowledgeable about xmake internals yet, but I tried diagnosing a bit and it just seems like the module scanning is running before the PCH is built.
I can provide the project, but I just changed the xmake.lua file to add PCH and use clang-19 and then I added a trivial header file at
src/pch.h
Contents:
Expected Behavior
Expected compile to succeed.
Project Configuration
Additional Information and Error Logs
It fails when I build.
When I try to run the command that
clang_scan_deps
is running: