Issue
I try to build android kernel from google official document,use official build.sh
from scratch,but got this error message as follow:
VDSOSYM include/generated/vdso-offsets.h
LDS arch/arm64/kernel/vdso32/vdso.lds
VDSOC32 arch/arm64/kernel/vdso32/vgettimeofday.o
VDSOA32 arch/arm64/kernel/vdso32/sigreturn.o
HOSTCC arch/arm64/kernel/vdso32/../../../arm/vdso/vdsomunge
clang-5.0: warning: optimization flag '-fno-delete-null-pointer-checks' is not supported [-Wignored-optimization-argument]
VDSOL32 arch/arm64/kernel/vdso32/vdso.so.raw
/..//bin/ld: unrecognised emulation mode: armelf_linux_eabi
Supported emulations: elf_x86_64 elf32_x86_64 elf_i386 elf_iamcu i386pep i386pe elf64bpf
clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [/home/tonki/aosp/newkernel/private/msm-google/arch/arm64/kernel/vdso32/Makefile:138: arch/arm64/kernel/vdso32/vdso.so.raw] Error 1
make[2]: *** [arch/arm64/Makefile:242: vdso_prepare] Error 2
make[1]: *** [Makefile:152: sub-make] Error 2
make: *** [Makefile:24: __sub-make] Error 2
I take a look at arch/arm64/kernel/vdso32/Makefile
file,found this line
CC_ARM32 := $(CC) $(CLANG_TARGET_ARM32)
,it use clang --target=arm-linux-androideabi
to link vdso32.raw image but use /usr/bin/ld
to link.
My OS is Arch Linux distribution,there was no gcc-arm-linux-androideabi
official package which i can install with pacman like Ubuntu's apt tool.
Branch: AOSP kernel/android-msm-crosshatch-4.9-pie-qpr2.
Device: Pixel 3XL.
Kernel-config: official b1c1_defconfig(arch/arm64/configs/b1c1_defconfig).
Question: How can i solve it ? I have no idea here.Thanks!
Solution
I try to find the error detail.
I open make verbose message ouput.
clang --target=arm-linux-androideabi -Wp,-MD,arch/arm64/kernel/vdso32/.vdso.so.raw.d -nostdinc -isystem /home/tonki/aosp/newkernel/prebuilts-master/clang/host/linux-x86/clang-4393122/lib64/clang/5.0.1/include -I/home/tonki/aosp/newkernel/private/msm-google/arch/arm64/include -I./arch/arm64/include/generated/uapi -I./arch/arm64/include/generated -I/home/tonki/aosp/newkernel/private/msm-google/include -I./include -I/home/tonki/aosp/newkernel/private/msm-google/arch/arm64/include/uapi -I/home/tonki/aosp/newkernel/private/msm-google/include/uapi -I./include/generated/uapi -include /home/tonki/aosp/newkernel/private/msm-google/include/linux/kconfig.h -D__KERNEL__ -Qunused-arguments -mlittle-endian -Wl,-Bsymbolic -Wl,--no-undefined -Wl,-soname=linux-vdso.so.1 -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096 -nostdlib -shared -mfloat-abi=soft -Wl,-T arch/arm64/kernel/vdso32/vdso.lds arch/arm64/kernel/vdso32/vgettimeofday.o arch/arm64/kernel/vdso32/sigreturn.o -o arch/arm64/kernel/vdso32/vdso.so.raw
I think clang -target=arm-linux-androideabi was use system'ld to link vdso.so.raw ,so i found this link ,finally i modify like this
in arch/arm64/kernel/vdso32/Makefile:8
CC_ARM32 := $(CC) $(CLANG_TARGET_ARM32) -gcc-toolchain /home/tonki/aosp/newkernel/prebuilts/ndk-r23/toolchains/llvm/prebuilt/linux-x86_64
It finally work!
Answered By - jdir.s Answer Checked By - Pedro (WPSolving Volunteer)