xmake-vscode icon indicating copy to clipboard operation
xmake-vscode copied to clipboard

cuda 项目生成的compile_commands貌似无法正常提示

Open swhoro opened this issue 1 year ago • 6 comments

Xmake Version

v2.8.6+master.8545a9301

Operating System Version and Architecture

windows 11 23h2 22631.3007

Describe Bug

直接使用生成的compile_commands文件会报如下错误: image 生成的compile_commands文件: image 怀疑是 -I 参数和后面的目录应该分开写,但是分开写后会报如下错误: image

Expected Behavior

vscode不报错误

Project Configuration

add_rules("mode.debug", "mode.release")

target("cuda-learning")
    set_kind("binary")
    add_files("src/*.cu")

    -- generate SASS code for SM architecture of current host
    add_cugencodes("native")

    -- generate PTX code for the virtual architecture to guarantee compatibility
    add_cugencodes("compute_75")

Additional Information and Error Logs

none

swhoro avatar Jan 20 '24 14:01 swhoro

compile_commands 为啥会在 build 下。。vscode-xmake 插件默认生成的 compile_commands 应该在 .vscode 目录下。。

另外,光生成 compile_commands.json 不够,还得配置 cpptools/clangd ,去绑定 compile_commands.json 才能生效,确定绑关联对了路径?

waruqi avatar Jan 20 '24 15:01 waruqi

compile_commands 为啥会在 build 下。。vscode-xmake 插件默认生成的 compile_commands 应该在 .vscode 目录下。。

另外,光生成 compile_commands.json 不够,还得配置 cpptools/clangd ,去绑定 compile_commands.json 才能生效,确定绑关联对了路径?

个人习惯,已经配置好了,cpptools和xmake的compile_commands都放在build下 image

swhoro avatar Jan 21 '24 04:01 swhoro

又换clangd试了一下,指定clangd的--cuda-path,但是不使用compile_commands,一切正常 如果指定--cuda-path,同时使用compile_commands,会报很多错误: image

swhoro avatar Jan 22 '24 08:01 swhoro

clangd插件支持cuda吗?cpptools是可以正常提示cuda的,clangd我也没成功过,后面放弃了

xq114 avatar Jan 22 '24 10:01 xq114

支持的,需要 compile_commands.json + --cuda-path .clangd 文件要这样写:

If:
    PathMatch: .*\.cu
CompileFlags:
    Add:
    [
        "--cuda-path=<CUDA_PATH>"
    ]

除此之外文件第一行会依然会报一些错,比如 Unknown argument: '-rdc=true',但不影响写代码。 这些 nvcc 的参数只能等 clangd 去修复了。

star-hengxing avatar Jan 22 '24 12:01 star-hengxing

clangd插件支持cuda吗?cpptools是可以正常提示cuda的,clangd我也没成功过,后面放弃了

我用cpptools的话compile_commands也会报错: image 但是把compile_commands删了的话cpptools就正常了

swhoro avatar Jan 22 '24 12:01 swhoro