fix: initial 16KB pages support (#2523)

* fix: initial 16KB pages support

all .so dependencies other than reown walletkit (`libuniffi_yttrium.so`) which is a prebuild are 16KB now

* chore: update flutter to 3.29.3

* build: 16KB align go builds
ci: update action to check for 16KB align
[skip ci]

* chore: bump flutter to 3.32.0

* fix: replace prebuilds with built versions for 16KB alignment
fix: walletkit secure storage fix
This commit is contained in:
cyan
2025-09-23 11:30:10 +03:00
committed by GitHub
parent cb9ac69e31
commit e4726c2242
33 changed files with 480 additions and 267 deletions
+1
View File
@@ -69,6 +69,7 @@ do
rm -fr ./build
fi
export CGO_LDFLAGS="-O2 -g -s -w -Wl,-z,max-page-size=16384"
CLANG_PATH="${NDK_BIN_PATH}/${TRIPLET}${ANDROID_API_VERSION}-clang"
CGO_ENABLED=1 GOOS=android GOARCH=${TARGET} CC=${CLANG_PATH} CXX=${CLANG_PATH}++ \
go build -v -buildmode=c-shared -o ./build/${TRIPLET}-libdcrwallet.so ./cgo
+5 -3
View File
@@ -25,24 +25,26 @@ export ANDROID_SDK="${HOME}/Library/Android/sdk"
export NDK_BIN="${ANDROID_HOME}/ndk/${ANDROID_NDK_VERSION}/toolchains/llvm/prebuilt/$(uname | tr '[:upper:]' '[:lower:]')-x86_64/bin"
# Compile for x86_64 architecture and place the binary file in the android/src/main/jniLibs/x86_64 folder
export CGO_LDFLAGS="-O2 -g -s -w -Wl,-z,max-page-size=16384"
CGO_ENABLED=1 \
GOOS=android \
GOARCH=amd64 \
CC=${NDK_BIN}/x86_64-linux-android21-clang \
go build -buildmode=c-shared -o ${ANDROID_OUT}/x86_64/libmweb.so .
go build -v -buildmode=c-shared -o ${ANDROID_OUT}/x86_64/libmweb.so .
# Compile for arm64 architecture and place the binary file in the android/src/main/jniLibs/arm64-v8a folder
CGO_ENABLED=1 \
GOOS=android \
GOARCH=arm64 \
CC=${NDK_BIN}/aarch64-linux-android21-clang \
go build -buildmode=c-shared -o ${ANDROID_OUT}/arm64-v8a/libmweb.so .
go build -v -buildmode=c-shared -o ${ANDROID_OUT}/arm64-v8a/libmweb.so .
# Compile for armv7a architecture and place the binary file in the android/src/main/jniLibs/armeabi-v7a folder
CGO_ENABLED=1 \
GOOS=android \
GOARCH=arm \
CC=${NDK_BIN}/armv7a-linux-androideabi21-clang \
go build -buildmode=c-shared -o ${ANDROID_OUT}/armeabi-v7a/libmweb.so .
go build -v -buildmode=c-shared -o ${ANDROID_OUT}/armeabi-v7a/libmweb.so .
cd ../
dart run ffigen --config ffigen_config.yaml
+32
View File
@@ -0,0 +1,32 @@
#!/bin/bash
# NOTE: This script is used to build the reown dependencies for the android app.
# ideally we should be able to get rid of this script when yttrium updates at some point.
# CI uses prebuilds that are provided as-is at https://static.mrcyjanek.net/lfs/cake-yttrium/
# please, do **NOT** use those prebuilds for production.
cd "$(dirname $0)"
set -x -e
if [ ! -e yttrium/.git ]; then
rm -rf yttrium
git clone https://github.com/reown-com/yttrium
fi
cd yttrium
# git checkout ed8e8f5af2029406263be5993e484c3a69c1db7a
git reset --hard
git checkout 9f81ab8e0fb879a994392d603b7908b2104d1735
git reset --hard
sed -i.bak "s/-i ''/-i.bak/g" build-kotlin.sh
sed -i.bak "s/--bin uniffi-bindgen generate/-p kotlin-ffi --bin uniffi-bindgen generate/g" build-kotlin.sh
sed -i.bak "s/stat -f%z/echo stat -f%z/g" build-kotlin.sh
sed -i.bak "s/ -t arm64-v8a/ -t arm64-v8a -t x86_64/g" build-kotlin.sh
cargo install cargo-ndk
ENABLE_STRIP=false PROFILE=release bash -x ./build-kotlin.sh
cp target/x86_64-linux-android/release/deps/libuniffi_yttrium.so ../../../android/app/src/main/jniLibs/x86_64/libuniffi_yttrium.so
cp target/aarch64-linux-android/release/deps/libuniffi_yttrium.so ../../../android/app/src/main/jniLibs/arm64-v8a/libuniffi_yttrium.so
cp target/armv7-linux-androideabi/release/deps/libuniffi_yttrium.so ../../../android/app/src/main/jniLibs/armeabi-v7a/libuniffi_yttrium.so
+117
View File
@@ -0,0 +1,117 @@
#!/bin/bash
progname="${0##*/}"
progname="${progname%.sh}"
# usage: check_elf_alignment.sh [path to *.so files|path to *.apk]
cleanup_trap() {
if [ -n "${tmp}" -a -d "${tmp}" ]; then
rm -rf ${tmp}
fi
exit $1
}
usage() {
echo "Host side script to check the ELF alignment of shared libraries."
echo "Shared libraries are reported ALIGNED when their ELF regions are"
echo "16 KB or 64 KB aligned. Otherwise they are reported as UNALIGNED."
echo
echo "Usage: ${progname} [input-path|input-APK|input-APEX]"
}
if [ ${#} -ne 1 ]; then
cd $(dirname $0)/../..
usage
cd build/app/outputs/flutter-apk
bash ../../../../scripts/android/check_16kb_align.sh app-release.apk
exit
fi
case ${1} in
--help | -h | -\?)
usage
exit
;;
*)
dir="${1}"
;;
esac
if ! [ -f "${dir}" -o -d "${dir}" ]; then
echo "Invalid file: ${dir}" >&2
exit 1
fi
if [[ "${dir}" == *.apk ]]; then
trap 'cleanup_trap' EXIT
echo
echo "Recursively analyzing $dir"
echo
if { zipalign --help 2>&1 | grep -q "\-P <pagesize_kb>"; }; then
echo "=== APK zip-alignment ==="
zipalign -v -c -P 16 4 "${dir}" | egrep 'lib/arm64-v8a|lib/x86_64|Verification'
echo "========================="
else
echo "NOTICE: Zip alignment check requires build-tools version 35.0.0-rc3 or higher."
echo " You can install the latest build-tools by running the below command"
echo " and updating your \$PATH:"
echo
echo " sdkmanager \"build-tools;35.0.0-rc3\""
fi
dir_filename=$(basename "${dir}")
tmp=$(mktemp -d -t "${dir_filename%.apk}_out_XXXXX")
unzip "${dir}" lib/* -d "${tmp}" >/dev/null 2>&1
dir="${tmp}"
fi
if [[ "${dir}" == *.apex ]]; then
trap 'cleanup_trap' EXIT
echo
echo "Recursively analyzing $dir"
echo
dir_filename=$(basename "${dir}")
tmp=$(mktemp -d -t "${dir_filename%.apex}_out_XXXXX")
deapexer extract "${dir}" "${tmp}" || { echo "Failed to deapex." && exit 1; }
dir="${tmp}"
fi
RED="\e[31m"
GREEN="\e[32m"
ENDCOLOR="\e[0m"
unaligned_libs=()
echo
echo "=== ELF alignment ==="
matches="$(find "${dir}" -type f | grep -E '/(arm64-v8a|x86_64)/')"
IFS=$'\n'
for match in $matches; do
# We could recursively call this script or rewrite it to though.
[[ "${match}" == *".apk" ]] && echo "WARNING: doesn't recursively inspect .apk file: ${match}"
[[ "${match}" == *".apex" ]] && echo "WARNING: doesn't recursively inspect .apex file: ${match}"
[[ $(file "${match}") == *"ELF"* ]] || continue
res="$(objdump -p "${match}" | grep LOAD | awk '{ print $NF }' | head -1)"
if [[ $res =~ 2\*\*(1[4-9]|[2-9][0-9]|[1-9][0-9]{2,}) ]]; then
echo -e "${match}: ${GREEN}ALIGNED${ENDCOLOR} ($res)"
else
echo -e "${match}: ${RED}UNALIGNED${ENDCOLOR} ($res)"
unaligned_libs+=("${match}")
fi
done
if [ ${#unaligned_libs[@]} -gt 0 ]; then
echo -e "${RED}Found ${#unaligned_libs[@]} unaligned libs (only arm64-v8a/x86_64 libs need to be aligned).${ENDCOLOR}"
exit ${#unaligned_libs[@]}
elif [ -n "${dir_filename}" ]; then
echo -e "ELF Verification Successful"
fi
echo "====================="