xmake-io / xmake

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

使用 compile_commands.json 时报错 Unknown argument: '-sdk' #3286

Closed Parallel-Paradox closed 1 year ago

Parallel-Paradox commented 1 year ago

Xmake 版本

xmake v2.7.5

操作系统版本和架构

macOS Ventura 13.1

描述问题

在 vscode 中使用 clangd 插件作为跳转环境, 使用 xmake project -k compile_commands 生成 compile_commands.json 文件后, 虽然不影响 build 和 run, 但 clangd 会在头文件开始处报错 Unknown argument: '-sdk'.

观察生成的 compile_commands.json 文件中部分表项:

{
  "directory": "...",
  "arguments": ["/usr/bin/xcrun", “-sdk”, "macosx" , "clang", "-c", ...],
  "file": "..."
},

将 arguments 中的 "-sdk", "macosx" 删除后报错提示消失.

期待的结果

生成 arguments 时是否不应有 “-sdk” 参数?

工程配置

mvp.zip

附加信息和错误日志

image

waruqi commented 1 year ago

maybe you should open an issue to clangd

Parallel-Paradox commented 1 year ago

I try to revert the arguments combination change in #3159 and this error disappear.

"arguments": ["/usr/bin/xcrun -sdk macosx clang",

Looks like there is a conflict between CLion and clangd.

waruqi commented 1 year ago

我改进了下,转成全路径了,再试试,xmake update -s dev