clangd / vscode-clangd

Visual Studio Code extension for clangd
https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.vscode-clangd
MIT License
617 stars 100 forks source link

clangd not support ccbin when CUDA-based programming #458

Open davidxiaozhi opened 1 year ago

davidxiaozhi commented 1 year ago

When CUDA-based programming is performed, the clangd plug-in displays a message indicating that ccbin is not supported. The error message is as follows

image

json文件如下

[{
  "directory": "/mae_pat/zhipeng.li/develop/project/git_projects/cuda-trick",
  "arguments": ["/usr/local/cuda/bin/nvcc", "-c", "-ccbin=clang", "-Xcompiler", "-fPIE", "-O3", "-I/App/conda/envs/conda_xmake/include", "-I/usr/local/cuda/Common", "-I/usr/local/cuda/include", "-allow-unsupported-compiler", "-m64", "-rdc=true", "-gencode", "arch=compute_70,code=sm_70", "-gencode", "arch=compute_70,code=compute_70", "-o", "build/.objs/sgemm/linux/x86_64/release/src/cuc/02/sgemm/sgemm.cu.o", "src/cuc/02/sgemm/sgemm.cu"],
  "file": "src/cuc/02/sgemm/sgemm.cu"
}]

the log

V[19:00:46.089] <<< {"id":1874,"jsonrpc":"2.0","method":"textDocument/hover","params":{"position":{"character":55,"line":23},"textDocument":{"uri":"file:///home/z.li/develop/project/git_projects/cuda-trick/src/cuc/02/sgemm/sgemm.cu"}}}

I[19:00:46.089] <-- textDocument/hover(1874)
V[19:00:46.090] ASTWorker running Hover on version 43 of /home/z.li/develop/project/git_projects/cuda-trick/src/cuc/02/sgemm/sgemm.cu
I[19:00:46.091] --> reply:textDocument/hover(1874) 1 ms
V[19:00:46.091] >>> {"id":1874,"jsonrpc":"2.0","result":null}

I[19:00:46.091] --> textDocument/clangd.fileStatus
V[19:00:46.091] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///home/z.li/develop/project/git_projects/cuda-trick/src/cuc/02/sgemm/sgemm.cu"}}

V[19:00:50.433] <<< {"id":1875,"jsonrpc":"2.0","method":"textDocument/hover","params":{"position":{"character":1,"line":1},"textDocument":{"uri":"file:///home/z.li/develop/project/git_projects/cuda-trick/src/cuc/02/sgemm/sgemm.cu"}}}

I[19:00:50.433] <-- textDocument/hover(1875)
V[19:00:50.433] ASTWorker running Hover on version 43 of /home/z.li/develop/project/git_projects/cuda-trick/src/cuc/02/sgemm/sgemm.cu
I[19:00:50.433] --> reply:textDocument/hover(1875) 0 ms
V[19:00:50.433] >>> {"id":1875,"jsonrpc":"2.0","result":{"contents":{"kind":"markdown","value":"### `cuda_runtime.h`  \n\n---\n```\n/App/conda/envs/conda_xmake/include/cuda_runtime.h\n```"}}}

I[19:00:50.433] --> textDocument/clangd.fileStatus
V[19:00:50.433] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///home/z.li/develop/project/git_projects/cuda-trick/src/cuc/02/sgemm/sgemm.cu"}}

V[19:00:51.487] <<< {"id":1876,"jsonrpc":"2.0","method":"textDocument/hover","params":{"position":{"character":0,"line":0},"textDocument":{"uri":"file:///home/z.li/develop/project/git_projects/cuda-trick/src/cuc/02/sgemm/sgemm.cu"}}}

I[19:00:51.487] <-- textDocument/hover(1876)
V[19:00:51.488] ASTWorker running Hover on version 43 of /home/z.li/develop/project/git_projects/cuda-trick/src/cuc/02/sgemm/sgemm.cu
I[19:00:51.488] --> reply:textDocument/hover(1876) 1 ms
V[19:00:51.488] >>> {"id":1876,"jsonrpc":"2.0","result":null}

I[19:00:51.488] --> textDocument/clangd.fileStatus
V[19:00:51.489] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///home/z.li/develop/project/git_projects/cuda-trick/src/cuc/02/sgemm/sgemm.cu"}}

V[19:00:56.168] <<< {"id":1877,"jsonrpc":"2.0","method":"textDocument/hover","params":{"position":{"character":0,"line":0},"textDocument":{"uri":"file:///home/z.li/develop/project/git_projects/cuda-trick/src/cuc/02/sgemm/sgemm.cu"}}}

I[19:00:56.168] <-- textDocument/hover(1877)
V[19:00:56.168] ASTWorker running Hover on version 43 of /home/z.li/develop/project/git_projects/cuda-trick/src/cuc/02/sgemm/sgemm.cu
I[19:00:56.168] --> reply:textDocument/hover(1877) 0 ms
V[19:00:56.169] >>> {"id":1877,"jsonrpc":"2.0","result":null}

I[19:00:56.169] --> textDocument/clangd.fileStatus
V[19:00:56.169] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///home/z.li/develop/project/git_projects/cuda-trick/src/cuc/02/sgemm/sgemm.cu"}}

V[19:00:56.327] <<< {"id":1878,"jsonrpc":"2.0","method":"textDocument/codeAction","params":{"context":{"diagnostics":[{"code":"drv_unknown_argument","message":"Unknown argument: '-ccbin=clang'","range":{"end":{"character":0,"line":0},"start":{"character":0,"line":0}},"relatedInformation":[],"severity":1,"source":"clang"},{"code":"drv_unknown_argument","message":"Unknown argument: '-rdc=true'","range":{"end":{"character":0,"line":0},"start":{"character":0,"line":0}},"relatedInformation":[],"severity":1,"source":"clang"},{"code":"drv_unknown_argument","message":"Unknown argument: '-gencode'","range":{"end":{"character":0,"line":0},"start":{"character":0,"line":0}},"relatedInformation":[],"severity":1,"source":"clang"}],"only":["quickfix"],"triggerKind":1},"range":{"end":{"character":0,"line":0},"start":{"character":0,"line":0}},"textDocument":{"uri":"file:///home/z.li/develop/project/git_projects/cuda-trick/src/cuc/02/sgemm/sgemm.cu"}}}

I[19:00:56.327] <-- textDocument/codeAction(1878)
V[19:00:56.327] ASTWorker running EnumerateTweaks on version 43 of /home/z.li/develop/project/git_projects/cuda-trick/src/cuc/02/sgemm/sgemm.cu
I[19:00:56.327] --> reply:textDocument/codeAction(1878) 0 ms
V[19:00:56.327] >>> {"id":1878,"jsonrpc":"2.0","result":[]}

I[19:00:56.327] --> textDocument/clangd.fileStatus
V[19:00:56.328] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///home/z.li/develop/project/git_projects/cuda-trick/src/cuc/02/sgemm/sgemm.cu"}}
HighCommander4 commented 1 year ago

What is the meaning of these flags?

Can they just be ignored for clangd's purposes? If so, you can instruct clangd to ignore it by creating a config file (.clangd) with:

CompileFlags:
  Remove: [-ccbin=*,-rdc=*,-gencode]
davidxiaozhi commented 1 year ago

What is the meaning of these flags?

Can they just be ignored for clangd's purposes? If so, you can instruct clangd to ignore it by creating a config file (.clangd) with:

CompileFlags:
  Remove: [-ccbin=*,-rdc=*,-gencode]

@HighCommander4 this is cuda need

davidxiaozhi commented 1 year ago

"arguments": ["/usr/local/cuda/bin/nvcc", "-c", "-ccbin=clang", "-Xcompiler", "-fPIE", "-O3", "-I/App/conda/envs/conda_xmake/include", "-I/usr/local/cuda/Common", "-I/usr/local/cuda/include", "-allow-unsupported-compiler", "-m64", "-rdc=true", "-gencode", "arch=compute_70,code=sm_70", "-gencode", "arch=compute_70,code=compute_70", "-o", "build/.objs/sgemm/linux/x86_64/release/src/cuc/02/sgemm/sgemm.cu.o", "src/cuc/02/sgemm/sgemm.cu"],

davidxiaozhi commented 1 year ago

@HighCommander4 Is there a solution to this problem

HighCommander4 commented 1 year ago

Have you tried removing the flags as suggested in this comment?

davidxiaozhi commented 1 year ago

@HighCommander4 I can't remove these flags because cuda c++ programs won't compile properly from the command line,i need it

HighCommander4 commented 1 year ago

you can instruct clangd to ignore it by creating a config file (.clangd) with:

CompileFlags:
  Remove: [-ccbin=*,-rdc=*,-gencode]

^ This will only remove the flags from the command line that clangd sees. Your actual build will still use the flags.

davidxiaozhi commented 1 year ago

@HighCommander4 The .clangd file should be stored in the directory of the engineering root directory in vscode project or below the .vscode directory

HighCommander4 commented 1 year ago

@HighCommander4 The .clangd file should be stored in the directory of the engineering root directory in vscode project or below the .vscode directory

It applies to files in the directory tree of the directory containing the .clangd file, so it should go into the project root.