diff --git a/toolchains/android-common/multi-build.sh b/toolchains/android-common/multi-build.sh index f5ec0aa8..dfe2bc63 100755 --- a/toolchains/android-common/multi-build.sh +++ b/toolchains/android-common/multi-build.sh @@ -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) @@ -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 diff --git a/toolchains/android-common/packages/libvpx/patches/0003-Fix-Android-build-on-x86.patch b/toolchains/android-common/packages/libvpx/patches/0003-Fix-Android-build.patch similarity index 55% rename from toolchains/android-common/packages/libvpx/patches/0003-Fix-Android-build-on-x86.patch rename to toolchains/android-common/packages/libvpx/patches/0003-Fix-Android-build.patch index 316046b4..ace087dd 100644 --- a/toolchains/android-common/packages/libvpx/patches/0003-Fix-Android-build-on-x86.patch +++ b/toolchains/android-common/packages/libvpx/patches/0003-Fix-Android-build.patch @@ -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 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 @@ -21,5 +31,5 @@ index 890be135b..8dfda7da7 100644 ;; darwin*) -- -2.39.2 +2.43.0 diff --git a/toolchains/android-common/packages/libvpx/patches/0004-configure-add-c-to-ASFLAGS-for-android-AS-clang.patch b/toolchains/android-common/packages/libvpx/patches/0004-configure-add-c-to-ASFLAGS-for-android-AS-clang.patch new file mode 100644 index 00000000..d8c16068 --- /dev/null +++ b/toolchains/android-common/packages/libvpx/patches/0004-configure-add-c-to-ASFLAGS-for-android-AS-clang.patch @@ -0,0 +1,36 @@ +From 4bb95bea3b7ff2ae5aca4ee9d56f6c1af20c62e9 Mon Sep 17 00:00:00 2001 +From: James Zern +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 + diff --git a/toolchains/android/Dockerfile.m4 b/toolchains/android/Dockerfile.m4 index a70f8244..2f405b13 100644 --- a/toolchains/android/Dockerfile.m4 +++ b/toolchains/android/Dockerfile.m4 @@ -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 diff --git a/toolchains/android/packages/ndk/build.sh b/toolchains/android/packages/ndk/build.sh index 2d814d41..23d1013c 100755 --- a/toolchains/android/packages/ndk/build.sh +++ b/toolchains/android/packages/ndk/build.sh @@ -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