0

I'm building an Android tree 5.1.0_r3, that for some modules uses Clang as compiler. To avoid a reloc issue I had to apply a one-line patch that specifies to the system to use external (in-tree) assembler instead of the system one, as explained here https://stackoverflow.com/a/39638631/6350583

Now that problem is gone, but my build fails at linking.

This is the error:

art/runtime/class_linker.cc:376: error: undefined reference to 'art_quick_generic_jni_trampoline' .....

.....

clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [out/host/linux-x86/obj32/lib/libart.so] Error 1

I omitted all the lines in the middle, because they show always the same error for different functions. Here you can find the complete output http://pastebin.com/Q9hJ0Q7Y You can see they're mostly art-related. Someone refers to bionic, like __memcmp16

Problems seems to be that clang is able to correctly build c++ sources but, when processing assembly .S files, it generates only almost empty object files of 516 bytes. I added the verbose flag to get the invocation line

host asm: libart_32 <= art/runtime/arch/x86/memcmp16_x86.S
clang version 3.5 
Target: i386--linux-gnu
Thread model: posix
 "prebuilts/clang/linux-x86/host/3.5/bin/clang" -cc1 -triple i386--linux-gnu -E -disable-free -disable-llvm-verifier -main-file-name memcmp16_x86.S -mrelocation-model pic -pic-level 2 -relaxed-aliasing -fmath-errno -masm-verbose -no-integrated-as -mconstructor-aliases -target-cpu prescott -target-feature +sse3 -target-linker-version 2.22 -momit-leaf-frame-pointer -v -g -coverage-file /tmp/memcmp16_x86-23e2cb.s -resource-dir prebuilts/clang/linux-x86/host/3.5/bin/../lib/clang/3.5 -dependency-file out/host/linux-x86/obj32/SHARED_LIBRARIES/libart_intermediates/arch/x86/memcmp16_x86.d -MT out/host/linux-x86/obj32/SHARED_LIBRARIES/libart_intermediates/arch/x86/memcmp16_x86.o -sys-header-deps -isystem system/core/include -isystem hardware/libhardware/include -isystem hardware/libhardware_legacy/include -isystem hardware/ril/include -isystem libnativehelper/include -isystem frameworks/native/include -isystem frameworks/native/opengl/include -isystem frameworks/av/include -isystem frameworks/base/include -isystem tools/include -isystem out/host/linux-x86/obj/include -isystem prebuilts/clang/linux-x86/host/3.5/lib/clang/3.5/include/ -include build/core/combo/include/arch/linux-x86/AndroidConfig.h -U _FORTIFY_SOURCE -D _FORTIFY_SOURCE=0 -D __STDC_FORMAT_MACROS -D __STDC_CONSTANT_MACROS
.......
.......
.......
D NDEBUG -U DEBUG -D __compiler_offsetof=__builtin_offsetof -D __ASSEMBLY__ -I external/libcxx/include -I external/gtest/include -I external/valgrind/main/include -I external/valgrind/main -I external/vixl/src -I external/zlib -I frameworks/compile/mclinker/include -I art/sigchainlib -I art/runtime -I out/host/linux-x86/obj32/SHARED_LIBRARIES/libart_intermediates -I out/host/linux-x86/gen/SHARED_LIBRARIES/libart_intermediates -I libnativehelper/include/nativehelper -I vendor/mediatek/proprietary/custom/y991/cgen/cfgdefault -I vendor/mediatek/proprietary/custom/y991/cgen/cfgfileinc -I vendor/mediatek/proprietary/custom/y991/cgen/inc -I vendor/mediatek/proprietary/custom/y991/cgen -I vendor/mediatek/proprietary/custom/mt6795/cgen/cfgdefault -I vendor/mediatek/proprietary/custom/mt6795/cgen/cfgfileinc -I vendor/mediatek/proprietary/custom/mt6795/cgen/inc -I vendor/mediatek/proprietary/custom/mt6795/cgen -I vendor/mediatek/proprietary/custom/common/cgen/cfgdefault -I vendor/mediatek/proprietary/custom/common/cgen/cfgfileinc -I vendor/mediatek/proprietary/custom/common/cgen/inc -I vendor/mediatek/proprietary/custom/common/cgen -isysroot prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.6/sysroot -internal-isystem prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.6/sysroot/usr/local/include -internal-isystem prebuilts/clang/linux-x86/host/3.5/bin/../lib/clang/3.5/include -internal-externc-isystem prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.6/sysroot/include -internal-externc-isystem prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.6/sysroot/usr/include -O2 -Wno-multichar -W -Wall -Wno-unused -Winit-self -Wpointer-arith -Werror=int-conversion -fno-dwarf-directory-asm -fdebug-compilation-dir /home/Ubuntu/javier/dati/download/part-tree -ferror-limit 19 -fmessage-length 0 -backend-option -force-align-stack -mstackrealign -fobjc-runtime=gcc -fdiagnostics-show-option -vectorize-loops -vectorize-slp -dM -o /tmp/memcmp16_x86-23e2cb.s -x assembler-with-cpp art/runtime/arch/x86/memcmp16_x86.S

Here you can find the same output line-wrapped http://pastebin.com/2DFAbHuc I omitted some lines which were just a bunch of Android-specific variable definitions, to make the output easier to read.

EDIT

I found a subsequent invocation of the assembler. Still don't know where the problem resides. "prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.6/x86_64-linux/bin/as" --32 --noexecstack -o out/host/linux-x86/obj32/SHARED_LIBRARIES/libart_intermediates/arch/x86/memcmp16_x86.o /tmp/memcmp16_x86-23e2cb.s

Community
  • 1
  • 1
4javier
  • 481
  • 2
  • 7
  • 22

1 Answers1

0

Obviously nobody could help me with this problem, simply because it was all my fault. Trying to debug another issue I had previously, I had added the "-dM" flag to the toolchain. This option forces the preprocessor to just print out all the definitions involved in the operation is invoked for, without actually preprocess the source file. Its output file then, will be just a list of definitions. When this "false-preprocessed" file gets passed to the assembler, it will bring to the production of a useless object file.

Lesson learnt: always revert your temporary debug modifications as soon as possible.

4javier
  • 481
  • 2
  • 7
  • 22