@@ -24,11 +24,11 @@ fail() {
24
24
# * https://android.googlesource.com/platform/ndk/+/ndk-rXX-release/docs/BuildSystemMaintainers.md
25
25
# where XX is the NDK version. Do a diff against the version you're upgrading from, e.g.:
26
26
# https://android.googlesource.com/platform/ndk/+/ndk-r25-release..ndk-r26-release/docs/BuildSystemMaintainers.md
27
- ndk_version=26.2.11394342
27
+ ndk_version=27.1.12297006
28
28
29
29
ndk=$ANDROID_HOME /ndk/$ndk_version
30
30
if ! [ -e $ndk ]; then
31
- log " Installing NDK: this may take several minutes"
31
+ log " Installing NDK - this may take several minutes"
32
32
yes | $ANDROID_HOME /cmdline-tools/latest/bin/sdkmanager " ndk;$ndk_version "
33
33
fi
34
34
@@ -58,10 +58,16 @@ for path in "$AR" "$AS" "$CC" "$CXX" "$LD" "$NM" "$RANLIB" "$READELF" "$STRIP";
58
58
fi
59
59
done
60
60
61
- export CFLAGS=" "
62
- export LDFLAGS=" -Wl,--build-id=sha1 -Wl,--no-rosegment"
61
+ export CFLAGS=" -D__BIONIC_NO_PAGE_SIZE_MACRO "
62
+ export LDFLAGS=" -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,-z,max-page-size=16384 "
63
63
64
- # Many packages get away with omitting this on standard Linux, but Android is stricter.
64
+ # Unlike Linux, Android does not implicitly use a dlopened library to resolve
65
+ # relocations in subsequently-loaded libraries, even if RTLD_GLOBAL is used
66
+ # (https://github.com/android/ndk/issues/1244). So any library that fails to
67
+ # build with this flag, would also fail to load at runtime.
68
+ LDFLAGS=" $LDFLAGS -Wl,--no-undefined"
69
+
70
+ # Many packages get away with omitting -lm on Linux, but Android is stricter.
65
71
LDFLAGS=" $LDFLAGS -lm"
66
72
67
73
# -mstackrealign is included where necessary in the clang launcher scripts which are
72
78
73
79
if [ -n " ${PREFIX:- } " ]; then
74
80
abs_prefix=$( realpath $PREFIX )
75
- CFLAGS+=" -I$abs_prefix /include"
76
- LDFLAGS+=" -L$abs_prefix /lib"
81
+
82
+ # Use -idirafter so that package-specified -I directories take priority. For
83
+ # example, grpcio provides its own BoringSSL headers which must be used rather than
84
+ # our OpenSSL.
85
+ CFLAGS=" $CFLAGS -idirafter $abs_prefix /include"
86
+ LDFLAGS=" $LDFLAGS -L$abs_prefix /lib"
77
87
78
88
export PKG_CONFIG=" pkg-config --define-prefix"
79
89
export PKG_CONFIG_LIBDIR=" $abs_prefix /lib/pkgconfig"
0 commit comments