[clang-tools-extra] [clangd] [C++20] [Modules] Introduce initial support for C++20 Modules (PR #66462)
Arthur Laurent via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 15 07:10:59 PDT 2024
Arthapz wrote:
> Given we are going to branch clang19 in the end of the month, it is highly possible that we can't land sufficient patches before that. Note that even if we land this patch before that, the support of modules in clangd is expected to very slow for real world applications. See the summary of the patch for details. So we may miss the train again.
>
> To mitigate this, I opened https://github.com/ChuanqiXu9/clangd-for-modules. This contains the following patches to make the clangd sufficient to work with modules in practical workloads. Feedbacks and contributions are welcomed. Hope this can be helpful for people who are waiting this.
i tried this (and modified my xmake a little to gen the module_map.txt, https://github.com/Arthapz/xmake/tree/clangd-module-map), i did get some of LSP support
![image](https://github.com/user-attachments/assets/dfd1bba7-1221-4bc4-b3b8-02537b210446)
but the logs are full of errors like
```
[ERROR][2024-07-15 16:03:31] .../vim/lsp/rpc.lua:770 "rpc" "/opt/llvm-git/bin/clangd" "stderr" "E[16:03:31.557] Scanning modules dependencies for build/../modules/stormkit/Core/Utils/Stacktrac
e.mpp failed: error: unable to handle compilation, expected exactly one compiler job in '/opt/llvm-git/bin/clang -c -Qunused-arguments -m64 -g -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Wpe
dantic -Wextra -ffp-model=fast -O3 -mfma -mfpu=neon -mavx -mavx2 -msse -msse2 -msse3 -mssse3 -msse4.2 -stdlib=libc++ -cxx-isystem/opt/llvm-git/include/c++/v1 -Ibuild/.gens/include -I/home/arthapz/Repos
/StormKit/include -D_GLIBCXX_DEBUG -DSTORMKIT_BUILD -DSTORMKIT_BUILD_DEBUG -DSTORMKIT_ASSERT=1 -DSTORMKIT_STATIC -DBOOST_STACKTRACE_USE_ADDR2LINE -DBOOST_STACKTRACE_LINK -isystem /home/arthapz/.xmake/p
ackages/g/glm/1.0.1/e8b755c3b7d04ec88316715dbafe4cb6/include -isystem /home/arthapz/Repos/StormKit/build/.packages/f/frozen/latest/9a1f279102e34dbe91527197132695fd/include -isystem /home/arthapz/.xmake
/packages/u/unordered_dense/v4.4.0/9226fe6ee99949838863899207aec25e/include -isystem /home/arthapz/.xmake/packages/m/magic_enum/v0.9.5/c9d129e2b37f49a5897d1ef2a130e7c3/include -isystem /home/arthapz/.x
make/packages/t/tl_function_ref/v1.0.0/db82eb7eb9e64a40a64595c6319b711b/include -isystem /home/arthapz/.xmake/packages/b/boost/1.84.0/1be587ae28144669827487e346d4bc81/include -isystem /home/arthapz/.xm
ake/packages/l/libbacktrace/v1.0/5ff2e6e6560147f597b99dfa2bbea685/include -Wno-experimental-header-units -fcolor-diagnostics -fexperimental-library -fstrict-aliasing -Wstrict-aliasing -Wno-missing-fiel
d-initializers -Wno-include-angled-in-module-purview -Wno-unknown-attributes -Wno-deprecated-declarations -ggdb3 -Wno-language-extension-token -fmodule-file=std=build/.gens/stormkit-core/linux/x86_64/d
ebug/rules/bmi/cache/modules/500a1880/std.pcm -fmodule-file=stormkit.Core:Parallelism.ThreadUtils=build/.gens/stormkit-core/linux/x86_64/debug/rules/bmi/cache/modules/500a1880/stormkit.Core-Parallelism
.ThreadUtils.pcm --precompile -- build/../modules/stormkit/Core/Utils/Stacktrace.mpp'\n\nI[16:03:31.557] Recorded module unit path build/../modules/stormkit/Core/Utils/Stacktrace.mpp doesn't declare mo
dule stormkit.Core:Utils.Stacktrace\n"
[ERROR][2024-07-15 16:03:31] .../vim/lsp/rpc.lua:770 "rpc" "/opt/llvm-git/bin/clangd" "stderr" "I[16:03:31.557] Recorded module unit path build/../opt/llvm-git/bin/../lib/../share/libc++/v1/st
d.compat.cppm for module std.compat not existed.\n"
```
i used these parameters for clangd
```
"--offset-encoding=utf-16", "--header-insertion=never", "--experimental-modules-support", "--compile-commands-dir=.vscode", "--modules-map-path=build/clangd_mapper.txt"
```
https://github.com/llvm/llvm-project/pull/66462
More information about the cfe-commits
mailing list