Repository navigation
Clang3.8 cross-compile linker issues libc (undefined references) #1
Copy link
Copy link
Closed
Description
I'm trying to cross-compile zlib-1.2.8 with clang3.8/android-ndk-20160105 snapshot on Debian Jessie.
Compiles properly but linking gives undefined reference errors.
'CC=arm-linux-androideabi-gcc' compiles (and links) properly. But that's probably not meant by "Everyone should be switching to Clang".
Any idea what's wrong here?
export NDK=/home/bob/Android/android-ndk-20160105
export TOOLCHAIN=/home/bob/Android/mytoolchain
export PATH=$TOOLCHAIN/bin:$PATH
export SYSROOT=$TOOLCHAIN/sysroot
export CFLAGS="-O3 -fPIC -ffast-math -march=armv7-a --target=thumbv7a-none-linux-androideabi -mthumb -mcpu=cortex-a15 -mfpu=neon-vfpv4 -mfloat-abi=softfp -v"
export CXXFLAGS="$CFLAGS -stdlib=libc++ -std=c++14"
export CPPFLAGS="-DANDROID -DNDEBUG"
export LDFLAGS="--fix-cortex-a8"
export CC=arm-linux-androideabi-clang
export CXX=arm-linux-androideabi-clang++
export AR=arm-linux-androideabi-ar
export AS=arm-linux-androideabi-as
export LD=arm-linux-androideabi-ld
export RANLIB=arm-linux-androideabi-ranlib
export NM=arm-linux-androideabi-nm
export STRIP=arm-linux-androideabi-strip
export CHOST=arm-linux-androideabi
$NDK/build/tools/make-standalone-toolchain.sh --verbose --platform=android-21 --install-dir=$TOOLCHAIN --arch=arm --toolchain=arm-linux-androideabi-4.9 --use-llvm --stl=libc++
./configure --static --prefix=/home/bob/zlibout
make
This is the tail of the output:
[...]
"/home/bob/Android/mytoolchain/bin/clang38" -cc1 -triple thumbv7-none-linux-android -emit-obj -disable-free -disable-llvm-verifier -main-file-name gzwrite.c -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -menable-no-infs -menable-no-nans -menable-unsafe-fp-math -fno-signed-zeros -freciprocal-math -ffp-contract=fast -ffast-math -masm-verbose -mconstructor-aliases -fuse-init-array -target-cpu cortex-a15 -target-feature +soft-float-abi -target-feature -fp-only-sp -target-feature -d16 -target-feature +vfp4 -target-feature -fp-armv8 -target-feature +neon -target-feature -crypto -target-abi aapcs-linux -mfloat-abi soft -target-linker-version 2.24 -v -dwarf-column-info -coverage-file /home/bob/encfs/zlib-1.2.8/gzwrite.o -resource-dir /home/bob/Android/mytoolchain/bin/../lib64/clang/3.8.243773 -D _LARGEFILE64_SOURCE=1 -D ANDROID -D NDEBUG -isysroot /home/bob/Android/mytoolchain/bin/../sysroot -internal-isystem /home/bob/Android/mytoolchain/bin/../sysroot/usr/local/include -internal-isystem /home/bob/Android/mytoolchain/bin/../lib64/clang/3.8.243773/include -internal-externc-isystem /home/bob/Android/mytoolchain/bin/../sysroot/include -internal-externc-isystem /home/bob/Android/mytoolchain/bin/../sysroot/usr/include -O3 -fdebug-compilation-dir /home/bob/encfs/zlib-1.2.8 -ferror-limit 19 -fmessage-length 100 -femulated-tls -mstackrealign -fno-signed-char -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp -o gzwrite.o -x c gzwrite.c
clang -cc1 version 3.8.243773 based upon LLVM 3.6.0svn default target x86_64-unknown-linux
ignoring nonexistent directory "/home/bob/Android/mytoolchain/bin/../sysroot/usr/local/include"
ignoring nonexistent directory "/home/bob/Android/mytoolchain/bin/../sysroot/include"
#include "..." search starts here:
#include <...> search starts here:
/home/bob/Android/mytoolchain/bin/../lib64/clang/3.8.243773/include
/home/bob/Android/mytoolchain/bin/../sysroot/usr/include
End of search list.
arm-linux-androideabi-ar rc libz.a adler32.o crc32.o deflate.o infback.o inffast.o inflate.o inftrees.o trees.o zutil.o compress.o uncompr.o gzclose.o gzlib.o gzread.o gzwrite.o
arm-linux-androideabi-clang -O3 -fPIC -ffast-math -march=armv7-a --target=thumbv7a-none-linux-androideabi -mthumb -mcpu=cortex-a15 -mfpu=neon-vfpv4 -mfloat-abi=softfp -v -D_LARGEFILE64_SOURCE=1 -o example example.o -L. libz.a
clang version 3.8.243773
Target: thumbv7a-none-linux-android
Thread model: posix
Found candidate GCC installation: /home/bob/Android/mytoolchain/bin/../lib/gcc/arm-linux-androideabi/4.9
Selected GCC installation: /home/bob/Android/mytoolchain/bin/../lib/gcc/arm-linux-androideabi/4.9
Candidate multilib: .;@m32
Selected multilib: .;@m32
"/home/bob/Android/mytoolchain/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/ld" --sysroot=/home/bob/Android/mytoolchain/bin/../sysroot -X --build-id --eh-frame-hdr -m armelf_linux_eabi -dynamic-linker /system/bin/linker -o example /home/bob/Android/mytoolchain/bin/../sysroot/usr/lib/../lib/crtbegin_dynamic.o -L. -L/home/bob/Android/mytoolchain/bin/../lib/gcc/arm-linux-androideabi/4.9 -L/home/bob/Android/mytoolchain/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/lib/../lib -L/home/bob/Android/mytoolchain/bin/../sysroot/usr/lib/../lib -L/home/bob/Android/mytoolchain/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/lib -L/home/bob/Android/mytoolchain/bin/../sysroot/usr/lib example.o libz.a -lgcc -ldl -lc -lgcc -ldl /home/bob/Android/mytoolchain/bin/../sysroot/usr/lib/../lib/crtend_android.o
libz.a(deflate.o):deflate.c:function deflateReset: error: undefined reference to '__aeabi_memclr'
libz.a(deflate.o):deflate.c:function deflateSetDictionary: error: undefined reference to '__aeabi_memclr'
libz.a(deflate.o):deflate.c:function fill_window: error: undefined reference to '__aeabi_memcpy'
libz.a(deflate.o):deflate.c:function fill_window: error: undefined reference to '__aeabi_memcpy'
libz.a(deflate.o):deflate.c:function fill_window: error: undefined reference to '__aeabi_memclr'
libz.a(deflate.o):deflate.c:function fill_window: error: undefined reference to '__aeabi_memclr'
libz.a(deflate.o):deflate.c:function deflate: error: undefined reference to '__aeabi_memcpy'
libz.a(deflate.o):deflate.c:function deflate: error: undefined reference to '__aeabi_memcpy'
clang38: error: linker command failed with exit code 1 (use -v to see invocation)
Makefile:170: recipe for target 'example' failed
make: *** [example] Error 1
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
DanAlbert commentedon Jan 5, 2016
Works fine with build 2490520, so this is a pretty recent regression (I assume that by "clang3.8/android-ndk-20160105 snapshot on Debian Jessie" you mean you built it yourself? Or does Debian provide nightlies?)
Checking with a ToT build right now.
DanAlbert commentedon Jan 5, 2016
Those symbols, and a few others, ended up getting accidentally removed from the NDK's definition of libc while we were purging other private symbols and whatnot. @dimitry- is working on a fix.
BlueMax commentedon Jan 5, 2016
Nice, thx.
Yes, i built it myself. I'm not sure where to find the NDK build number but the last commit of 'NDK' folder is:
DanAlbert commentedon Jan 5, 2016
Yeah, unfortunately our build servers aren't publicly visible (yet, I'm working on making that happen).
dimitry- commentedon Jan 5, 2016
Fixed by:
https://android-review.googlesource.com/194652
https://android-review.googlesource.com/194625
Restore public __aeabi symbols
Move __aeabi_ which are not in libgcc.a to LIBC
BlueMax commentedon Jan 6, 2016
Here's another one:
__gnu_Unwind_Find_exidx
Unresolved in
$TOOLCHAIN/arm-linux-androideabi/lib/armv7-a/thumb/libc++_shared.so:Is
make-standalone-toolchain.sh --stl=gnustlnot yet ready?--stl=libc++works properly.ERROR: Cant' copy from non-directory: /home/bob/Android/android-ndk-20160106/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi/thumbcmdline:
$ANDROID_NDK_ROOT/build/tools/make-standalone-toolchain.sh --verbose --platform=android-21 --install-dir=$TOOLCHAIN --arch=arm --toolchain=arm-linux-androideabi-4.9 --use-llvm --stl=gnustldimitry- commentedon Jan 6, 2016
will move it to LIBC there are couple of others I missed (__popcount_tab?)
BlueMax commentedon Jan 8, 2016
Not sure about any more libc symbols but the
libc++_shared.soseems completely unusable:dimitry- commentedon Jan 8, 2016
CLs:
https://android-review.googlesource.com/195350 and
https://android-review.googlesource.com/195322
Add missing __gnu_Unwind_Find_exidx symbol
Move __aeabi* symbols to LIBC_N version
BlueMax commentedon Jan 9, 2016
I think
__page_sizeis another one used by https://github.com/seth-hg/fuse-android.dimitry- commentedon Jan 12, 2016
__page_size was only used for android-12 and below.. I have fixed getpagesize for these versions to use PAGE_SIZE instead
Replace __page_size reference with PAGE_SIZE for android-12 and below
Move __aeabi_ which are not in libgcc.a to LIBC
Move __aeabi* symbols to LIBC_N version
Move __aeabi_ which are not in libgcc.a to LIBC
Move __aeabi* symbols to LIBC_N version
Move __aeabi* symbols to LIBC_N version
Move __aeabi_ which are not in libgcc.a to LIBC