depends: android_ndk: update to 27 (latest LTS)

This commit is contained in:
tobtoht 2024-08-26 12:12:42 +02:00
parent 2e8a128c75
commit b746d01522
No known key found for this signature in database
GPG Key ID: E45B10DD027D2472
7 changed files with 57 additions and 89 deletions

View File

@ -1,12 +1,20 @@
ANDROID_API=21
ifeq ($(host_arch),arm)
host_toolchain=arm-linux-androideabi-
host_toolchain=armv7a-linux-androideabi$(ANDROID_API)-
else ifeq ($(host_arch),aarch64)
host_toolchain=aarch64-linux-android$(ANDROID_API)-
endif
android_CC=$(host_toolchain)clang
android_CXX=$(host_toolchain)clang++
android_RANLIB=:
clear_guix_env=env -u C_INCLUDE_PATH -u CPLUS_INCLUDE_PATH \
-u OBJC_INCLUDE_PATH -u OBJCPLUS_INCLUDE_PATH -u CPATH \
-u LIBRARY_PATH
android_CC=$(clear_guix_env) $(build_prefix)/bin/$(host_toolchain)clang
android_CXX=$(clear_guix_env) $(build_prefix)/bin/$(host_toolchain)clang++
android_AR=llvm-ar
android_RANLIB=llvm-ranlib
android_CFLAGS=-pipe
android_CXXFLAGS=$(android_CFLAGS)
@ -20,4 +28,8 @@ android_debug_CXXFLAGS=$(android_debug_CFLAGS)
android_native_toolchain=android_ndk
android_cmake_system=Android
# CMake 3.24 fails to detect API level for Android, even if set explicitly in
# toolchain.cmake. It also tries to manually construct paths to clang(++), but we
# want it to always use the options defined here. It's easier to just pretend
# we're a generic Linux target, than to hack around it.
android_cmake_system=Linux

View File

@ -1,29 +1,15 @@
package=android_ndk
$(package)_version=18b
$(package)_version=27c
$(package)_download_path=https://dl.google.com/android/repository/
$(package)_file_name=android-ndk-r$($(package)_version)-linux-x86_64.zip
$(package)_sha256_hash=4f61cbe4bbf6406aa5ef2ae871def78010eed6271af72de83f8bd0b07a9fd3fd
$(package)_patches=api_definition.patch fix_env.patch
define $(package)_set_vars
$(package)_config_opts_arm=--arch arm
$(package)_config_opts_aarch64=--arch arm64
endef
$(package)_file_name=android-ndk-r$($(package)_version)-linux.zip
$(package)_sha256_hash=59c2f6dc96743b5daf5d1626684640b20a6bd2b1d85b13156b90333741bad5cc
define $(package)_extract_cmds
echo $($(package)_sha256_hash) $($(1)_source_dir)/$($(package)_file_name) | sha256sum -c &&\
unzip -q $($(1)_source_dir)/$($(package)_file_name)
endef
define $(package)_preprocess_cmds
cd android-ndk-r$($(package)_version) && \
patch -p1 < $($(package)_patch_dir)/api_definition.patch && \
patch -p1 < $($(package)_patch_dir)/fix_env.patch
endef
define $(package)_stage_cmds
python3 android-ndk-r$($(package)_version)/build/tools/make_standalone_toolchain.py --api 21 \
--install-dir $(build_prefix) --stl=libc++ $($(package)_config_opts) &&\
mv $(build_prefix) $($(package)_staging_dir)/$(host_prefix)
mkdir -p $($(package)_staging_prefix_dir) && \
mv android-ndk-r$($(package)_version)/toolchains/llvm/prebuilt/linux-x86_64/* $($(package)_staging_prefix_dir)
endef

View File

@ -3,13 +3,11 @@ $(package)_version=3.0.13
$(package)_download_path=https://www.openssl.org/source
$(package)_file_name=$(package)-$($(package)_version).tar.gz
$(package)_sha256_hash=88525753f79d3bec27d2fa7c66aa0b92b3aa9498dafd93d7cfa4b3780cdae313
# The bundled ranlib in Android NDK 18b inserts timestamps by default.
# To prevent reproducibility issues, we must enable [D]eterministic mode.
$(package)_patches=fix-android.patch
define $(package)_set_vars
$(package)_config_env=AR="$($(package)_ar)" RANLIB="$($(package)_ranlib)" CC="$($(package)_cc)"
$(package)_config_env_android=ANDROID_NDK_ROOT="$(host_prefix)/native" PATH="$(host_prefix)/native/bin" CC=clang AR=ar RANLIB="ranlib -D"
$(package)_config_env_android=ANDROID_NDK_ROOT="$(host_prefix)/native" PATH="$(host_prefix)/native/bin"
$(package)_build_env_android=ANDROID_NDK_ROOT="$(host_prefix)/native"
$(package)_config_opts=--prefix=$(host_prefix) --openssldir=$(host_prefix)/etc/openssl --libdir=$(host_prefix)/lib
$(package)_config_opts+=no-capieng
@ -52,7 +50,8 @@ $(package)_config_opts_x86_64_freebsd=BSD-x86_64
endef
define $(package)_preprocess_cmds
sed -i.old 's|crypto ssl apps util tools fuzz providers doc|crypto ssl util tools providers|' build.info
sed -i.old 's|crypto ssl apps util tools fuzz providers doc|crypto ssl util tools providers|' build.info && \
patch -p1 < $($(package)_patch_dir)/fix-android.patch
endef
define $(package)_config_cmds

View File

@ -1,15 +0,0 @@
CMake 3.10.2 compatibility, see:
https://github.com/Kitware/CMake/blob/c1e087a9d3af74299d7681c9f9de59e5977a1539/Modules/Platform/Android-Determine.cmake#L105
diff --git a/build/tools/make_standalone_toolchain.py b/build/tools/make_standalone_toolchain.py
index b8172b2..1984595 100755
--- a/build/tools/make_standalone_toolchain.py
+++ b/build/tools/make_standalone_toolchain.py
@@ -208,6 +208,7 @@ def make_clang_scripts(install_dir, triple, api, windows):
target = '-'.join([arch, 'none', os_name, env])
common_flags = '-target {}{}'.format(target, api)
+ common_flags += ' -D__ANDROID_API__={}'.format(api)
# We only need mstackrealign to fix issues on 32-bit x86 pre-24. After 24,
# this consumes an extra register unnecessarily, which can cause issues for

View File

@ -1,30 +0,0 @@
diff --git a/build/tools/make_standalone_toolchain.py b/build/tools/make_standalone_toolchain.py
index b8172b2..19c0ad6 100755
--- a/build/tools/make_standalone_toolchain.py
+++ b/build/tools/make_standalone_toolchain.py
@@ -224,10 +224,10 @@ def make_clang_scripts(install_dir, triple, api, windows):
clang.write(textwrap.dedent("""\
#!/bin/bash
if [ "$1" != "-cc1" ]; then
- `dirname $0`/clang{version} {flags} "$@"
+ env -u C_INCLUDE_PATH -u CPLUS_INCLUDE_PATH -u OBJC_INCLUDE_PATH -u OBJCPLUS_INCLUDE_PATH -u CPATH -u LIBRARY_PATH `dirname $0`/clang{version} {flags} "$@"
else
# target/triple already spelled out.
- `dirname $0`/clang{version} "$@"
+ env -u C_INCLUDE_PATH -u CPLUS_INCLUDE_PATH -u OBJC_INCLUDE_PATH -u OBJCPLUS_INCLUDE_PATH -u CPATH -u LIBRARY_PATH `dirname $0`/clang{version} "$@"
fi
""".format(version=version_number, flags=unix_flags)))
@@ -239,10 +239,10 @@ def make_clang_scripts(install_dir, triple, api, windows):
clangpp.write(textwrap.dedent("""\
#!/bin/bash
if [ "$1" != "-cc1" ]; then
- `dirname $0`/clang{version}++ {flags} "$@"
+ env -u C_INCLUDE_PATH -u CPLUS_INCLUDE_PATH -u OBJC_INCLUDE_PATH -u OBJCPLUS_INCLUDE_PATH -u CPATH -u LIBRARY_PATH `dirname $0`/clang{version}++ {flags} "$@"
else
# target/triple already spelled out.
- `dirname $0`/clang{version}++ "$@"
+ env -u C_INCLUDE_PATH -u CPLUS_INCLUDE_PATH -u OBJC_INCLUDE_PATH -u OBJCPLUS_INCLUDE_PATH -u CPATH -u LIBRARY_PATH `dirname $0`/clang{version}++ "$@"
fi
""".format(version=version_number, flags=unix_flags)))

View File

@ -0,0 +1,27 @@
OpenSSL's build system tries to be helpful by constructing the compiler name
for us. This doesn't work with our setup. Instead, we want it to use
$($(package)_cc), to ensure certain environment flags are unset.
diff --git a/Configurations/15-android.conf b/Configurations/15-android.conf
index 41ad9223e0..ea27a3bbba 100644
--- a/Configurations/15-android.conf
+++ b/Configurations/15-android.conf
@@ -124,17 +124,7 @@
$user{RANLIB} = ":";
}
} elsif ($is_standalone_toolchain) {
- my $cc = $user{CC} // "clang";
- # One can probably argue that both clang and gcc should be
- # probed, but support for "standalone toolchain" was added
- # *after* announcement that gcc is being phased out, so
- # favouring clang is considered adequate. Those who insist
- # have option to enforce test for gcc with CC=gcc.
- if (which("$triarch-$cc") !~ m|^$ndk|) {
- die "no NDK $triarch-$cc on \$PATH";
- }
- $user{CC} = $cc;
- $user{CROSS_COMPILE} = "$triarch-";
+
} elsif ($user{CC} eq "clang") {
die "no NDK clang on \$PATH";
} else {

View File

@ -43,6 +43,7 @@ SET(Boost_USE_STATIC_RUNTIME ON)
SET(OPENSSL_ROOT_DIR @prefix@)
SET(ARCHITECTURE @arch@)
SET(TARGET_OS @host_os@)
# for libraries and headers in the target directories
set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) # Find programs on host
@ -84,22 +85,10 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
SET(CMAKE_CXX_STANDARD 17)
SET(LLVM_ENABLE_PIC OFF)
SET(LLVM_ENABLE_PIE OFF)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Android")
elseif(TARGET_OS STREQUAL "android")
SET(ANDROID TRUE)
if(ARCHITECTURE STREQUAL "arm")
SET(CMAKE_ANDROID_ARCH_ABI "armeabi-v7a")
SET(CMAKE_SYSTEM_PROCESSOR "armv7-a")
SET(CMAKE_ANDROID_ARM_MODE ON)
SET(CMAKE_C_COMPILER_TARGET arm-linux-androideabi)
SET(CMAKE_CXX_COMPILER_TARGET arm-linux-androideabi)
SET(_CMAKE_TOOLCHAIN_PREFIX arm-linux-androideabi-)
elseif(ARCHITECTURE STREQUAL "aarch64")
SET(CMAKE_ANDROID_ARCH_ABI "arm64-v8a")
SET(CMAKE_SYSTEM_PROCESSOR "aarch64")
endif()
SET(CMAKE_ANDROID_STANDALONE_TOOLCHAIN @prefix@/native)
SET(CMAKE_C_COMPILER "${_CMAKE_TOOLCHAIN_PREFIX}clang")
SET(CMAKE_CXX_COMPILER "${_CMAKE_TOOLCHAIN_PREFIX}clang++")
SET(CMAKE_C_COMPILER @CC@)
SET(CMAKE_CXX_COMPILER @CXX@)
else()
if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
SET(CMAKE_ASM_COMPILER clang)