xmake-io / xmake

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

clang c++20 modules missing information in compile_commands.json exported #1167

Closed Shuenhoy closed 2 years ago

Shuenhoy commented 3 years ago

Note: If you use the fuzzy expressions such as 'can't use/no effect/problem/error', but don't give any relevant auxiliary information according to the template below, this issue will be not replied.

Describe the bug

In current version, the compile_commands.json file generated with xmake when using clang11 c++20 modules lost the options "-fmodule-file=xxx.pcm, which would make clangd cannot find the module I am importing.

Expected behavior

The compile_commands.json should add the option mentioned.

Error output

If applicable, please add verbose the errors output to help us analyze your problem.

If it is a xmake related compilation problem, please add the -v -D parameter and give the detailed compilation output information.

Related Environment

Please provide compiling and running environment information:

Additional context

Add any other context about the problem here.

waruqi commented 3 years ago

Yes, it is not currently supported, maybe I will consider supporting it on 2.5.2

related issue. https://github.com/xmake-io/xmake/issues/1148

Shuenhoy commented 3 years ago

FYI, I just found probably a simpler way to get things work. Current module.mpp would generate module.mpp.o.pcm, if we make the naming pattern to module.pcm, then we can just add a -fprebuilt-module-path=xx instead of adding module-file for each pcm file.


UPDATE: there is a drawback. The file name must be exactly the same with the module name, or clangd still cannot found. The previous way should be better.

waruqi commented 3 years ago

ok, thanks. I will improve c++20 modules on 2.5.2. In addition, I will also support c++20 modules for gcc.

waruqi commented 2 years ago

we have supported it, you can try cxxmodules branch. https://github.com/xmake-io/xmake/pull/2641

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

waruqi commented 2 years ago

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

https://github.com/microsoft/vscode-cpptools/issues/6302#issuecomment-1215554637

Shuenhoy commented 2 years ago

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

I have made some try with compile_commands.json manually generated, with clangd extension and clang, and it works in general. vscode-cpptools extension still does not work as your reference, nor does clangd with gcc.

However, I have to admit that the whole module thing is still not useable with gcc and clang. There are just too many ICEs. The compiler just crashes for the simple codes. Really hope the situation would change next year.

waruqi commented 2 years ago

yes, and I have merged it now.