1

I want to use sublime text as my c++ editor.

I added LSP-clangd in the editor. I generate some compile_commands.json and clangd works on almost every files in my project but not with cuda files.

I saw in clangd FAQ that we must ensure :

  1. that our editor plugin is enabling clangd when CUDA files are open (e.g. enabling for extension *.cu). I didn't found any parameters in LSP-clangd settings to add some file extensions.
  2. make sure that clangd understands these are CUDA files (e.g. by extension *.cu or adding the clang flag -xcuda). Where should I add these flags? In compile_commands.json?
  3. set the path to your cuda installation if it isn’t detected, by adding the clang flag --cuda-path=... Where should I specify this path? I tried using command clang --cuda-path=my/cuda/path but it returns me clang: error; no input files

Have you any idea to solve one of these 3 problems ? or did someone suceed to use cuda with clangd in sublime text ?

lufydad
  • 225
  • 2
  • 8
  • For #2 and #3, I think the best place to specify both the `-xcuda` flag (note: I believe this is only needed if your CUDA files _don't_ have a CUDA-specific extension such as `*.cu`), and the `--cuda-path` flag is a [clangd config file](https://clangd.llvm.org/config.html) using `CompileFlags:` `Add:`. These flags will be added to the flags from `compile_commands.json`. – HighCommander4 Feb 16 '23 at 21:03

1 Answers1

1

Thanks to @HighCommander4, I solve this issue by adding a clang config file to my project. Moreover, I found an issue on clangd github that shares a similar problem.

Here is the .clangd configuration file that I use for my project :

CompileFlags:
  Add:
    - --cuda-path=C://Program Files//NVIDIA GPU Computing Toolkit//CUDA//v12.1
    - -LC://Program Files//NVIDIA GPU Computing Toolkit//CUDA//v12.1//lib
    - -IC://Program Files//NVIDIA GPU Computing Toolkit//CUDA//v12.1//include
lufydad
  • 225
  • 2
  • 8