Skip to content

Commit 65d87e3

Browse files
committed
Support 16 KB page sizes
1 parent 746f104 commit 65d87e3

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

android-env.sh

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ fail() {
2424
# * https://android.googlesource.com/platform/ndk/+/ndk-rXX-release/docs/BuildSystemMaintainers.md
2525
# where XX is the NDK version. Do a diff against the version you're upgrading from, e.g.:
2626
# 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
2828

2929
ndk=$ANDROID_HOME/ndk/$ndk_version
3030
if ! [ -e $ndk ]; then
31-
log "Installing NDK: this may take several minutes"
31+
log "Installing NDK - this may take several minutes"
3232
yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager "ndk;$ndk_version"
3333
fi
3434

@@ -58,10 +58,16 @@ for path in "$AR" "$AS" "$CC" "$CXX" "$LD" "$NM" "$RANLIB" "$READELF" "$STRIP";
5858
fi
5959
done
6060

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"
6363

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.
6571
LDFLAGS="$LDFLAGS -lm"
6672

6773
# -mstackrealign is included where necessary in the clang launcher scripts which are
@@ -72,8 +78,12 @@ fi
7278

7379
if [ -n "${PREFIX:-}" ]; then
7480
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"
7787

7888
export PKG_CONFIG="pkg-config --define-prefix"
7989
export PKG_CONFIG_LIBDIR="$abs_prefix/lib/pkgconfig"

0 commit comments

Comments
 (0)