Skip to content

Commit 3ab2748

Browse files
authored
Merge pull request #34 from gnustep/android-16k
Android 16 KiB page alignment and OpenSSL upstream builds
2 parents 4c11b70 + 063bc2e commit 3ab2748

3 files changed

Lines changed: 87 additions & 14 deletions

File tree

patches/openssl-android-16k.patch

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
From 66ed6db2ac83430e5bb768a44308df04ad685847 Mon Sep 17 00:00:00 2001
2+
From: vkryl <6242627+vkryl@users.noreply.github.com>
3+
Date: Fri, 15 Aug 2025 15:01:51 +0300
4+
Subject: [PATCH] Android: Enable 16 KB ELF alignment for `arm64-v8a` and
5+
`x86_64` platforms
6+
7+
CLA: trivial
8+
---
9+
Configurations/15-android.conf | 2 ++
10+
1 file changed, 2 insertions(+)
11+
12+
diff --git a/Configurations/15-android.conf b/Configurations/15-android.conf
13+
index 1de6b7a91571d..26d9d6508f582 100644
14+
--- a/Configurations/15-android.conf
15+
+++ b/Configurations/15-android.conf
16+
@@ -232,6 +232,7 @@ my %targets = (
17+
bn_ops => add("RC4_CHAR"),
18+
asm_arch => 'aarch64',
19+
perlasm_scheme => "linux64",
20+
+ shared_ldflag => add("-Wl,-z,max-page-size=16384"),
21+
},
22+
23+
"android-mips" => {
24+
@@ -269,6 +270,7 @@ my %targets = (
25+
bn_ops => add("RC4_INT"),
26+
asm_arch => 'x86_64',
27+
perlasm_scheme => "elf",
28+
+ shared_ldflag => add("-Wl,-z,max-page-size=16384"),
29+
},
30+
31+
"android-riscv64" => {

phases/18-openssl.sh

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,62 @@ set -e # make any subsequent failing command exit the script
55
. `dirname $0`/../scripts/common.sh
66

77
PROJECT=openssl
8-
GITHUB_REPO=KDAB/android_openssl
8+
GITHUB_REPO=openssl/openssl
9+
TAG=$(get_latest_github_release_tag $GITHUB_REPO)
910

1011
# load environment and prepare project
1112
if ! prepare_project $PROJECT $GITHUB_REPO; then
1213
exit 0
1314
fi
1415

15-
echo -e "\n### Installing headers"
16+
BUILD_TARGET=
17+
case $ABI_NAME in
18+
armeabi-v7a)
19+
BUILD_TARGET=android-arm
20+
;;
21+
arm64-v8a)
22+
BUILD_TARGET=android-arm64
23+
;;
24+
x86)
25+
BUILD_TARGET=android-x86
26+
;;
27+
x86_64)
28+
BUILD_TARGET=android-x86_64
29+
;;
30+
*)
31+
esac
32+
33+
SSL_BUILD_TYPE=release
34+
if [ "${BUILD_TYPE}" = "Debug" ]; then
35+
SSL_BUILD_TYPE=debug
36+
fi
37+
38+
ANDROID_NDK_MAJOR=`basename $ANDROID_NDK_ROOT | cut -d. -f1`
39+
ASM=
40+
# Seems like there is a bug in the r26 ndk which prevents us from compiling some assembly
41+
if [ "$ANDROID_NDK_MAJOR" = "26" ]; then
42+
ASM=no-asm
43+
fi
1644

17-
cp -Rf ssl_3/include/ ${INSTALL_PREFIX}/include
1845

19-
echo -e "\n### Installing libraries"
46+
echo -e "\n### Running configure"
47+
PATH=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/${HOST_TAG}/bin:$PATH
48+
./Configure \
49+
shared \
50+
no-docs \
51+
no-apps \
52+
${ASM} \
53+
${BUILD_TARGET} \
54+
--prefix="${INSTALL_PREFIX}" \
55+
--${SSL_BUILD_TYPE} \
56+
-U__ANDROID_API__ \
57+
-D__ANDROID_API__="${ANDROID_API_LEVEL}" \
2058

21-
cp -f ssl_3/$ABI_NAME/*.so ${INSTALL_PREFIX}/lib
59+
echo -e "\n### Building"
60+
make -j${MAKE_JOBS}
2261

23-
# create version-less symlinks for libcrypto/libssl.so to versioned libraries
24-
libraries=`ls ssl_3/$ABI_NAME/*.so`
25-
cd ${INSTALL_PREFIX}/lib
26-
for lib in $libraries; do
27-
libname=`basename $lib`
28-
if [[ $libname =~ ([a-z]+)[0-9\_]+.so ]]; then
29-
ln -sf $libname ${BASH_REMATCH[1]}.so
30-
fi
31-
done
62+
echo -e "\n### Installing"
63+
make install
3264

3365
echo -e "\n### Downloading CA bundle (must be installed into Android app bundle)"
3466
mkdir -p "$CACHE_ROOT"

scripts/toolchain.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,28 @@ export CFLAGS="$OPTFLAG -fstack-protector-strong -D_FORTIFY_SOURCE=2 -fPIC"
4040
# --gc-sections is recommended to decrease binary size
4141
export LDFLAGS="-L${INSTALL_PREFIX}/lib -fuse-ld=lld -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--gc-sections"
4242

43+
ADDITIONAL_CMAKE_FLAGS=
4344
case $ABI_NAME in
4445
armeabi-v7a)
4546
# use Thumb instruction set for smaller code
4647
export CFLAGS="$CFLAGS -mthumb"
4748
# don't export symbols from libunwind
4849
export LDFLAGS="$LDFLAGS -Wl,--exclude-libs,libunwind.a"
4950
;;
51+
arm64-v8a)
52+
export LDFLAGS="$LDFLAGS -Wl,-z,max-page-size=16384"
53+
ADDITIONAL_CMAKE_FLAGS="-Wl,-z,max-page-size=16384"
54+
;;
5055
x86)
5156
# properly align stacks for global constructors when targeting API < 24
5257
if [ "$ANDROID_API_LEVEL" -lt "24" ]; then
5358
export CFLAGS="$CFLAGS -mstackrealign"
5459
fi
5560
;;
61+
x86_64)
62+
export LDFLAGS="$LDFLAGS -Wl,-z,max-page-size=16384"
63+
ADDITIONAL_CMAKE_FLAGS="-Wl,-z,max-page-size=16384"
64+
;;
5665
esac
5766

5867
export CXXFLAGS=$CFLAGS
@@ -72,4 +81,5 @@ CMAKE_OPTIONS=" \
7281
-DANDROID_NDK=${ANDROID_NDK_ROOT} \
7382
-DANDROID_PLATFORM=android-${ANDROID_API_LEVEL} \
7483
-DANDROID_STL=c++_shared \
84+
-DCMAKE_SHARED_LINKER_FLAGS=$ADDITIONAL_CMAKE_FLAGS \
7585
"

0 commit comments

Comments
 (0)