Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
swhoro opened this issue Jan 20, 2024 · 6 comments
Open

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

swhoro opened this issue Jan 20, 2024 · 6 comments
Labels

Comments

@swhoro
Copy link

swhoro commented Jan 20, 2024

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 swhoro added the bug label Jan 20, 2024
@waruqi
Copy link
Member

waruqi commented Jan 20, 2024

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

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

@swhoro
Copy link
Author

swhoro commented Jan 21, 2024

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

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

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

@swhoro
Copy link
Author

swhoro commented Jan 22, 2024

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

@xq114
Copy link
Contributor

xq114 commented Jan 22, 2024

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

@star-hengxing
Copy link
Contributor

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

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

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

@swhoro
Copy link
Author

swhoro commented Jan 22, 2024

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants