1 #!/bin/bash 2 3 if [[ "$OUT" == "" ]]; then 4 echo "In order for this script to function, please choose an x86_64 target" 5 echo "using source build/envsetup.sh and lunch XXX\n" 6 exit 1 7 fi 8 9 x86_64_cc="${ANDROID_TOOLCHAIN}/x86_64-linux-android-gcc" 10 x86_64_cpp="${ANDROID_TOOLCHAIN}/x86_64-linux-android-g++" 11 12 includes=( 13 "-isystem ${ANDROID_BUILD_TOP}/bionic/libc/arch-x86_64/include" 14 "-isystem ${ANDROID_BUILD_TOP}/bionic/libc/include" 15 "-isystem ${ANDROID_BUILD_TOP}/bionic/libstdc++/include" 16 "-isystem ${ANDROID_BUILD_TOP}/bionic/libc/kernel/uapi" 17 "-isystem ${ANDROID_BUILD_TOP}/bionic/libc/kernel/uapi/asm-x86" 18 "-isystem ${ANDROID_BUILD_TOP}/bionic/libm/include" 19 "-isystem ${ANDROID_BUILD_TOP}/bionic/libm/include/amd64" 20 "-include ${ANDROID_BUILD_TOP}/build/core/combo/include/arch/linux-x86/AndroidConfig.h" 21 ) 22 23 # Copy libm.so to libpthread.so to allow -lpthread to work. 24 cp ${OUT}/obj/lib/libm.so ${OUT}/obj/lib/libpthread.so 25 26 ldflags=( 27 "-nostdlib" 28 "-Bdynamic" 29 "-fPIE" 30 "-pie" 31 "-Wl,-dynamic-linker,/system/bin/linker64" 32 "-Wl,--gc-sections" 33 "-Wl,-z,nocopyreloc" 34 "-L${OUT}/obj/lib" 35 "-Wl,-rpath-link=${OUT}/obj/lib" 36 "${OUT}/obj/lib/crtbegin_dynamic.o" 37 "-Wl,--whole-archive" 38 "-Wl,--no-whole-archive" 39 "-lc" 40 "-lstdc++" 41 "-lgcc" 42 "-lm" 43 "-Wl,-z,noexecstack" 44 "-Wl,-z,relro" 45 "-Wl,-z,now" 46 "-Wl,--warn-shared-textrel" 47 "-Wl,--fatal-warnings" 48 "-Wl,--icf=safe" 49 "-Wl,--no-undefined" 50 "-ldl" 51 ) 52 53 eval ./configure CC=\"${x86_64_cc} ${includes[@]}\" \ 54 CPP=\"${x86_64_cc} ${includes[@]} -E\" \ 55 CXX=\"${x86_64_cpp} ${includes[@]}\" \ 56 CXXCPP=\"${x86_64_cpp} ${includes[@]} -E\" \ 57 LDFLAGS=\"${ldflags[@]}\" \ 58 --host=x86_64-android-linux \ 59 --disable-valgrind \ 60 --with-jemalloc_prefix=je_ \ 61 62