Update to use android-ndk r23

This commit is contained in:
Henrik Grimler 2021-09-16 21:51:29 +02:00
parent e91e3d31c1
commit a465f14c90
11 changed files with 52 additions and 81 deletions

View File

@ -1,16 +0,0 @@
diff -uNr sysroot.orig/usr/include/linux/fcntl.h sysroot/usr/include/linux/fcntl.h
--- sysroot.orig/usr/include/linux/fcntl.h 2019-02-12 16:12:24.000000000 +0000
+++ sysroot/usr/include/linux/fcntl.h 2019-03-20 13:22:32.823142545 +0000
@@ -51,6 +51,12 @@
#define DN_ATTRIB 0x00000020
#define DN_MULTISHOT 0x80000000
#define AT_FDCWD - 100
+/* Termux patch: This flag is not supported on Android 6.0+, and should not
+ be needed since there are not setuid binaries. Define AT_EACCESS to 0 to
+ avoid packages defining their own AT_EACCESS (which e.g. coreutil does)
+ since that will only result in errors. See:
+ https://android.googlesource.com/platform/bionic/+/3577825%5E!/ */
+#define AT_EACCESS 0
#define AT_SYMLINK_NOFOLLOW 0x100
#define AT_REMOVEDIR 0x200
#define AT_SYMLINK_FOLLOW 0x400

View File

@ -1,5 +1,5 @@
--- ./usr/include/paths.h.orig 2020-07-10 21:50:03.778299300 +0000
+++ ./usr/include/paths.h 2020-07-10 21:51:03.127602196 +0000
--- ./usr/include/paths.h.orig 2021-08-16 11:55:04.492150066 +0200
+++ ./usr/include/paths.h 2021-08-16 11:55:42.498804733 +0200
@@ -40,14 +40,14 @@
#ifndef _PATH_BSHELL
@ -12,7 +12,7 @@
#define _PATH_CONSOLE "/dev/console"
/** Default shell search path. */
-#define _PATH_DEFPATH "/product/bin:/apex/com.android.runtime/bin:/apex/com.android.art/bin:/system/bin:/system/xbin:/odm/bin:/vendor/bin:/vendor/xbin"
-#define _PATH_DEFPATH "/product/bin:/apex/com.android.runtime/bin:/apex/com.android.art/bin:/system_ext/bin:/system/bin:/system/xbin:/odm/bin:/vendor/bin:/vendor/xbin"
+#define _PATH_DEFPATH "@TERMUX_PREFIX@/bin"
/** Path to the directory containing device files. */

View File

@ -1,7 +1,6 @@
diff -uNr ./usr.old/include/stdio.h ./usr/include/stdio.h
--- ./usr.old/include/stdio.h 2019-05-22 12:49:28.000000000 +0300
+++ ./usr/include/stdio.h 2019-12-13 21:50:02.765565736 +0200
@@ -44,11 +44,12 @@
--- ./usr/include/stdio.h.orig 2021-08-16 11:48:44.308954400 +0200
+++ ./usr/include/stdio.h 2021-08-16 11:50:00.438924014 +0200
@@ -44,6 +44,9 @@
#include <stdarg.h>
#include <stddef.h>
@ -10,16 +9,11 @@ diff -uNr ./usr.old/include/stdio.h ./usr/include/stdio.h
+
#include <bits/seek_constants.h>
-#if __ANDROID_API__ < __ANDROID_API_N__
#include <bits/struct_file.h>
-#endif
__BEGIN_DECLS
#if __ANDROID_API__ < 24
@@ -165,7 +166,7 @@
__printflike(2, 0) __warnattr_strict("vsprintf is often misused; please use vsnprintf");
char* tmpnam(char* __s)
__warnattr("tempnam is unsafe, use mkstemp or tmpfile instead");
__warnattr("tmpnam is unsafe, use mkstemp or tmpfile instead");
-#define P_tmpdir "/tmp/" /* deprecated */
+#define P_tmpdir "@TERMUX_PREFIX@/tmp/" /* deprecated */
char* tempnam(const char* __dir, const char* __prefix)

View File

@ -1,6 +1,5 @@
diff -uNr sysroot.orig/usr/include/stdlib.h sysroot/usr/include/stdlib.h
--- sysroot.orig/usr/include/stdlib.h 2019-02-12 16:12:24.000000000 +0000
+++ sysroot/usr/include/stdlib.h 2019-03-20 13:23:48.870108924 +0000
--- ./usr/include/stdlib.h.orig 2021-08-16 11:50:47.432239182 +0200
+++ ./usr/include/stdlib.h 2021-08-16 11:51:31.102222894 +0200
@@ -33,6 +33,7 @@
#include <bits/wait.h>
#include <malloc.h>
@ -12,7 +11,7 @@ diff -uNr sysroot.orig/usr/include/stdlib.h sysroot/usr/include/stdlib.h
@@ -224,8 +225,7 @@
size_t wcstombs(char* __dst, const wchar_t* __src, size_t __n);
#if __ANDROID_API__ >= __ANDROID_API_L__
#if __ANDROID_API__ >= 21
-size_t __ctype_get_mb_cur_max(void) __INTRODUCED_IN(21);
-#define MB_CUR_MAX __ctype_get_mb_cur_max()
+#define MB_CUR_MAX 4

View File

@ -1,6 +1,6 @@
--- ./usr/include/sys/cdefs.h.orig 2020-01-18 00:06:05.760188085 +0000
+++ ./usr/include/sys/cdefs.h 2020-01-18 00:09:52.363968728 +0000
@@ -358,3 +358,6 @@
--- ./usr/include/sys/cdefs.h.orig 2021-08-16 11:52:08.128876161 +0200
+++ ./usr/include/sys/cdefs.h 2021-08-16 11:52:08.555542676 +0200
@@ -372,3 +372,6 @@
#if __has_include(<android/ndk-version.h>)
#include <android/ndk-version.h>
#endif

View File

@ -1,6 +1,6 @@
--- sysroot/usr/include/unistd.h 2018-04-30 19:24:22.000000000 +0000
+++ usr/include/unistd.h 2018-08-16 10:42:51.158596753 +0000
@@ -377,4 +377,72 @@
--- ./usr/include/unistd.h.orig 2021-08-16 11:52:08.095542840 +0200
+++ ./usr/include/unistd.h 2021-08-16 11:52:08.565542673 +0200
@@ -375,6 +375,74 @@
#undef _UNISTD_H_
#endif
@ -73,3 +73,5 @@
+#endif
+
__END_DECLS
#include <android/legacy_unistd_inlines.h>

View File

@ -1,6 +1,6 @@
--- sysroot/usr/include/utmp.h 2021-05-07 05:45:33.518467959 +0000
+++ usr/include/utmp.h 2021-05-07 05:46:25.195022662 +0000
@@ -32,9 +32,9 @@
--- ./usr/include/utmp.h.orig 2021-08-16 11:52:08.095542840 +0200
+++ ./usr/include/utmp.h 2021-08-16 11:52:08.565542673 +0200
@@ -37,9 +37,9 @@
#include <sys/types.h>
#include <time.h>

View File

@ -8,14 +8,14 @@ termux_step_setup_toolchain() {
export AS=$TERMUX_HOST_PLATFORM-clang
export CC=$TERMUX_HOST_PLATFORM-clang
export CXX=$TERMUX_HOST_PLATFORM-clang++
export AR=$TERMUX_HOST_PLATFORM-ar
export AR=llvm-ar
export CPP=$TERMUX_HOST_PLATFORM-cpp
export LD=$TERMUX_HOST_PLATFORM-ld
export OBJCOPY=$TERMUX_HOST_PLATFORM-objcopy
export OBJDUMP=$TERMUX_HOST_PLATFORM-objdump
export RANLIB=$TERMUX_HOST_PLATFORM-ranlib
export READELF=$TERMUX_HOST_PLATFORM-readelf
export STRIP=$TERMUX_HOST_PLATFORM-strip
export LD=ld.lld
export OBJCOPY=llvm-objcopy
export OBJDUMP=llvm-objdump
export RANLIB=llvm-ranlib
export READELF=llvm-readelf
export STRIP=llvm-strip
if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then
export PATH=$TERMUX_STANDALONE_TOOLCHAIN/bin:$PATH
@ -146,26 +146,6 @@ termux_setup_standalone_toolchain() {
# Remove android-support header wrapping not needed on android-21:
rm -Rf $_TERMUX_TOOLCHAIN_TMPDIR/sysroot/usr/local
# Use gold by default to work around https://github.com/android-ndk/ndk/issues/148
cp $_TERMUX_TOOLCHAIN_TMPDIR/bin/aarch64-linux-android-ld.gold \
$_TERMUX_TOOLCHAIN_TMPDIR/bin/aarch64-linux-android-ld
cp $_TERMUX_TOOLCHAIN_TMPDIR/aarch64-linux-android/bin/ld.gold \
$_TERMUX_TOOLCHAIN_TMPDIR/aarch64-linux-android/bin/ld
# Linker wrapper script to add '--exclude-libs libgcc.a', see
# https://github.com/android-ndk/ndk/issues/379
# https://android-review.googlesource.com/#/c/389852/
local linker
for linker in ld ld.bfd ld.gold; do
local wrap_linker=$_TERMUX_TOOLCHAIN_TMPDIR/arm-linux-androideabi/bin/$linker
local real_linker=$_TERMUX_TOOLCHAIN_TMPDIR/arm-linux-androideabi/bin/$linker.real
cp $wrap_linker $real_linker
echo '#!/bin/bash' > $wrap_linker
echo -n '$(dirname $0)/' >> $wrap_linker
echo -n $linker.real >> $wrap_linker
echo ' --exclude-libs libunwind.a --exclude-libs libgcc_real.a "$@"' >> $wrap_linker
done
for HOST_PLAT in aarch64-linux-android armv7a-linux-androideabi i686-linux-android x86_64-linux-android; do
cp $_TERMUX_TOOLCHAIN_TMPDIR/bin/$HOST_PLAT$TERMUX_PKG_API_LEVEL-clang \
$_TERMUX_TOOLCHAIN_TMPDIR/bin/$HOST_PLAT-clang
@ -206,13 +186,20 @@ termux_setup_standalone_toolchain() {
# Remove <glob.h> as we currently provide it from libandroid-glob.
# Remove <iconv.h> as it's provided by libiconv.
# Remove <spawn.h> as it's only for future (later than android-27).
# Remove <zlib.h> and <zconf.h> as we build our own zlib
rm usr/include/sys/{capability.h,shm.h,sem.h} usr/include/{glob.h,iconv.h,spawn.h,zlib.h,zconf.h}
# Remove <zlib.h> and <zconf.h> as we build our own zlib.
# Remove unicode headers provided by libicu.
rm usr/include/{sys/{capability,shm,sem},{glob,iconv,spawn,zlib,zconf}}.h
rm usr/include/unicode/{char16ptr,platform,ptypes,putil,stringoptions,ubidi,ubrk,uchar,uconfig,ucpmap,udisplaycontext,uenum,uldnames,ulocdata,uloc,umachine,unorm2,urename,uscript,ustring,utext,utf16,utf8,utf,utf_old,utypes,uvernum,uversion}.h
sed -i "s/define __ANDROID_API__ __ANDROID_API_FUTURE__/define __ANDROID_API__ $TERMUX_PKG_API_LEVEL/" \
usr/include/android/api-level.h
$TERMUX_ELF_CLEANER usr/lib/*/*/*.so
for dir in usr/lib/*; do
# This seem to be needed when building rust
# packages
echo 'INPUT(-lunwind)' > $dir/libgcc.a
done
grep -lrw $_TERMUX_TOOLCHAIN_TMPDIR/sysroot/usr/include/c++/v1 -e '<version>' | xargs -n 1 sed -i 's/<version>/\"version\"/g'
mv $_TERMUX_TOOLCHAIN_TMPDIR $TERMUX_STANDALONE_TOOLCHAIN

View File

@ -2,7 +2,7 @@ termux_step_start_build() {
TERMUX_STANDALONE_TOOLCHAIN="$TERMUX_COMMON_CACHEDIR/android-r${TERMUX_NDK_VERSION}-api-${TERMUX_PKG_API_LEVEL}"
# Bump the below version if a change is made in toolchain setup to ensure
# that everyone gets an updated toolchain:
TERMUX_STANDALONE_TOOLCHAIN+="-v5"
TERMUX_STANDALONE_TOOLCHAIN+="-v0"
# shellcheck source=/dev/null
source "$TERMUX_PKG_BUILDER_SCRIPT"

View File

@ -1,6 +1,6 @@
TERMUX_ANDROID_BUILD_TOOLS_VERSION=30.0.3
TERMUX_NDK_VERSION_NUM=21
TERMUX_NDK_REVISION="d"
TERMUX_NDK_VERSION_NUM=23
TERMUX_NDK_REVISION=""
TERMUX_NDK_VERSION=$TERMUX_NDK_VERSION_NUM$TERMUX_NDK_REVISION
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64

View File

@ -4,10 +4,10 @@ set -e -u
# Install desired parts of the Android SDK:
. $(cd "$(dirname "$0")"; pwd)/properties.sh
ANDROID_SDK_FILE=sdk-tools-linux-4333796.zip
ANDROID_SDK_SHA256=92ffee5a1d98d856634e8b71132e8a95d96c83a63fde1099be3d86df3106def9
ANDROID_NDK_FILE=android-ndk-r${TERMUX_NDK_VERSION}-Linux-x86_64.zip
ANDROID_NDK_SHA256=dd6dc090b6e2580206c64bcee499bc16509a5d017c6952dcd2bed9072af67cbd
ANDROID_SDK_FILE=commandlinetools-linux-7583922_latest.zip
ANDROID_SDK_SHA256=124f2d5115eee365df6cf3228ffbca6fc3911d16f8025bebd5b1c6e2fcfa7faf
ANDROID_NDK_FILE=android-ndk-r${TERMUX_NDK_VERSION}-linux.zip
ANDROID_NDK_SHA256=e3eacf80016b91d4cd2c8ca9f34eebd32df912bb799c859cc5450b6b19277b4f
if [ ! -d $ANDROID_HOME ]; then
mkdir -p $ANDROID_HOME
cd $ANDROID_HOME/..
@ -39,7 +39,12 @@ if [ ! -d $NDK ]; then
rm ndk.zip
fi
yes | $ANDROID_HOME/tools/bin/sdkmanager --licenses
yes | $ANDROID_HOME/cmdline-tools/bin/sdkmanager --sdk_root=$ANDROID_HOME --licenses
# The android platforms are used in the ecj and apksigner packages:
yes | $ANDROID_HOME/tools/bin/sdkmanager "platform-tools" "build-tools;${TERMUX_ANDROID_BUILD_TOOLS_VERSION}" "platforms;android-28" "platforms;android-24" "platforms;android-21"
yes | $ANDROID_HOME/cmdline-tools/bin/sdkmanager --sdk_root=$ANDROID_HOME \
"platform-tools" \
"build-tools;${TERMUX_ANDROID_BUILD_TOOLS_VERSION}" \
"platforms;android-28" \
"platforms;android-24" \
"platforms;android-21"