xmake-io / xmake

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

使用 c++ 20 的 modules (clang++ 19),能否单独清除 module 的依赖文件并重新生成? #5856

Open vrecluse opened 4 days ago

vrecluse commented 4 days ago

你在什么场景下需要该功能?

modules 的依赖文件缓存似乎不够聪明,比如 import wrong_module; // wrong_module 不存在 编译生成 module 依赖后,编译到该文件时报错 把它改为正确的如 import right_module; 仍然会报错没有 wrong_module

描述可能的解决方案

有没有单独的命令可以清理module依赖重新生成?现在似乎只能删build目录重新编译

描述你认为的候选方案

No response

其他信息

No response

Issues-translate-bot commented 4 days ago

Bot detected the issue body's language is not English, translate it automatically.


Title: When using c++ 20 modules (clang++ 19), can you clear the module's dependency files separately and regenerate them?

In what scenario do you need this function?

The dependency file caching of modules seems not smart enough, for example import wrong_module; // wrong_module does not exist After compiling and generating module dependencies, an error occurs when compiling to this file. Change it to the correct one such as import right_module; The error will still be reported and there is no wrong_module

Describe possible solutions

Is there a separate command to clean up module dependencies and regenerate them? Now it seems that the only option is to delete the build directory and recompile.

Describe your alternatives

No response

Other information

No response

vrecluse commented 4 days ago

另外如果修改 c++ module include 的其它头文件,似乎不会触发 module 重新编译

Issues-translate-bot commented 4 days ago

Bot detected the issue body's language is not English, translate it automatically.


In addition, if you modify other header files of c++ module include, it does not seem to trigger module recompilation.

waruqi commented 4 days ago

这边可以的么。没法复现。

ruki-2:hello ruki$ xmake
checking for Xcode directory ... /Applications/Xcode.app
checking for SDK version of Xcode for macosx (x86_64) ... 14.0
[  0%]: <hello> generating.module.deps src/main.cpp
error: module dependency hello2 required for src/main.cpp not found
warning: some modules have got culled, use verbose (-v) mode to more informations

ruki-2:hello ruki$ perl -pi -e "s/hello2/hello/g" src/main.cpp

ruki-2:hello ruki$ xmake
checking for Xcode directory ... /Applications/Xcode.app
checking for SDK version of Xcode for macosx (x86_64) ... 14.0
[  0%]: <hello> generating.module.deps src/main.cpp
[ 71%]: compiling.release src/main.cpp
[ 85%]: linking.release hello
[100%]: build ok, spent 2.091s

另外,确保安装了 clang-scan-deps 并已被使用,否则 xmake 只能 fallback 内建的模块依赖分析,精准度肯定没 clang-scan-deps 自带的准。