Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modules from packages not added when generating vs projects #6070

Open
Shiffted opened this issue Jan 13, 2025 · 11 comments
Open

Modules from packages not added when generating vs projects #6070

Shiffted opened this issue Jan 13, 2025 · 11 comments
Labels

Comments

@Shiffted
Copy link
Contributor

Xmake Version

2.9.7

Operating System Version and Architecture

Windows

Describe Bug

Modules from packages are not added when generating vs projects (both vs and vsxmake). Local modules and modules from other targets work as expected, building also works.

Expected Behavior

Modules from packages are recognized in vs projects.

Project Configuration

add_requires("magic_enum", {configs={modules=true}})

add_rules("mode.debug", "mode.release")
set_languages("c++23")

target("module_test")
    set_kind("binary")
    add_files("src/*.cpp")
    add_packages("magic_enum")
    set_policy("build.c++.modules", true)

missing_module

Additional Information and Error Logs

Compilation works:

xmake build module_test
checking for Microsoft Visual Studio (x64) version ... 2022
checking for Microsoft C/C++ Compiler (x64) version ... 19.42.34435
[  0%]: <module_test> generating.module.deps src\main.cpp
[  0%]: <module_test> generating.module.deps C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.42.34433\modules\std.ixx
[  0%]: <module_test> generating.module.deps F:\packages\.xmake\packages\m\magic_enum\v0.9.7\fdb5460ff3c64f3a824f1e422136da67\modules\7597f117\magic_enum.cppm
[  0%]: <module_test> generating.module.deps C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.42.34433\modules\std.compat.ixx
[ 42%]: <module_test> compiling.module.release magic_enum
[ 71%]: compiling.release src\main.cpp
[ 85%]: linking.release module_test.exe
[100%]: build ok, spent 3.938s
@Shiffted Shiffted added the bug label Jan 13, 2025
@waruqi
Copy link
Member

waruqi commented Jan 13, 2025

vs project generator does not support modules now.

@nqf
Copy link

nqf commented Jan 26, 2025

vs project generator does not support modules now.

gcc15 也不支持吗. 我用gcc15 编译的模块工程, 生成compile_commands.json, clangd 也不识别, 用的 xmake v2.9.7+20250122, 如果我使用clang-20 编译, 然后它生成 compile_commands.json,clangd 可以识别

Image

➜  test-mod diff compile_commands.json compile_commands.json.gcc15                           
4,5c4,5
<   "arguments": ["/usr/lib/llvm-20/bin/clang", "-c", "-Qunused-arguments", "-m64", "-fvisibility=hidden", "-fvisibility-inlines-hidden", "-O3", "-std=c++26", "-stdlib=libc++", "-cxx-isystem/usr/lib/llvm-20/include/c++/v1", "-DNDEBUG", "-x", "c++-module", "-fmodule-output=build/.gens/test-mod/linux/x86_64/release/rules/bmi/cache/modules/641690a7/std.pcm", "-Wno-include-angled-in-module-purview", "-Wno-reserved-module-identifier", "-o", "build/.objs/test-mod/linux/x86_64/release/usr/lib/llvm-20/bin/__/lib/__/share/libc++/v1/std.cppm.o", "/usr/lib/llvm-20/bin/../lib/../share/libc++/v1/std.cppm"],
<   "file": "/usr/lib/llvm-20/bin/../lib/../share/libc++/v1/std.cppm"
---
>   "arguments": ["/root/gcc15/bin/g++", "-c", "-m64", "-fvisibility=hidden", "-fvisibility-inlines-hidden", "-O3", "-std=c++26", "-fmodules-ts", "-D_GLIBCXX_USE_CXX11_ABI=1", "-DNDEBUG", "-fmodule-mapper=/tmp/.xmake0/250126/test-mod/root/gcc15/lib/gcc/x86_64-redhat-linux/15/../../../../lib64/../include/c++/15/bits/std.cc", "-x", "c++", "-o", "build/.objs/test-mod/linux/x86_64/release/root/gcc15/lib/gcc/x86_64-redhat-linux/15/__/__/__/__/lib64/__/include/c++/15/bits/std.cc.o", "/root/gcc15/lib/gcc/x86_64-redhat-linux/15/../../../../lib64/../include/c++/15/bits/std.cc"],
>   "file": "/root/gcc15/lib/gcc/x86_64-redhat-linux/15/../../../../lib64/../include/c++/15/bits/std.cc"
9c9
<   "arguments": ["/usr/lib/llvm-20/bin/clang", "-c", "-Qunused-arguments", "-m64", "-fvisibility=hidden", "-fvisibility-inlines-hidden", "-O3", "-std=c++26", "-stdlib=libc++", "-cxx-isystem/usr/lib/llvm-20/include/c++/v1", "-DNDEBUG", "-fmodule-file=std=build/.gens/test-mod/linux/x86_64/release/rules/bmi/cache/modules/641690a7/std.pcm", "-o", "build/.objs/test-mod/linux/x86_64/release/src/main.cpp.o", "src/main.cpp"],
---
>   "arguments": ["/root/gcc15/bin/g++", "-c", "-m64", "-fvisibility=hidden", "-fvisibility-inlines-hidden", "-O3", "-std=c++26", "-fmodules-ts", "-D_GLIBCXX_USE_CXX11_ABI=1", "-DNDEBUG", "-fmodule-mapper=/tmp/.xmake0/250126/test-mod/src/main.cpp", "-o", "build/.objs/test-mod/linux/x86_64/release/src/main.cpp.o", "src/main.cpp"],

@Issues-translate-bot
Copy link

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


vs project generator does not support modules now.

Doesn't gcc15 also support it? I compiled the module project with gcc15 and generated compile_commands.json, which is not recognized by clangd either.

Image

@waruqi
Copy link
Member

waruqi commented Jan 26, 2025

这个你要问 clangd 了

@Issues-translate-bot
Copy link

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


You have to ask clangd about this

@nqf
Copy link

nqf commented Jan 26, 2025

这个你要问 clangd 了

你看我上面贴了 gcc 和 clang 生成 compile_commands.json, 它们俩 完全不同, xmake project -k compile_commands 生成 compile_commands.json, 是 xmake 自己内部实现的吗? 还是 调用了第三方的东西

@Issues-translate-bot
Copy link

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


You have to ask Clangd

You see, I posted GCC and CLANG to generate compile_commands.json. They are completely different. Still calling the third party's things

@waruqi
Copy link
Member

waruqi commented Jan 26, 2025

这里只负责生成,不同编译器对应的 flags 和实现机制都不同,生成的 compile_commands 结果肯定都不同 ,至于 clangd 是否支持,你要去问 clangd 。。可以自行对比生成的结果。

@Issues-translate-bot
Copy link

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


Here are only responsible for generating. The FLAGS corresponding to different compilers and the implementation mechanism are different. The result generated by the generated compile_commands must be different. As for whether Clangd supports, you have to ask Clangd. Essence You can compare the result of generating.

@nqf
Copy link

nqf commented Jan 26, 2025

这里只负责生成,不同编译器对应的 flags 和实现机制都不同,生成的 compile_commands 结果肯定都不同 ,至于 clangd 是否支持,你要去问 clangd 。。可以自行对比生成的结果。

好,我刚才用cmake + ninja 编译然后生成compile_commands , clangd 也不识别, 看样子是clangd 的问题

@Issues-translate-bot
Copy link

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


This is only responsible for generation. Different compilers have different flags and implementation mechanisms, and the generated compile_commands results are definitely different. As for whether clangd supports it, you have to ask clangd. . You can compare the generated results yourself.

Okay, I just used cmake + ninja to compile and generate compile_commands. Clangd doesn’t recognize it either. It seems to be a problem with clangd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants