Reputation: 83
So while compiling android kernel for my 1plus phone, after multiples attempts over 3 days, I gave up and give a try to ask here if anyone had this problem before.
The bug is a bit obscure to me, but I feel like the problem comes from my recent change to a GNU/Linux distribution (Gentoo), which is somehow overriding the AS environment variable when it shouldn't; it fails at assembling VDSO, but I've no idea sadly from where the overriding comes. (maybe they did a modify the make command in order to allow supporting flags overriding etc..)
EDIT, Small version:
make RANLIB=/media/sda2/git/linux-x86/clang-bootstrap/bin/llvm-ranlib CC='/media/sda2/git/linux-x86/clang-bootstrap/bin/clang -fintegrated-as' LD=/media/sda2/git/linux-x86/clang-bootstrap/bin/ld.lld AR=/media/sda2/git/linux-x86/clang-bootstrap/bin/llvm-ar AS=/media/sda2/git/linux-x86/clang-bootstrap/bin/llvm-as NM=/media/sda2/git/linux-x86/clang-bootstrap/bin/llvm-nm OBJCOPY=/media/sda2/git/linux-x86/clang-bootstrap/bin/llvm-objcopy OBJDUMP=/media/sda2/git/linux-x86/clang-bootstrap/bin/llvm-objdump READELF=/media/sda2/git/linux-x86/clang-bootstrap/bin/llvm-readelf OBJSIZE=/media/sda2/git/linux-x86/clang-bootstrap/bin/llvm-size STRIP=/media/sda2/git/linux-x86/clang-bootstrap/bin/llvm-strip
CC kernel/bounds.s
CC arch/arm64/kernel/asm-offsets.s
In file included from arch/arm64/kernel/asm-offsets.c:25:
In file included from ./include/linux/kvm_host.h:39:
In file included from ./arch/arm64/include/asm/kvm_host.h:42:
In file included from ./include/kvm/arm_pmu.h:21:
In file included from ./include/linux/perf_event.h:57:
In file included from ./include/linux/cgroup.h:28:
./include/linux/cgroup-defs.h:475:16: warning: field 'cgrp' with variable sized type 'struct cgroup' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
struct cgroup cgrp;
^
1 warning generated.
CALL scripts/checksyscalls.sh
LDS arch/arm64/kernel/vdso/vdso.lds
VDSOA arch/arm64/kernel/vdso/gettimeofday.o
/usr/bin/as: unrecognized option '-EL'
clang-12: error: assembler command failed with exit code 1 (use -v to see invocation)
make[1]: *** [arch/arm64/kernel/vdso/Makefile:57: arch/arm64/kernel/vdso/gettimeofday.o] Error 1
make: *** [arch/arm64/Makefile:201: vdso_prepare] Error 2
Environment variables:
# https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/
export PATH='/media/sda2/git/aarch64-linux-android-4.9/bin':${PATH}
export LD_LIBRARY_PATH='/media/sda2/git/aarch64-linux-android-4.9/lib':${LD_LIBRARY_PATH}
# git clone https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86
export PATH='/media/sda2/git/linux-x86/clang-bootstrap/bin':${PATH}
export LD_LIBRARY_PATH='/media/sda2/git/linux-x86/clang-bootstrap/lib':${LD_LIBRARY_PATH}
export ARCH=arm64
export SUBARCH=arm64
export CROSS_COMPILE='aarch64-linux-android-'
export CROSS_COMPILER=$PATH
export CLANG_TRIPLE='aarch64-linux-gnu-'
export KCFLAGS='-pipe -O3'
export KCPPFLAGS='-pipe -O3'
Kernel used: https://github.com/LineageOS/android_kernel_oneplus_sm8250
Any ideas?
I use Google's clang prebuilt compiler (could build it myself but in order to gain time) in order to use polly for compiling android kernels since Gentoo LLVM team doesn't apparently have yet a use flag for it.
At worse I'm thinking to use Ubuntu binutils/automake etc / creating a docker environment in order to compile this kernel but this just doesn't make many sense to me since I should be able to do it on my own host system.
Thank you for your help and your care.
Upvotes: 1
Views: 9094
Reputation: 103
I have met the same problem. The root cause is that the CLANG_PATH should add before the PATH.
// have chance to use /usr/bin/as
export PATH=$PATH:$CLANG_PATH // wrong
export PATH=${CLANG_PATH}:${PATH} // correct
IGNORE
The reason is that you do not set the CROSS_COMPILE and the CROSS_COMPILE_ARM32 correctly.
The aarch64-linux-android-as can not find in PATH. So it uses /usr/bin/as. You should put the cross compile tools into patch or just set the absolute patch like this:
export CROSS_COMPILE=$CROSS/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-android-
export CROSS_COMPILE_ARM32=$CROSS/arm/arm-linux-androideabi-4.9/bin/arm-linux-androideabi-
- make CC=clang LD=ld.lld HOSTCC=clang AR=llvm-ar NM=llvm-nm OBJCOPY=llvm-objcopy OBJDUMP=llvm-objdump STRIP=llvm-strip O=out floral_defconfig
+ make CC=clang HOSTCC=clang AR=llvm-ar NM=llvm-nm OBJCOPY=llvm-objcopy OBJDUMP=llvm-objdump STRIP=llvm-strip O=out floral_defconfig
I have changes to this problem in one script but never meet it in another build script. By diffing the two files, I find the correct one does not set LD=ld.lld in make defconfig.
Upvotes: 2
Reputation: 83
I got it solved. After removing LD=/media/sda2/git/linux-x86/clang-bootstrap/bin/ld.lld for the linker, it worked, I suppose the clang linker was using /usr/bin/as by default and not aarch64-linux-android-as which is google's prebuilt. I'll need to investigate about it further. I'll edit this post once I found more.
Upvotes: 5