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

update compile_commands generation to be compatible with C++20 modules (bug?) #2114

Closed
metasprite opened this issue Mar 1, 2022 · 4 comments
Milestone

Comments

@metasprite
Copy link

Is your feature request related to a problem? Please describe.

The compile_commands.json generated by xmake doesn't help language servers like clangd find C++20 module files. My project with C++20 modules compiles fine, but clangd can't find imported modules, so it complains.

Describe the solution you'd like

Extend compile_commands.json generation to tell the compiler where modules can be found.
For clang on linux, adding -fprebuilt-module-path=build/.gens/test/linux/x86_64/release/rules/modules/cache to the compile_commands.json generated by xmake works. clangd behaves as expected after doing this.

I see how this is implemented in build_modules/clang.lua:

target:add("cxxflags", "-fimplicit-modules", "-fimplicit-module-maps", "-fprebuilt-module-path=" .. cachedir, {force = true})

I'm just not sure how to make the compile_commands.json generation code use this...

Describe alternatives you've considered

I wasn't sure whether this was a bug report or feature request, so I don't see another way to fix this problem.

@waruqi
Copy link
Member

waruqi commented Mar 1, 2022

not supported yet, see #1167

@waruqi
Copy link
Member

waruqi commented Aug 15, 2022

we have supported it, you can try cxxmodules branch. #2641

However, vscode and other editor/ide should not yet support complie_commands with c++modules.

@waruqi
Copy link
Member

waruqi commented Aug 15, 2022

but vscode and other some ide maybe still not support compile_commands.json with c++modules.

microsoft/vscode-cpptools#6302 (comment)

@waruqi waruqi added this to the v2.7.1 milestone Aug 15, 2022
@waruqi
Copy link
Member

waruqi commented Aug 16, 2022

I have merged it now.

@waruqi waruqi closed this as completed Aug 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants