Skip to content

Commit

Permalink
ANDROID: Use newer NDK version 23
Browse files Browse the repository at this point in the history
  • Loading branch information
lephilousophe committed Sep 14, 2024
1 parent 50509e4 commit 4db9c31
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 34 deletions.
29 changes: 11 additions & 18 deletions toolchains/android-common/multi-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ if [ -z "$API" ]; then
API=all
fi

# Old toolchains don't have this architecure so let it be configurable
if [ -z "$TOOLCHAIN" ]; then
TOOLCHAIN="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${HOST_TAG}"
fi
TOOLCHAIN="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${HOST_TAG}"

targets=$(cd "$TOOLCHAIN/sysroot/usr/lib" && ls -d */)
for c in ar c++filt nm objcopy objdump ranlib readelf strings strip; do
v=$(echo $c | tr 'a-z+-' 'A-ZX_')
export $v="$TOOLCHAIN/bin/llvm-$c"
done
export LD="$TOOLCHAIN/bin/lld"

for t in "$TOOLCHAIN/sysroot/usr/lib/"*/; do
t=$(basename $t)
Expand Down Expand Up @@ -56,23 +57,15 @@ for t in "$TOOLCHAIN/sysroot/usr/lib/"*/; do
# Define all environment variables now that we have the target platform and API
export HOST=$t TARGET=$t
# Don't know why but tools and compiler don't have the same target prefix for ARM
# Don't know why but libs and compiler don't have the same target prefix for ARM
comp_target=$TARGET
if [ $comp_target = "arm-linux-androideabi" ]; then
comp_target=armv7a-linux-androideabi
fi
for c in ar as c++filt ld nm objcopy objdump ranlib readelf strings strip; do
v=$(echo $c | tr 'a-z+-' 'A-ZX_')
export $v="$TOOLCHAIN/bin/$TARGET-$c"
done
# Frankenstein unified toolchains don't have the API version and use same name as TARGET
if [ -f "$TOOLCHAIN/bin/$comp_target$a-clang" ]; then
export CC=$TOOLCHAIN/bin/$comp_target$a-clang
export CXX=$TOOLCHAIN/bin/$comp_target$a-clang++
else
export CC=$TOOLCHAIN/bin/$TARGET-clang
export CXX=$TOOLCHAIN/bin/$TARGET-clang
fi
# Libvpx detects if AS ends with clang
export AS=$TOOLCHAIN/bin/$comp_target$a-clang
export CC=$TOOLCHAIN/bin/$comp_target$a-clang
export CXX=$TOOLCHAIN/bin/$comp_target$a-clang++
export PREFIX=$TOOLCHAIN/sysroot/usr
export PATH=$original_path:$TOOLCHAIN/bin:$PREFIX/bin/$TARGET/$a
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
From cebce96d91c2e04bc07025f04ef093438a0f99dd Mon Sep 17 00:00:00 2001
From e6955c6ac0adb5b23532dd737188744f05b0260b Mon Sep 17 00:00:00 2001
From: Le Philousophe <lephilousophe@users.noreply.github.com>
Date: Sun, 12 Mar 2023 16:36:43 +0100
Subject: [PATCH 3/3] Fix Android build on x86
Subject: [PATCH 3/4] Fix Android build

---
build/make/configure.sh | 2 ++
1 file changed, 2 insertions(+)
build/make/configure.sh | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/build/make/configure.sh b/build/make/configure.sh
index 890be135b..8dfda7da7 100644
index 12255b27c..629d79f53 100644
--- a/build/make/configure.sh
+++ b/build/make/configure.sh
@@ -1378,6 +1378,8 @@ EOF
@@ -792,6 +792,9 @@ process_common_toolchain() {

# detect tgt_os
case "$gcctarget" in
+ *android*)
+ tgt_os=android
+ ;;
*darwin1[0-9]*)
tgt_isa=x86_64
tgt_os=`echo $gcctarget | sed 's/.*\(darwin1[0-9]\).*/\1/'`
@@ -1409,6 +1412,8 @@ EOF
add_asflags -f elf${bits}
enabled debug && [ "${AS}" = yasm ] && add_asflags -g dwarf2
enabled debug && [ "${AS}" = nasm ] && add_asflags -g
Expand All @@ -21,5 +31,5 @@ index 890be135b..8dfda7da7 100644
;;
darwin*)
--
2.39.2
2.43.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
From 4bb95bea3b7ff2ae5aca4ee9d56f6c1af20c62e9 Mon Sep 17 00:00:00 2001
From: James Zern <jzern@google.com>
Date: Tue, 11 Jun 2024 13:55:36 -0700
Subject: [PATCH 4/4] configure: add -c to ASFLAGS for android + AS=clang

The GNU Assembler was removed in r24. clang's internal assembler works,
but `-c` is necessary to avoid linking.

Bug: webm:1856
Change-Id: I61f80cf78657d3b71d5e73c5b2510575533ca5ea
---
build/make/configure.sh | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/build/make/configure.sh b/build/make/configure.sh
index 629d79f53..c4524b7a8 100644
--- a/build/make/configure.sh
+++ b/build/make/configure.sh
@@ -1123,6 +1123,14 @@ EOF
echo "See build/make/Android.mk for details."
check_add_ldflags -static
soft_enable unit_tests
+ case "$AS" in
+ *clang)
+ # The GNU Assembler was removed in the r24 version of the NDK.
+ # clang's internal assembler works, but `-c` is necessary to
+ # avoid linking.
+ add_asflags -c
+ ;;
+ esac
;;

darwin)
--
2.43.0

2 changes: 1 addition & 1 deletion toolchains/android/Dockerfile.m4
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ RUN apt-get update && \
ENV ANDROID_ROOT=/opt/android

ENV ANDROID_NDK_ROOT=${ANDROID_ROOT}/ndk \
ANDROID_NDK_VERSION=21.3.6528147 \
ANDROID_NDK_VERSION=23.2.8568313 \
API=16 \
HOST_TAG=linux-x86_64

Expand Down
10 changes: 2 additions & 8 deletions toolchains/android/packages/ndk/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,8 @@ do_sdk_install "ndk;${ANDROID_NDK_VERSION}"

cd "ndk/${ANDROID_NDK_VERSION}"

# Cleanup unused parts of the NDK (which will get removed in future versions)
rm -rf platforms sources/cxx-stl sysroot
for d in toolchains/*; do
if [ "$d" = "toolchains/llvm" ]; then
continue
fi
rm -rf "$d"
done
# Cleanup unused parts of the NDK
rm -rf prebuilt sources/cxx-stl sources/third_party simpleperf shader-tools toolchains/renderscript

mkdir -p "${ANDROID_NDK_ROOT}/"
# mv is faster than cp
Expand Down

0 comments on commit 4db9c31

Please sign in to comment.