From 8fa92daf6334010df564afa41a7ca9fc9db34060 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Vasconcellos?= Date: Mon, 21 Oct 2024 06:35:38 -0300 Subject: [PATCH] Fix x86_64 android build --- scripts/build.sh | 10 ++++++++-- scripts/cc.sh | 2 +- scripts/toolchain.sh | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/scripts/build.sh b/scripts/build.sh index a0b3f74..62c78ca 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -59,6 +59,7 @@ case "$TARGET" in ;; esac + LLVM_BUILTIN='/usr/lib/llvm-17/lib/clang/17/lib' case "$TARGET" in *gnu) CFLAGS="${CFLAGS} -D_GLIBCXX_ASSERTIONS=1" @@ -68,12 +69,17 @@ case "$TARGET" in ;; *android*) export SDKROOT="${NDK_SDKROOT:?Missing ndk sysroot}" + ANDROID_LIB="${SDKROOT}/usr/lib/${TARGET}" CFLAGS="${CFLAGS} -D__ANDROID_API__=${ANDROID_API_LEVEL:?Missing android api level}" - LDFLAGS="-fuse-ld=$(command -v ld.lld-17) -B${SDKROOT}/usr/lib/${TARGET}/${ANDROID_API_LEVEL:?} -L${SDKROOT}/usr/lib/${TARGET}/${ANDROID_API_LEVEL:?} -L${SDKROOT}/usr/lib/${TARGET} -lm ${LDFLAGS}" + LDFLAGS="-fuse-ld=$(command -v ld.lld-17) -B${ANDROID_LIB}/${ANDROID_API_LEVEL:?} -L${ANDROID_LIB}/${ANDROID_API_LEVEL:?} -L${ANDROID_LIB} -lm ${LDFLAGS}" ;;& # Resume switch/case matching from this point forward + x86_64-linux-android*) + # VERY UGLY HACK, no ideia why clang is not picking this up automatically + LDFLAGS="-L${LLVM_BUILTIN}/linux -lclang_rt.builtins-x86_64-android ${LDFLAGS}" + ;; aarch64-linux-android*) # VERY UGLY HACK, no ideia why clang is not picking this up automatically - LDFLAGS="-L/usr/lib/llvm-17/lib/clang/17/lib/baremetal -lclang_rt.builtins-aarch64 ${LDFLAGS}" + LDFLAGS="-L${LLVM_BUILTIN}/baremetal -L${LLVM_BUILTIN}/linux -lclang_rt.builtins-aarch64-android -lclang_rt.builtins-aarch64 ${LDFLAGS}" ;; esac ;; diff --git a/scripts/cc.sh b/scripts/cc.sh index fc78236..373af93 100755 --- a/scripts/cc.sh +++ b/scripts/cc.sh @@ -12,7 +12,7 @@ case "${TARGET:?TARGET envvar is required to be defined}" in ;; x86_64-linux-android | aarch64-linux-android) export SDKROOT="${NDK_SDKROOT:?Missing ndk sysroot}" - ;; + ;; x86_64-darwin-apple | x86_64-apple-darwin-macho) if [ "$OS_IPHONE" -eq 1 ]; then export SDKROOT="${IOS_SDKROOT:?Missing iOS SDK}" diff --git a/scripts/toolchain.sh b/scripts/toolchain.sh index 2983168..a74daa1 100755 --- a/scripts/toolchain.sh +++ b/scripts/toolchain.sh @@ -31,7 +31,7 @@ SYSTEM_PROCESSOR="${TARGET%%-*}" OS_IPHONE="${OS_IPHONE:-0}" # Check if target last part (*-*-last) is android -OS_ANDROID="$( case "${TARGET##*-}" in android*) echo 1 ;; *) echo 0 ;; esac )" +OS_ANDROID="$(case "${TARGET##*-}" in android*) echo 1 ;; *) echo 0 ;; esac)" case "$SYSTEM_NAME" in windows)