This is a cache of https://discuss.96boards.org/t/not-able-to-build-kernel-clang-linker-error/5206. It is a snapshot of the page at 2024-10-31T02:15:37.396+0000.
Not Able to build Kernel ? Clang Linker error - MediaTek-X20 - 96Boards Forum

Not Able to build Kernel ? Clang Linker error

host C++: v8_mksnapshot.arm <= external/v8/src/arguments.cc
clang: error: linker command failed with exit code 1 (use -v to see invocation)
build/core/host_shared_library_internal.mk:51: recipe for target ‘out/host/linux-x86/obj/lib/libart.so’ failed
make: *** [out/host/linux-x86/obj/lib/libart.so] Error 1
make: *** Waiting for unfinished jobs…
clang: error: linker command failed with exit code 1 (use -v to see invocation)
build/core/host_shared_library_internal.mk:51: recipe for target ‘out/host/linux-x86/obj/lib/libartd.so’ failed
make: *** [out/host/linux-x86/obj/lib/libartd.so] Error 1

Build Failed throwing new Error

out/host/linux-x86/obj/STATIC_LIBRARIES/libutils_intermediates/libutils.a(VectorImpl.o):system/core/libutils/VectorImpl.cpp:function typeinfo for android::VectorImpl: error: undefined reference to ‘vtable for __cxxabiv1::__class_type_info’
clang: error: linker command failed with exit code 1 (use -v to see invocation)
build/core/host_executable_internal.mk:34: recipe for target ‘out/host/linux-x86/obj/EXECUTABLES/validatekeymaps_intermediates/validatekeymaps’ failed
make: *** [out/host/linux-x86/obj/EXECUTABLES/validatekeymaps_intermediates/validatekeymaps] Error 1
out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/AST.o:frameworks/base/tools/aidl/AST.cpp:function vtable for ClassElement: error: undefined reference to ‘__cxa_pure_virtual’
out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/AST.o:frameworks/base/tools/aidl/AST.cpp:function vtable for ClassElement: error: undefined reference to ‘__cxa_pure_virtual’
out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/AST.o:frameworks/base/tools/aidl/AST.cpp:function typeinfo for ClassElement: error: undefined reference to ‘vtable for __cxxabiv1::__class_type_info’
out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/AST.o:frameworks/base/tools/aidl/AST.cpp:function typeinfo for Field: error: undefined reference to ‘vtable for __cxxabiv1::__si_class_type_info’
out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/AST.o:frameworks/base/tools/aidl/AST.cpp:function vtable for Expression: error: undefined reference to ‘__cxa_pure_virtual’
out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/AST.o:frameworks/base/tools/aidl/AST.cpp:function typeinfo for Expression: error: undefined reference to ‘vtable for __cxxabiv1::__class_type_info’
out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/AST.o:frameworks/base/tools/aidl/AST.cpp:function typeinfo for LiteralExpression: error: undefined reference to ‘vtable for __cxxabiv1::__si_class_type_info’
out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/AST.o:frameworks/base/tools/aidl/AST.cpp:function typeinfo for StringLiteralExpression: error: undefined reference to ‘vtable for __cxxabiv1::__si_class_type_info’
out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/AST.o:frameworks/base/tools/aidl/AST.cpp:function typeinfo for Variable: error: undefined reference to ‘vtable for __cxxabiv1::__si_class_type_info’
out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/AST.o:frameworks/base/tools/aidl/AST.cpp:function vtable for Statement: error: undefined reference to ‘__cxa_pure_virtual’
out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/AST.o:frameworks/base/tools/aidl/AST.cpp:function typeinfo for Statement: error: undefined reference to ‘vtable for __cxxabiv1::__class_type_info’
out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/AST.o:frameworks/base/tools/aidl/AST.cpp:function typeinfo for Case: error: undefined reference to ‘vtable for __cxxabiv1::__class_type_info’
clang: error: linker command failed with exit code 1 (use -v to see invocation)
build/core/host_executable_internal.mk:34: recipe for target ‘out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl’ failed
make: *** [out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl] Error 1

I think you might have to offer a few more clues: What build guide are you following (hyperlinks please)? What commands did you run to obtain the source code? What OS are you attempting to run the build on?

I am working on Ubantu 16 LTE as Host mechine. I ran make -j8 command. I set up the setup according to as given in mediatek x20 installation

I am working on Ubantu 16 LTE as Host mechine. I ran make -j8 command. I set up the setup according to as given in mediatek x20 installation

Which is where? Please tell us the link.

The problems in setup process is as -:
1). The version supported is openjdk-7, which is not supported .
2). Clang linkers error use to come frequently.
3). Code Download link for SLA is broken. Had to go for latest.(as it has “//” in address)
4). Launch command is not working
5). make -j<> gives error due to build/core/host_shared_library_internal.mk:51 file

I got following errors:-
It says build sucessful.
make[1]: Leaving directory `/home/ravi/develop/x20/vendor/mediatek/proprietary/trustzone/atf/v1.0’
make error

Host Os:-Ubantu 14
kernel 3.18
command ran:
sudo apt-get install openjdk-7-jdk
sudo apt-get install git-core gnupg flex bison gperf build-essential
zip curl zlib1g-dev gcc-multilib g+±multilib libc6-dev-i386
lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache
libgl1-mesa-dev libxml2-utils xsltproc unzip
$ mkdir ~/bin
$ PATH=~/bin:$PATH
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo

$ mkdir ~/develop/x20
$ cd ~/develop/x20
$ repo init -u platform/manifest - Git at Google -b android-6.0.0_r1
$ epo sync –j8

$ cd ~/develop
$ git clone https://github.com/helio-x20/linux.git

copied sla from linario site
make clobber
source build/envsetup.sh
$ lunch full_amt6796_64_open-eng

make -j8

Hi Ravi

Any idea why all your comments end up as new posts? I’m really struggling to keep track of your questions (which AFAICT should all be replies on the same topic). I’ve been moving them to where they belong but it doesn’t make it easy for people to help you.

It’s better to share the whole build log

It might be because I build in a container (so OS is very stripped down) but I also needed:

sudo apt install python gnupg2 bc

How does the kernel end up in the right bit of the repo source tree? What commands did you use to unpact the sla?

For reference I got both kernel and sla from the source package and unpacked it from the repo directory (e.g. ~/develop/x20) with the following commands:

tar -xf ../mediatek-x20-aosp-16.10/Source/kernel.tar.gz
tar --strip=1 -xf ../mediatek-x20-aosp-16.10/Source/sla.tar.gz

With the extract packages and the source unpacked using the above commands then AOSP builds for me.

when I am running the command lunch full_amt6796_64_open-eng it gives following error.

~/develop/x20$ lunch full_amt6796_64_open-eng
build/core/product_config.mk:222: *** Can not locate config makefile for product “full_amt6796_64_open”. Stop.

** Don’t have a product spec for: ‘full_amt6796_64_open’
** Do you have the right repo manifest?

How to debug it?

I know you couldn’t get it to build but this command was working for you before. What have you changed?