Googlers: clangd has been installed on your glinux by default, just use
Alternative: download clangd from the official Releases page.
Note: clangd 10.0.0 does not work with Chromium; use one of the more recent pre-release versions of 11 or later on the Releases page.
If you prefer to build clangd locally, use the following command to build from LLVM source, and you will get the binary at
tools/clang/scripts/build_clang_tools_extra.py --fetch out/Release clangd
gn gen out/Release
tools/clang/scripts/generate_compdb.py -p out/Release > compile_commands.json
Note: the compilation database is not regenerated automatically. You need to regenerate it manually whenever build rules change, e.g., when you have new files checked in or when you sync to head.
If using Windows PowerShell, use the following command instead to set the output's encoding to UTF-8 (otherwise Clangd will hit “YAML:1:4: error: Got empty plain scalar” while parsing it).
tools/clang/scripts/generate_compdb.py -p out/Release | out-file -encoding utf8 compile_commands.json
ninja -C out/Release chrome
By default, clangd only knows the files you are currently editing. To provide project-wide code navigations (e.g. find references), clangd neesds a project-wide index.
You can pass an experimental
--background-index command line argument to clangd, clangd will incrementally build an index of Chromium in the background. Note: the first index time may take hours (for reference, it took 2~3 hours on a 48-core, 64GB machine).
A full index of Chromium (including v8, blink) takes ~550 MB disk space and ~2.7 GB memory in clangd.
If you have any questions, reach out to firstname.lastname@example.org.