Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ManuLinares/c63b4eeaba4438b893b99dff8e8a468c to your computer and use it in GitHub Desktop.
Save ManuLinares/c63b4eeaba4438b893b99dff8e8a468c to your computer and use it in GitHub Desktop.
Configure vscode for linux kernel source code
  1. Disable or uninstall the official C/C++ plugin.
  2. Install the clangd plugin.
  3. Build the kernel with clang:
/path/to/kernel_source$ make CC=clang defconfig
/path/to/kernel_source$ make CC=clang -j16
  1. Generate the compile_commands.json:
/path/to/kernel_source$ python ./scripts/clang-tools/gen_compile_commands.py

If no error occures, you will find compile_commands.json in /path/to/kernel_source/.

  1. Configure the clangd plugin with the following parameters:

image.png

  1. Open any C file in kernel source and enjoy it :)

image.png

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment