Awesome Open Source
Awesome Open Source


Steps to build the Linux kernel using Clang

  1. Start with an empty dir

    git clone
    cd clang-kernel-build
    export WORLD=`pwd`
  2. Install Clang from Chromium:

    cd $WORLD
    # Instruction taken from
    mkdir TMP_CLANG
    cd TMP_CLANG
    git clone
    cd ..

(To update Clang later on, do (cd TMP_CLANG/clang ; git pull) and run again.)

  1. Clone the Linux source tree

    cd $WORLD
    git clone git://
    cd linux-stable
    git reset --hard v5.2-rc4
  2. Configure and build the kernel

    cd $WORLD
    export CLANG_PATH=`pwd`/third_party/llvm-build/Release+Asserts/bin/
    cd linux-stable
    make CC=$CLANG_PATH/clang defconfig
    make CC=$CLANG_PATH/clang -j64 2>&1 | tee build.log
  3. Set up the VM:

    cd $WORLD
    # requires sudo
  4. Run the VM

    cd $WORLD
    # in a separate console:
    ssh -i ssh/id_rsa -p 10023 [email protected]


# Start the VM before running GDB
gdb -x gdb.script
(gdb) br dump_stack


# Perform these steps instead of Step 4 above.
cd $WORLD/linux-stable
make CC=$CLANG_PATH/clang defconfig
make CC=`pwd`/../ 2>&1 | tee build.log

The handy lets you add arguments to Clang invocation, measure compilation times or fall back to GCC for certain files.

Also, get yourself a log symbolizer:

Alternatives To Clang Kernel Build
Select To Compare

Alternative Project Comparisons
Related Awesome Lists
Top Programming Languages
Top Projects

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Python (819,471
Kernel (21,797
Step (21,708
Vm (14,501
Clang (3,781
Chromium (2,715
Linux Kernel (1,751