Skip to content

Commit

Permalink
Fix x86_64 android build
Browse files Browse the repository at this point in the history
  • Loading branch information
HeavenVolkoff committed Oct 21, 2024
1 parent 2466c03 commit 8fa92da
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
;;
Expand Down
2 changes: 1 addition & 1 deletion scripts/cc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
2 changes: 1 addition & 1 deletion scripts/toolchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 8fa92da

Please sign in to comment.