Kernel Compile Guide(clang)
Guide
- Add the Clang commits to your kernel source
https://android.googlesource.com/kernel/common/+log/f0907aa15ed9f9c7541bb244ed3f52c376ced19c - Download/build a compatible Clang toolchain
- Download/build a copy of binutils
- Compile the kernel (for arm64, x86_64 is similar - example using AOSP’s toolchains):
1 | export PATH=/home/ubuntu/gcc/bin:$PATH |
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 | git branch -r -d <branch> |
1 | git remote add op https://github.com/OnePlusOSS/android_kernel_oneplus_msm8998 |
把它这个拿下来
切换到自己的QC8998_P_9.0分支,并merge一下
1 | git checkout oneplus/QC8998_P_9.0 |
或者自己cherry-pick
1 | git cherry-pick commitid^..commitid |
Problem
- 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…嘻嘻
- Clang LTO
还没开始,但可以肯定的是必遇到问题。
- 手势用不了
fixed
- Clang编译 CPU 总是Max Freq
fixed
- ZRAM LZ4
added
- EAS
added
- Dynamic SchedTune Boost
added
- wakelock
todo
- more tcp congestion control algorithm
todo
Kernel Compile Guide(clang)