xmake-io / xmake

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

tests/project/c++/modules/hello compile_commands.json: Unknown argument -fmodules-ts, -fmodule-mapper #5830

Closed glyh closed 2 days ago

glyh commented 1 week ago

Xmake Version

xmake v2.9.6+20241030, A cross-platform build utility based on Lua

Operating System Version and Architecture

Linux mechrevo 6.11.6-arch1-1 #1 SMP PREEMPT_DYNAMIC Fri, 01 Nov 2024 03:30:41 +0000 x86_64 GNU/Linux

Describe Bug

  1. cd to tests/project/c++/modules/hello
  2. xmake project -k compile_commands --lsp=clangd
  3. open src/main.cpp
  4. got the following in diagnostics image

Expected Behavior

No errors

Project Configuration

I'm using the test case

Additional Information and Error Logs

here's the lsp log for clangd in neovim:

[START][2024-11-15 20:59:00] LSP logging initiated
[ERROR][2024-11-15 20:59:00] .../vim/lsp/rpc.lua:770    "rpc"   "/home/lyh/.local/share/nvim/mason/bin/clangd"  "stderr"    "I[20:59:00.043] clangd version 19.1.0 (https://github.com/llvm/llvm-project a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)\nI[20:59:00.043] Features: linux+grpc\nI[20:59:00.043] PID: 615032\nI[20:59:00.043] Working directory: /home/lyh/PullGround/xmake/tests/projects/c++/modules/hello\nI[20:59:00.043] argv[0]: /home/lyh/.local/share/nvim/mason/bin/clangd\nI[20:59:00.043] Starting LSP over stdin/stdout\n"
[ERROR][2024-11-15 20:59:00] .../vim/lsp/rpc.lua:770    "rpc"   "/home/lyh/.local/share/nvim/mason/bin/clangd"  "stderr"    "I[20:59:00.044] <-- initialize(1)\n"
[ERROR][2024-11-15 20:59:00] .../vim/lsp/rpc.lua:770    "rpc"   "/home/lyh/.local/share/nvim/mason/bin/clangd"  "stderr"    "I[20:59:00.044] --> reply:initialize(1) 0 ms\n"
[ERROR][2024-11-15 20:59:00] .../vim/lsp/rpc.lua:770    "rpc"   "/home/lyh/.local/share/nvim/mason/bin/clangd"  "stderr"    "I[20:59:00.047] <-- initialized\nI[20:59:00.047] <-- textDocument/didOpen\nI[20:59:00.048] Loaded compilation database from /home/lyh/PullGround/xmake/tests/projects/c++/modules/hello/compile_commands.json\nI[20:59:00.048] ASTWorker building file /home/lyh/PullGround/xmake/tests/projects/c++/modules/hello/src/main.cpp version 0 with command \n[/home/lyh/PullGround/xmake/tests/projects/c++/modules/hello]\n/usr/bin/gcc -c -m64 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -std=c++20 -fmodules-ts -D_GLIBCXX_USE_CXX11_ABI=0 -DNDEBUG -fmodule-mapper=/tmp/.xmake1000/241115/hello/src/main.cpp -o build/.objs/hello/linux/x86_64/release/src/main.cpp.o -resource-dir=/home/lyh/.local/share/nvim/mason/packages/clangd/clangd_19.1.0/lib/clang/19 -- /home/lyh/PullGround/xmake/tests/projects/c++/modules/hello/src/main.cpp\nI[20:59:00.048] --> window/workDoneProgress/create(0)\n"
[ERROR][2024-11-15 20:59:00] .../vim/lsp/rpc.lua:770    "rpc"   "/home/lyh/.local/share/nvim/mason/bin/clangd"  "stderr"    "I[20:59:00.048] Enqueueing 2 commands for indexing\n"
[ERROR][2024-11-15 20:59:00] .../vim/lsp/rpc.lua:770    "rpc"   "/home/lyh/.local/share/nvim/mason/bin/clangd"  "stderr"    "I[20:59:00.050] <-- reply(0)\nI[20:59:00.051] --> $/progress\nI[20:59:00.051] --> $/progress\n"
[ERROR][2024-11-15 20:59:00] .../vim/lsp/rpc.lua:770    "rpc"   "/home/lyh/.local/share/nvim/mason/bin/clangd"  "stderr"    "I[20:59:00.052] Built preamble of size 240104 for file /home/lyh/PullGround/xmake/tests/projects/c++/modules/hello/src/main.cpp version 0 in 0.00 seconds\nI[20:59:00.053] --> workspace/semanticTokens/refresh(1)\n"
[ERROR][2024-11-15 20:59:00] .../vim/lsp/rpc.lua:770    "rpc"   "/home/lyh/.local/share/nvim/mason/bin/clangd"  "stderr"    "I[20:59:00.054] Indexing c++20 standard library in the context of /home/lyh/PullGround/xmake/tests/projects/c++/modules/hello/src/main.cpp\nI[20:59:00.054] <-- reply(1)\n"
[ERROR][2024-11-15 20:59:00] .../vim/lsp/rpc.lua:770    "rpc"   "/home/lyh/.local/share/nvim/mason/bin/clangd"  "stderr"    "I[20:59:00.057] --> textDocument/publishDiagnostics\n"
[ERROR][2024-11-15 20:59:01] .../vim/lsp/rpc.lua:770    "rpc"   "/home/lyh/.local/share/nvim/mason/bin/clangd"  "stderr"    "I[20:59:01.394] Indexed c++20 standard library (incomplete due to errors): 16036 symbols, 10692 filtered\n"

I'm using clangd:

clangd version 18.1.8
Features: linux
Platform: x86_64-pc-linux-gnu
waruqi commented 1 week ago

please show your compile_commands.json

glyh commented 1 week ago
[
{
  "directory": "/home/lyh/PullGround/xmake/tests/projects/c++/modules/hello",
  "arguments": ["/sbin/gcc", "-c", "-m64", "-fvisibility=hidden", "-fvisibility-inlines-hidden", "-O3", "-std=c++20", "-fmodules-ts", "-D_GLIBCXX_USE_CXX11_ABI=0", "-DNDEBUG", "-fmodule-mapper=/tmp/.xmake1000/241115/hello/src/hello.mpp", "-x", "c++", "-o", "build/.objs/hello/linux/x86_64/release/src/hello.mpp.o", "src/hello.mpp"],
  "file": "src/hello.mpp"
},
{
  "directory": "/home/lyh/PullGround/xmake/tests/projects/c++/modules/hello",
  "arguments": ["/sbin/gcc", "-c", "-m64", "-fvisibility=hidden", "-fvisibility-inlines-hidden", "-O3", "-std=c++20", "-fmodules-ts", "-D_GLIBCXX_USE_CXX11_ABI=0", "-DNDEBUG", "-fmodule-mapper=/tmp/.xmake1000/241115/hello/src/main.cpp", "-o", "build/.objs/hello/linux/x86_64/release/src/main.cpp.o", "src/main.cpp"],
  "file": "src/main.cpp"
}]
waruqi commented 1 week ago

it will use gcc by default, if you installed gcc.

you should call xmake f --toolchain=clang to switch to clang