Skip to content

Commit d0f4522

Browse files
its-pointlessLeonid Plyushch
authored andcommitted
ndk-20 update
1 parent f210127 commit d0f4522

File tree

5 files changed

+107
-102
lines changed

5 files changed

+107
-102
lines changed
Lines changed: 53 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
diff -u -r /home/fornwall/lib/android-ndk/sysroot/usr/include/bits/struct_file.h ./usr/include/bits/struct_file.h
2-
--- /home/fornwall/lib/android-ndk/sysroot/usr/include/bits/struct_file.h 2017-06-20 17:41:56.000000000 +0200
3-
+++ ./usr/include/bits/struct_file.h 2017-06-26 13:35:19.040117023 +0200
4-
@@ -33,13 +33,80 @@
1+
--- ./usr/include/bits/struct_file.h.orig 2019-06-10 09:40:35.872857650 +1000
2+
+++ ./usr/include/bits/struct_file.h 2019-06-10 09:55:10.890308649 +1000
3+
@@ -31,14 +31,79 @@
4+
#include <sys/cdefs.h>
55

66
__BEGIN_DECLS
7-
87
+#if defined(__LP64__)
98
+struct __sbuf {
109
+ unsigned char* _base;
@@ -13,75 +12,74 @@ diff -u -r /home/fornwall/lib/android-ndk/sysroot/usr/include/bits/struct_file.h
1312
+#else
1413
+struct __sbuf {
1514
+ unsigned char *_base;
16-
+ int _size;
15+
+ int _size;
1716
+};
18-
+#endif
19-
+
17+
+#endif
2018
+#if defined(__LP64__)
2119
+typedef int64_t _struct_file_off_t;
2220
+#else
2321
+typedef __kernel_off_t _struct_file_off_t;
2422
+#endif
25-
+
23+
+
24+
25+
/** The opaque structure implementing `FILE`. Do not make any assumptions about its content. */
2626
struct __sFILE {
27-
+ unsigned char *_p; /* current position in (some) buffer */
28-
+ int _r; /* read space left for getc() */
29-
+ int _w; /* write space left for putc() */
27+
+ unsigned char *_p; /* current position in (some) buffer */
28+
+ int _r; /* read space left for getc() */
29+
+ int _w; /* write space left for putc() */
3030
#if defined(__LP64__)
3131
- char __private[152];
32-
+ int _flags; /* flags, below; this FILE is free if 0 */
33-
+ int _file; /* fileno, if Unix descriptor, else -1 */
32+
+ int _flags; /* flags, below; this FILE is free if 0 */
33+
+ int _file; /* fileno, if Unix descriptor, else -1 */
3434
#else
3535
- char __private[84];
36-
+ short _flags; /* flags, below; this FILE is free if 0 */
37-
+ short _file; /* fileno, if Unix descriptor, else -1 */
36+
+ short _flags; /* flags, below; this FILE is free if 0 */
37+
+ short _file; /* fileno, if Unix descriptor, else -1 */
3838
#endif
3939
-} __attribute__((aligned(sizeof(void*))));
40-
+ struct __sbuf _bf; /* the buffer (at least 1 byte, if !NULL) */
41-
+ int _lbfsize; /* 0 or -_bf._size, for inline putc */
42-
+
43-
+ /* operations */
44-
+ void *_cookie; /* cookie passed to io functions */
45-
+ int (*_close)(void *);
46-
+ int (*_read)(void *, char *, int);
47-
+ _struct_file_off_t (*_seek)(void *, _struct_file_off_t, int);
48-
+ int (*_write)(void *, const char *, int);
49-
+
40+
+ struct __sbuf _bf; /* the buffer (at least 1 byte, if !NULL) */
41+
+ int _lbfsize; /* 0 or -_bf._size, for inline putc */
42+
+
43+
+ /* operations */
44+
+ void *_cookie; /* cookie passed to io functions */
45+
+ int (*_close)(void *);
46+
+ int (*_read)(void *, char *, int);
47+
+ _struct_file_off_t (*_seek)(void *, _struct_file_off_t, int);
48+
+ int (*_write)(void *, const char *, int);
49+
+
5050
+ /* extension data, to avoid further ABI breakage */
51-
+ struct __sbuf _ext;
51+
+ struct __sbuf _ext;
5252
+ /* data for long sequences of ungetc() */
53-
+ unsigned char *_up; /* saved _p when _p is doing ungetc data */
54-
+ int _ur; /* saved _r when _r is counting ungetc data */
55-
+
53+
+ unsigned char *_up; /* saved _p when _p is doing ungetc data */
54+
+ int _ur; /* saved _r when _r is counting ungetc data */
55+
+
5656
+ /* tricks to meet minimum requirements even when malloc() fails */
57-
+ unsigned char _ubuf[3]; /* guarantee an ungetc() buffer */
58-
+ unsigned char _nbuf[1]; /* guarantee a getc() buffer */
59-
+
57+
+ unsigned char _ubuf[3]; /* guarantee an ungetc() buffer */
58+
+ unsigned char _nbuf[1]; /* guarantee a getc() buffer */
59+
+
6060
+ /* separate buffer for fgetln() when line crosses buffer boundary */
61-
+ struct __sbuf _lb; /* buffer for fgetln() */
62-
+
61+
+ struct __sbuf _lb; /* buffer for fgetln() */
62+
+
6363
+ /* Unix stdio files get aligned to block boundaries on fseek() */
64-
+ int _blksize; /* stat.st_blksize (may be != _bf._size) */
65-
+ _struct_file_off_t _offset; /* current lseek offset */
64+
+ int _blksize; /* stat.st_blksize (may be != _bf._size) */
65+
+ _struct_file_off_t _offset; /* current lseek offset */
6666
+};
67-
+
68-
+#define __SLBF 0x0001 /* line buffered */
69-
+#define __SNBF 0x0002 /* unbuffered */
70-
+#define __SRD 0x0004 /* OK to read */
71-
+#define __SWR 0x0008 /* OK to write */
67+
+#define __SLBF 0x0001 /* line buffered */
68+
+#define __SNBF 0x0002 /* unbuffered */
69+
+#define __SRD 0x0004 /* OK to read */
70+
+#define __SWR 0x0008 /* OK to write */
7271
+ /* RD and WR are never simultaneously asserted */
73-
+#define __SRW 0x0010 /* open for reading & writing */
74-
+#define __SEOF 0x0020 /* found EOF */
75-
+#define __SERR 0x0040 /* found error */
76-
+#define __SMBF 0x0080 /* _buf is from malloc */
77-
+#define __SAPP 0x0100 /* fdopen()ed in append mode */
78-
+#define __SSTR 0x0200 /* this is an sprintf/snprintf string */
79-
+#define __SOPT 0x0400 /* do fseek() optimization */
80-
+#define __SNPT 0x0800 /* do not do fseek() optimization */
81-
+#define __SOFF 0x1000 /* set iff _offset is in fact correct */
82-
+#define __SMOD 0x2000 /* true => fgetln modified _p text */
83-
+#define __SALC 0x4000 /* allocate string space dynamically */
84-
+#define __SIGN 0x8000 /* ignore this file in _fwalk */
72+
+#define __SRW 0x0010 /* open for reading & writing */
73+
+#define __SEOF 0x0020 /* found EOF */
74+
+#define __SERR 0x0040 /* found error */
75+
+#define __SMBF 0x0080 /* _buf is from malloc */
76+
+#define __SAPP 0x0100 /* fdopen()ed in append mode */
77+
+#define __SSTR 0x0200 /* this is an sprintf/snprintf string */
78+
+#define __SOPT 0x0400 /* do fseek() optimization */
79+
+#define __SNPT 0x0800 /* do not do fseek() optimization */
80+
+#define __SOFF 0x1000 /* set iff _offset is in fact correct */
81+
+#define __SMOD 0x2000 /* true => fgetln modified _p text */
82+
+#define __SALC 0x4000 /* allocate string space dynamically */
83+
+#define __SIGN 0x8000 /* ignore this file in _fwalk */
8584

8685
__END_DECLS
87-

ndk-patches/paths.h.patch

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,31 @@
1-
diff -u -r /home/fornwall/lib/android-ndk/sysroot/usr/include/paths.h ./usr/include/paths.h
2-
--- /home/fornwall/lib/android-ndk/sysroot/usr/include/paths.h 2017-11-09 09:57:12.000000000 +0100
3-
+++ ./usr/include/paths.h 2017-11-15 11:51:24.456129565 +0100
4-
@@ -34,15 +34,19 @@
1+
--- ./usr/include/paths.h.orig 2019-06-10 00:10:55.544212642 +0000
2+
+++ ./usr/include/paths.h 2019-06-10 00:16:51.514412646 +0000
3+
@@ -38,16 +38,14 @@
54

65
#include <sys/cdefs.h>
76

87
-#ifndef _PATH_BSHELL
9-
-#define _PATH_BSHELL "/system/bin/sh"
8+
/** Path to the default system shell. Historically the 'B' was to specify the Bourne shell. */
9+
-#define _PATH_BSHELL "/system/bin/sh"
1010
-#endif
11-
+#define _PATH_BSHELL "@TERMUX_PREFIX@/bin/sh"
12-
#define _PATH_CONSOLE "/dev/console"
13-
-#define _PATH_DEFPATH "/sbin:/system/sbin:/system/bin:/system/xbin:/odm/bin:/vendor/bin:/vendor/xbin"
14-
+#define _PATH_DEFPATH "@TERMUX_PREFIX@/bin:@TERMUX_PREFIX@/bin/applets"
15-
#define _PATH_DEV "/dev/"
16-
#define _PATH_DEVNULL "/dev/null"
17-
#define _PATH_KLOG "/proc/kmsg"
18-
#define _PATH_MOUNTED "/proc/mounts"
19-
#define _PATH_TTY "/dev/tty"
11+
+#define _PATH_BSHELL "@TERMUX_PREFIX@/bin/sh"
2012

21-
+#define _PATH_STDPATH _PATH_DEFPATH
22-
+#define _PATH_TMP "@TERMUX_PREFIX@/tmp/"
23-
+#define _PATH_VARDB "@TERMUX_PREFIX@/var/db/"
24-
+#define _PATH_VARRUN "@TERMUX_PREFIX@/var/run/"
25-
+#define _PATH_VARTMP "@TERMUX_PREFIX@/var/tmp/"
13+
/** Path to the system console. */
14+
#define _PATH_CONSOLE "/dev/console"
15+
16+
/** Default shell search path. */
17+
-#define _PATH_DEFPATH "/sbin:/system/sbin:/product/bin:/apex/com.android.runtime/bin:/system/bin:/system/xbin:/odm/bin:/vendor/bin:/vendor/xbin"
18+
+#define _PATH_DEFPATH "@TERMUX_PREFIX@/bin:@TERMUX_PREFIX@/bin/applets"
19+
20+
/** Path to the directory containing device files. */
21+
#define _PATH_DEV "/dev/"
22+
@@ -63,3 +61,9 @@
23+
24+
/** Path to the calling process' tty. */
25+
#define _PATH_TTY "/dev/tty"
26+
+#define _PATH_STDPATH _PATH_DEFPATH
27+
+#define _PATH_TMP "@TERMUX_PREFIX@/tmp/"
28+
+#define _PATH_VARDB "@TERMUX_PREFIX@/var/db/"
29+
+#define _PATH_VARRUN "@TERMUX_PREFIX@/var/run/"
30+
+#define _PATH_VARTMP "@TERMUX_PREFIX@/var/tmp/"
2631
+
27-
#endif /* !_PATHS_H_ */

scripts/build/termux_step_setup_toolchain.sh

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -80,48 +80,51 @@ termux_step_setup_toolchain() {
8080
elif [ "$TERMUX_ARCH" = "i686" ]; then
8181
_NDK_ARCHNAME=x86
8282
fi
83-
84-
"$NDK/build/tools/make_standalone_toolchain.py" \
85-
--api "$TERMUX_PKG_API_LEVEL" \
86-
--arch $_NDK_ARCHNAME \
87-
--stl=libc++ \
88-
--install-dir $_TERMUX_TOOLCHAIN_TMPDIR
83+
cp $NDK/toolchains/llvm/prebuilt/linux-x86_64 $_TERMUX_TOOLCHAIN_TMPDIR -r
8984

9085
# Remove android-support header wrapping not needed on android-21:
9186
rm -Rf $_TERMUX_TOOLCHAIN_TMPDIR/sysroot/usr/local
9287

93-
if [ "$TERMUX_ARCH" = "aarch64" ]; then
94-
# Use gold by default to work around https://github.com/android-ndk/ndk/issues/148
95-
cp $_TERMUX_TOOLCHAIN_TMPDIR/bin/aarch64-linux-android-ld.gold \
96-
$_TERMUX_TOOLCHAIN_TMPDIR/bin/aarch64-linux-android-ld
97-
cp $_TERMUX_TOOLCHAIN_TMPDIR/aarch64-linux-android/bin/ld.gold \
98-
$_TERMUX_TOOLCHAIN_TMPDIR/aarch64-linux-android/bin/ld
99-
fi
88+
# Use gold by default to work around https://github.com/android-ndk/ndk/issues/148
89+
cp $_TERMUX_TOOLCHAIN_TMPDIR/bin/aarch64-linux-android-ld.gold \
90+
$_TERMUX_TOOLCHAIN_TMPDIR/bin/aarch64-linux-android-ld
91+
cp $_TERMUX_TOOLCHAIN_TMPDIR/aarch64-linux-android/bin/ld.gold \
92+
$_TERMUX_TOOLCHAIN_TMPDIR/aarch64-linux-android/bin/ld
10093

101-
if [ "$TERMUX_ARCH" = "arm" ]; then
10294
# Linker wrapper script to add '--exclude-libs libgcc.a', see
10395
# https://github.com/android-ndk/ndk/issues/379
10496
# https://android-review.googlesource.com/#/c/389852/
10597
local linker
10698
for linker in ld ld.bfd ld.gold; do
107-
local wrap_linker=$_TERMUX_TOOLCHAIN_TMPDIR/$TERMUX_HOST_PLATFORM/bin/$linker
108-
local real_linker=$_TERMUX_TOOLCHAIN_TMPDIR/$TERMUX_HOST_PLATFORM/bin/$linker.real
99+
local wrap_linker=$_TERMUX_TOOLCHAIN_TMPDIR/arm-linux-androideabi/bin/$linker
100+
local real_linker=$_TERMUX_TOOLCHAIN_TMPDIR/arm-linux-androideabi/bin/$linker.real
109101
cp $wrap_linker $real_linker
110102
echo '#!/bin/bash' > $wrap_linker
111103
echo -n '$(dirname $0)/' >> $wrap_linker
112104
echo -n $linker.real >> $wrap_linker
113105
echo ' --exclude-libs libunwind.a --exclude-libs libgcc_real.a "$@"' >> $wrap_linker
114106
done
115-
fi
107+
for HOST_PLAT in aarch64-linux-android armv7a-linux-androideabi i686-linux-android x86_64-linux-android; do
116108

117109
# Setup the cpp preprocessor:
118-
cp $_TERMUX_TOOLCHAIN_TMPDIR/bin/$TERMUX_HOST_PLATFORM-clang \
119-
$_TERMUX_TOOLCHAIN_TMPDIR/bin/$TERMUX_HOST_PLATFORM-cpp
120-
sed -i 's/clang80/clang80 -E/' \
121-
$_TERMUX_TOOLCHAIN_TMPDIR/bin/$TERMUX_HOST_PLATFORM-cpp
122-
110+
cp $_TERMUX_TOOLCHAIN_TMPDIR/bin/$HOST_PLAT$TERMUX_PKG_API_LEVEL-clang \
111+
$_TERMUX_TOOLCHAIN_TMPDIR/bin/$HOST_PLAT-clang
112+
cp $_TERMUX_TOOLCHAIN_TMPDIR/bin/$HOST_PLAT$TERMUX_PKG_API_LEVEL-clang++ \
113+
$_TERMUX_TOOLCHAIN_TMPDIR/bin/$HOST_PLAT-clang++
114+
cp $_TERMUX_TOOLCHAIN_TMPDIR/bin/$HOST_PLAT$TERMUX_PKG_API_LEVEL-clang \
115+
$_TERMUX_TOOLCHAIN_TMPDIR/bin/$HOST_PLAT-cpp
116+
sed -i 's/clang/clang -E/' \
117+
$_TERMUX_TOOLCHAIN_TMPDIR/bin/$HOST_PLAT-cpp
118+
cp $_TERMUX_TOOLCHAIN_TMPDIR/bin/$HOST_PLAT-clang \
119+
$_TERMUX_TOOLCHAIN_TMPDIR/bin/$HOST_PLAT-gcc
120+
cp $_TERMUX_TOOLCHAIN_TMPDIR/bin/$HOST_PLAT-clang++ \
121+
$_TERMUX_TOOLCHAIN_TMPDIR/bin/$HOST_PLAT-gcc
122+
done
123+
cp $_TERMUX_TOOLCHAIN_TMPDIR/bin/armv7a-linux-androideabi$TERMUX_PKG_API_LEVEL-clang \
124+
$_TERMUX_TOOLCHAIN_TMPDIR/bin/arm-linux-androideabi-clang
125+
cp $_TERMUX_TOOLCHAIN_TMPDIR/bin/armv7a-linux-androideabi$TERMUX_PKG_API_LEVEL-clang++ \
126+
$_TERMUX_TOOLCHAIN_TMPDIR/bin/arm-linux-androideabi-clang++
123127
cd $_TERMUX_TOOLCHAIN_TMPDIR/sysroot
124-
125128
for f in $TERMUX_SCRIPTDIR/ndk-patches/*.patch; do
126129
sed "s%\@TERMUX_PREFIX\@%${TERMUX_PREFIX}%g" "$f" | \
127130
sed "s%\@TERMUX_HOME\@%${TERMUX_ANDROID_HOME}%g" | \

scripts/build/termux_step_start_build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ termux_step_start_build() {
22
# shellcheck source=/dev/null
33
source "$TERMUX_PKG_BUILDER_SCRIPT"
44

5-
TERMUX_STANDALONE_TOOLCHAIN="$TERMUX_COMMON_CACHEDIR/${TERMUX_NDK_VERSION}-${TERMUX_ARCH}-${TERMUX_PKG_API_LEVEL}"
5+
TERMUX_STANDALONE_TOOLCHAIN="$TERMUX_COMMON_CACHEDIR/android-r${TERMUX_NDK_VERSION}-api-${TERMUX_PKG_API_LEVEL}"
66
# Bump the below version if a change is made in toolchain setup to ensure
77
# that everyone gets an updated toolchain:
8-
TERMUX_STANDALONE_TOOLCHAIN+="-v5"
8+
TERMUX_STANDALONE_TOOLCHAIN+="-v1"
99

1010
if [ -n "${TERMUX_PKG_BLACKLISTED_ARCHES:=""}" ] && [ "$TERMUX_PKG_BLACKLISTED_ARCHES" != "${TERMUX_PKG_BLACKLISTED_ARCHES/$TERMUX_ARCH/}" ]; then
1111
echo "Skipping building $TERMUX_PKG_NAME for arch $TERMUX_ARCH"

scripts/properties.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
TERMUX_ANDROID_BUILD_TOOLS_VERSION=28.0.3
2-
TERMUX_NDK_VERSION_NUM=19
3-
TERMUX_NDK_REVISION=b
2+
TERMUX_NDK_VERSION_NUM=20
3+
TERMUX_NDK_REVISION=""
44
TERMUX_NDK_VERSION=$TERMUX_NDK_VERSION_NUM$TERMUX_NDK_REVISION
55

66
test -f "$HOME/.termuxrc" && . "$HOME/.termuxrc"

0 commit comments

Comments
 (0)