[llvm-dev] Properly configuring vscode for LLVM development

Kai Plociennik via llvm-dev llvm-dev at lists.llvm.org
Mon Dec 6 00:13:46 PST 2021


Hello Nicolas,

thanks for your email, I also use VS Code on Linux (Ubuntu) for LLVM 
development and had trouble when setting up everything correctly. In the 
end, I did not use the CMake tools extension but wrote a bash script for 
configuring LLVM (calling cmake with the necessary options) and one for 
building and installing. Then I defined a run task in VS Code which 
calls the latter. Since GDB startup is really slow, I added 
"gdb-add-index" for libLLVM and libclang, since then startup time is 
acceptable.

I also did some changes to my c_cpp_properties.json and further changes 
to tasks.json and launch.json to get decent debugger experience, e.g. 
skipping standard library files and have nice compiler error reporting 
with clickable links in the VS code console.

When I read in the previous comments to your post about pretty printer 
setup, I remembered that I also had a hard time to get that work. The 
solution for me was to add

source 
${env:SPU_LLVM_INSTALL_DIR}/../llvm/utils/gdb-scripts/prettyprinters.py

as setup command to my run configuration.

Maybe using LLDB would have been better, but I have to admit that 
compared to my previous development experience with Visual Studio and C# 
I had so much things to configure and do so much research to get things 
working that I finally was glad after weeks to get everything running 
and did not want to experiment any further.

Hence, I think maybe it would be a good idea to help developes have a 
quick start by providing condensed, ready to use information and scripts 
on the LLVM official website? I think this might help developers.

If you want, I can send you my configuration files if this helps.

Best regards,

Kai


On 01.12.21 15:40, Nicolas Vasilache via llvm-dev wrote:
> Hi everyone,
> 
> I am trying to use vscode for cmake development and so far I have been 
> only moderately successful.
> 
> I think I have most of the things right (including clangd and 
> autocomplete) but I still have a few issues:
> 
> 1. I am not able to configure vscode + cmake such that the project only 
> rebuilds incrementally. As a consequence a tiny change retriggers 
> compilation of the whole thing. Since I configured ccache I get close to 
> 100% hits but this still takes ~1-2 minutes instead of a few seconds by 
> using cmake -Ninja on the command line.
> (I think) I have been careful to not trigger spurious stuff (e.g.)
> 
>      "cmake.generator": "Ninja",
>      "cmake.clearOutputBeforeBuild": false,
>      "cmake.configureOnEdit": false,
>      "cmake.exportCompileCommandsFile": false,
>      "cmake.autoSelectActiveFolder": false,
>      "cmake.useCMakePresets": "never",
> 
> but to no avail ..
> 
> The other 2 may be related to my not investing the time to dig further 
> until I have a proper solution to point 1.
> 
> 2. I am not sure how to set the tests for easily pinpointing particular 
> errors, running a single test through the IDE and fixing it inline. 
> Maybe we are spoiled but our internal Google setup makes it very easy to 
> do such things.
> 
> 3. I am not sure how to set up the integrated debugger to have a clicky 
> debugging nice setup. I have some old recollections circa VC++ 6.0 ish 
> where these things were quite nice to navigate and I am hoping to
> 
> Some additional details that may be of relevanceL
> A. I am on a Linux boc (and running through a remote connection from my 
> mac laptop).
> B. I am using a third-party project and I am making use of some MLIR 
> side features to build stuff
> together with LLVM. In particular:
>      "cmake.sourceDirectory": "${workspaceFolder}/../llvm-project/llvm",
> Note that this is not a problem in my CLI-only setup where things behave 
> like I expect them
> 
> Does anyone know of a good setup I could replicate?
> 
> If you're replying to this, please +1 me in the conversation because 
> email is hard.
> 
> Thanks much!
> 
> -- 
> N
> 
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
> 

-- 
Dr. Kai Plociennik
Fraunhofer-Institut für Techno- und Wirtschaftsmathematik ITWM
Competence Center High Performance Computing
Fraunhofer-Platz 1
67663 Kaiserslautern
Tel: +49 (0)631 31600 4081
mail: kai.plociennik at itwm.fraunhofer.de
www.itwm.fraunhofer.de


More information about the llvm-dev mailing list