Nexus 7

Cyanogenmod and LLVMLinux

This guide describes how to replace the default Linux Kernel in Nexus 7 in the Cyanogenmod for one built with LLVM/Clang using the LLVMLinux project infrastructure. It is high recommended to be familiar with Cyanogenmod or AOSP build system.

Basically the Cyanogenmod is patched to use a prebuilt kernel instead of building one on demand. The LLVMLinux is used to build the prebuilt kernel. Afterwards this kernel is copied to Cyanogenmod build system and the process follows as a normal Cyanogenmod build.

The procedure described here can be adapted to other devices at Cyanogenmod.

Building the kernel

Clone the LLVMLinux project.

git clone ~/llvmlinux

Enter in the Nexus 7 target directory.

cd ~/llvmlinux/targets/nexus7

Install the LLVMLinux project dependencies.

make build-dep

Copy the configuration for the first checkpoint (well known working state).

cp checkpoint/

Checkout the proper LLVMLinux state.

git checkout 6f941c4a48a958417c0dae1e7a92131bc7bee34f

Sync and fetch all the external projects needed.

make sync-all

Build the Nexus 7 kernel.

make all

Copy the Nexus 7 kernel file.

cp ~/llvmlinux/targets/nexus7/src/android_kernel_nexus7/arch/arm/boot/zImage ~/llvmlinux/targets/nexus7/kernel

Patch the Cyanogenmod

Follow the steps at Cyanogenmod build for grouper up to Get prebuilt_apps stop and follow the instructions below.

Enter in the Nexus 7 directory.

cd ~/android/device/asus/grouper

Apply the following patch which replaces the kernel build instructions with the prebuilt kernel.

diff --git a/ b/
index d077647..aa6f134 100644
--- a/
+++ b/
@@ -83,6 +83,3 @@ BOARD_USES_GROUPER_MODULES := true
 # Required for CWM
-TARGET_KERNEL_SOURCE := kernel/asus/grouper
-TARGET_KERNEL_CONFIG := cyanogenmod_grouper_defconfig
diff --git a/ b/
index dd7aaa4..f38056b 100644
--- a/
+++ b/
@@ -14,10 +14,14 @@
 # limitations under the License.
+TARGET_PREBUILT_KERNEL := device/asus/grouper/kernel
+    $(LOCAL_KERNEL):kernel \
 # the actual meat of the device-specific product definition

Copy the prebuilt kernel to the Nexus 7 directory.

cp ~/llvmlinux/targets/nexus7/kernel ~/android/device/asus/grouper/kernel

Continue the Cyanogenmod build. At the end you will have almost the same image as a normal Cyanogenmod build, except it is using another kernel. Follow the default steps to install it.

Boot and check

In the terminal application or using adb shell command, check the kernel built.

cat /proc/version

This will display the kernel built information. If you get "... clang version 3.3 ..." congratulations, you are running a LLVM/Clang Linux Kernel.


Compatibility Test Suite

  • In progress.

Project Hosting

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More about the foundation...