参考步骤是: https://makiras.org/archives/173?amp
内核源码是: https://github.com/LineageOS/android_kernel_oneplus_msm8998/tree/lineage-17.1
make 最后几行信息是:
CC kernel/trace/ring_buffer.o
LD kernel/sched/built-in.o
CC mm/cma.o
CC mm/cma_debug.o
CC kernel/profile.o
CC mm/usercopy.o
CC kernel/trace/trace.o
LD mm/built-in.o
CC kernel/trace/trace_output.o
CC kernel/stacktrace.o
CC kernel/futex.o
CC kernel/trace/trace_seq.o
CC kernel/trace/trace_stat.o
CC kernel/trace/trace_printk.o
CC kernel/trace/trace_sched_switch.o
CC kernel/trace/trace_cpu_freq_switch.o
CC kernel/futex_compat.o
CC kernel/trace/trace_nop.o
In function 'ftrace_dump',
inlined from 'ftrace_dump' at ../kernel/trace/trace.c:7244:6:
../kernel/trace/trace.c:7321:3: warning: 'memset' offset [8385, 8440] from the object at 'iter' is out of the bounds of referenced subobject 'seq' with type 'struct trace_seq' at offset 4248 [-Warray-bounds]
error, forbidden warning: trace.c:7321
../scripts/Makefile.build:282: recipe for target 'kernel/trace/trace.o' failed
make[3]: *** [kernel/trace/trace.o] Error 1
make[3]: *** Waiting for unfinished jobs....
CC kernel/smp.o
CC kernel/uid16.o
../scripts/Makefile.build:489: recipe for target 'kernel/trace' failed
make[2]: *** [kernel/trace] Error 2
make[2]: *** Waiting for unfinished jobs....
/root/android_kernel_oneplus_msm8998-lineage-17.1/Makefile:1012: recipe for target 'kernel' failed
make[1]: *** [kernel] Error 2
make[1]: Leaving directory '/root/android_kernel_oneplus_msm8998-lineage-17.1/out'
Makefile:152: recipe for target 'sub-make' failed
make: *** [sub-make] Error 2
这个是源码本身有问题吗?编译环境 docker 上的 ubuntu18.04 ,官方容器,同时编译了 16.0 的分支也是也是提示类似错误。
使用的编译参数是
export ARCH=arm64
export SUBARCH=arm64
export PATH=~/.gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu/bin:$PATH
export CROSS_COMPILE=aarch64-none-linux-gnu-
make -j$(nproc --all) O=out lineage_oneplus5_defconfig
make -j$(nproc --all) O=out ARCH=arm64\
SUBARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- \
CONFIG_DEBUG_SECTION_MISMATCH=y
感谢 @codehz 提供的思路
解决方法是把上文中、arm的交叉编译器gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu,换成lineageOS自己的。具体在 https://github.com/LineageOS/android_prebuilts_gcc_linux-x86_aarch64_aarch64-linux-android-4.9 。
然后把PATH和CROSS_COMPILE变量改成对应值,再编译就没问题了。
1
codehz 2020-10-26 08:41:11 +08:00 via Android 1
一般来说是编译器版本太新了,有很多新的警告,配合 Werror 不就 boom 了吗
|
2
amrnxcdt OP @codehz 我是直接 apt install,所以是应该退回 gcc 的版本吗?还是要找 gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu 之前的版本?
|
3
codehz 2020-10-26 10:35:53 +08:00 via Android 1
不是退回,而是需要使用 prebuilt 的工具链,需要适配构建目标的内核版本。。。
当然这种问题主要是在单独编译内核的时候才出现的,如果是从安卓源码树(或者 lineageos 的完整源码 repo )下进行构建,就会把相关编译器准备好的 |
4
FFF5279 2020-10-27 16:06:00 +08:00 via iPhone 1
编译环境建议使用 docker
|