CLion could index linux kernel source code?


Hi there,

I'm trying to do some thing with the linux kernel source code, especially the virtual file system (VFS). VFS codes twist lots of kernel structures, macros, and other libraries, so I want to use CLion to helm me index them.

I just import the whole linux source code directory and let CLion index those code.

The problem is that, CLion could hardly index linux kernel source code properly, and the navigation to structure definitions is almost not usable...

Should I configure something to index the linux kernel source code?

Appreciate your help :)

By the way, CLion works with macOS.


The CMakeLists.txt here seems to work more or less, at least for Arch. I can navigate everything, but get some false positives for undefineds.




The approach I use to spelunk the linux kernel via clion is:

* create a `compile_commands.json` for the kernel using an intercepted build
* use a ruby script to convert `compile_commands.json` into an clion friendly `CMakeLists.txt`

This allows for both code navigation and also a reasonable editing experience.

See for more details



I followed the official guide at

The tool that worked best for me was bear, which I installed via sudo apt install bear

The rest of the kernel build instructions I used were from 

I was able to easily load the new Compilation Database project. Indexing took a while, but that's to be expected.


We really need this feature, and I wish to see that we can use CLion to develop linux kernel module natively some day!



I was using CLion with the Linux Kernel recently and this post helped me to create the compilation database from the link Marthinwurer posted.

But I learned that there is a script in the Linux Kernel to create the compilation database "scripts/clang-tools/"

I am not sure about its accuracy yet. I have been using bear, and it was working great for me but just wanted to share this in case someone else come to the same post.

One more note, since I was building the Kernel quite often CLion was reloading the compilation database after every build which takes quite a long time even in my 12 core CPU AMD Ryzen 3900x so I had to disable that.


Hi all!

Now CLion supports Makefile projects - But opening Linux Kernel in CLion requires some additional settings. Feel free to drop a message to clion-support at if you're interested.


Please sign in to leave a comment.