Skip to content

Commit

Permalink
Support 16 KB page sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsmith committed Oct 2, 2024
1 parent 746f104 commit 65d87e3
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions android-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ fail() {
# * https://android.googlesource.com/platform/ndk/+/ndk-rXX-release/docs/BuildSystemMaintainers.md
# where XX is the NDK version. Do a diff against the version you're upgrading from, e.g.:
# https://android.googlesource.com/platform/ndk/+/ndk-r25-release..ndk-r26-release/docs/BuildSystemMaintainers.md
ndk_version=26.2.11394342
ndk_version=27.1.12297006

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

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

export CFLAGS=""
export LDFLAGS="-Wl,--build-id=sha1 -Wl,--no-rosegment"
export CFLAGS="-D__BIONIC_NO_PAGE_SIZE_MACRO"
export LDFLAGS="-Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,-z,max-page-size=16384"

# Many packages get away with omitting this on standard Linux, but Android is stricter.
# Unlike Linux, Android does not implicitly use a dlopened library to resolve
# relocations in subsequently-loaded libraries, even if RTLD_GLOBAL is used
# (https://github.com/android/ndk/issues/1244). So any library that fails to
# build with this flag, would also fail to load at runtime.
LDFLAGS="$LDFLAGS -Wl,--no-undefined"

# Many packages get away with omitting -lm on Linux, but Android is stricter.
LDFLAGS="$LDFLAGS -lm"

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

if [ -n "${PREFIX:-}" ]; then
abs_prefix=$(realpath $PREFIX)
CFLAGS+=" -I$abs_prefix/include"
LDFLAGS+=" -L$abs_prefix/lib"

# Use -idirafter so that package-specified -I directories take priority. For
# example, grpcio provides its own BoringSSL headers which must be used rather than
# our OpenSSL.
CFLAGS="$CFLAGS -idirafter $abs_prefix/include"
LDFLAGS="$LDFLAGS -L$abs_prefix/lib"

export PKG_CONFIG="pkg-config --define-prefix"
export PKG_CONFIG_LIBDIR="$abs_prefix/lib/pkgconfig"
Expand Down

0 comments on commit 65d87e3

Please sign in to comment.