From 7e23a2a2c31ed7825561c839ba6424f70639fb56 Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Fri, 27 Sep 2024 15:42:18 -0700 Subject: [PATCH] Use Android NDK 27b and follow NDK guidelines for Android API level. --- mk/cargo.sh | 10 +++++----- mk/install-build-tools.sh | 17 +++++++++-------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/mk/cargo.sh b/mk/cargo.sh index 13906aee88..bc86f5e2bd 100755 --- a/mk/cargo.sh +++ b/mk/cargo.sh @@ -39,7 +39,7 @@ qemu_x86_64="qemu-x86_64" # be needed to compile the build script, or to compile for other targets. if [ -n "${ANDROID_HOME-}" ]; then # Keep the next line in sync with the corresponding line in install-build-tools.sh. - ndk_version=25.2.9519653 + ndk_version=27.1.12297006 ANDROID_NDK_ROOT=${ANDROID_NDK_ROOT:-${ANDROID_HOME}/ndk/$ndk_version} fi if [ -n "${ANDROID_NDK_ROOT-}" ]; then @@ -65,9 +65,9 @@ llvm_version=18 use_clang= case $target in aarch64-linux-android) - export CC_aarch64_linux_android=$android_tools/aarch64-linux-android21-clang + export CC_aarch64_linux_android="$android_tools/clang --target=aarch64-linux-android21" export AR_aarch64_linux_android=$android_tools/llvm-ar - export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=$android_tools/aarch64-linux-android21-clang + export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=$CC_aarch64_linux_android ;; aarch64-unknown-linux-gnu) use_clang=1 @@ -94,9 +94,9 @@ case $target in export CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_RUNNER="$qemu_arm_gnueabihf" ;; armv7-linux-androideabi) - export CC_armv7_linux_androideabi=$android_tools/armv7a-linux-androideabi19-clang + export CC_armv7_linux_androideabi="$android_tools/clang --target=armv7-linux-androideabi19" export AR_armv7_linux_androideabi=$android_tools/llvm-ar - export CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER=$android_tools/armv7a-linux-androideabi19-clang + export CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER=$CC_armv7_linux_androideabi ;; armv7-unknown-linux-gnueabihf) export CC_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-gcc diff --git a/mk/install-build-tools.sh b/mk/install-build-tools.sh index ca7129c7b0..eaf49da1c8 100755 --- a/mk/install-build-tools.sh +++ b/mk/install-build-tools.sh @@ -41,17 +41,18 @@ case ${target-} in # https://blog.rust-lang.org/2023/01/09/android-ndk-update-r25.html says # "Going forward the Android platform will target the most recent LTS NDK, # allowing Rust developers to access platform features sooner. These updates - # should occur yearly and will be announced in release notes." Assume that - # means that we should always prefer to be using the latest 25.x.y version of - # the NDK until the Rust project announces that we should use a higher major - # version number. + # should occur yearly and will be announced in release notes. # - # TODO: This should probably be implemented as a map of Rust toolchain version - # to NDK version; e.g. our MSRV might (only) support an older NDK than the - # latest stable Rust toolchain. + # https://github.com/actions/runner-images/issues/10614 indicates that GitHub + # actions doesn't intend to keep unsupported versions around, so in general + # we'll end up only supporting the latest NDK even for MSRV builds. + # + # https://developer.android.com/ndk/guides/other_build_systems explains how + # to set the API level. # # Keep the following line in sync with the corresponding line in cargo.sh. - ndk_version=25.2.9519653 + # + ndk_version=27.1.12297006 mkdir -p "${ANDROID_HOME}/licenses" android_license_file="${ANDROID_HOME}/licenses/android-sdk-license"