Kernel Compile Guide(clang)

Guide

  1. Add the Clang commits to your kernel source
    https://android.googlesource.com/kernel/common/+log/f0907aa15ed9f9c7541bb244ed3f52c376ced19c
  2. Download/build a compatible Clang toolchain
  3. Download/build a copy of binutils
  4. Compile the kernel (for arm64, x86_64 is similar - example using AOSP’s toolchains):
1
2
3
4
5
6
7
8
9
10
11
export PATH=/home/ubuntu/gcc/bin:$PATH
export PATH=/home/ubuntu/clang/bin:$PATH
export CROSS_COMPILE=aarch64-linux-android-
export CLANG_TRIPLE=aarch64-linux-gnu-
export ARCH=arm64
export SUBARCH=arm64

make clean
make mrproper
make O=out lcblues-perf_defconfig
make -j$(nproc --all) O=out CC=clang CONFIG_DEBUG_SECTION_MISMATCH=y
1
make -j$(nproc --all) O=out

CC=clang CLANG_TRIPLE=aarch64-linux-gnu-

op5-perf_defconfig or msmcortex-perf_defconfig
After compiling, you can verify the toolchain used by opening out/include/generated/compile.h and looking at the LINUX_COMPILER option.

A couple of notes:

CLANG_TRIPLE is only needed when using AOSP’s version of Clang
export CC=clang does not work. You need to pass CC=clang to make like above.

关于git cherry-pick

首先fork一加官方kernel,然后clone自己仓

1
git clone

清除无用的分支,再add一个一加官方的remote

1
2
git branch -r -d <branch>
git push origin <branch>
1
2
git remote add op https://github.com/OnePlusOSS/android_kernel_oneplus_msm8998
git fetch op HEAD:oneplus/QC8998_P_9.0

把它这个拿下来
切换到自己的QC8998_P_9.0分支,并merge一下

1
2
git checkout oneplus/QC8998_P_9.0
git merge op/oneplus/QC8998_P_9.0

或者自己cherry-pick

1
git cherry-pick commitid^..commitid

Problem

  1. WLAN驱动qca_cld3_wlan.ko的问题

一加官方内核repo里面是不包含qcacld3.0的源码的。它在开机的时候加载insmod /vedor/lib/module/qca_cl3_wlan.ko,见 /vendor/etc/init/hw/init.target.rc

但模块存在一个check_version的校验的问题,你如果不是从源码编译而来的,基本是过不去的,因此在启动的时候,驱动没加载,开机就没WiFi。

那么为什么Custom Rom没有这个问题?Custom Rom的内核是由CAF基线+一加的一些修改而成的,包含qcacld3源码,并且配置成includes到内核里。

那为什么第三方基于一加内核源码魔改的内核没有这个问题呢?特意看了commit,它魔改了/kernel/module.c,check_version遇到wlan直接return 1了。

现在我处于菜鸟阶段,因此我cherry-pick了这个commit…嘻嘻

  1. Clang LTO

还没开始,但可以肯定的是必遇到问题。

  1. 手势用不了

fixed

  1. Clang编译 CPU 总是Max Freq

fixed

  1. ZRAM LZ4

added

  1. EAS

added

  1. Dynamic SchedTune Boost

added

  1. wakelock

todo

  1. more tcp congestion control algorithm

todo

Comments

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×