From a09d1cad881403ac510e62f53d486f1e4d5b5ff9 Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Thu, 6 Nov 2025 04:05:18 +0100
Subject: [PATCH] release: apply updates from SDL3 repo
- test Android elf alignment for x86_64/aarch64
- disable test cmake support of frameworks inside xcframework
[ci skip]
---
.github/workflows/release.yml | 55 ++++++++++++
build-scripts/build-release.py | 6 +-
build-scripts/check_elf_alignment.sh | 127 +++++++++++++++++++++++++++
3 files changed, 185 insertions(+), 3 deletions(-)
create mode 100755 build-scripts/check_elf_alignment.sh
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 10325ed..c416aab 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -260,6 +260,15 @@ jobs:
# -B build_darwin
# cmake --build build_darwin --config Release --verbose
#
+# cmake -S "${{ steps.src.outputs.path }}/cmake/test" \
+# -DTEST_SHARED=TRUE \
+# -DTEST_STATIC=FALSE \
+# -DCMAKE_PREFIX_PATH="${{ steps.mount.outputs.mount-point }}/SDL3_net.xcframework/macos-arm64_x86_64;${{ steps.deps-mount.outputs.path }}/SDL3.xcframework/macos-arm64_x86_64" \
+# -DCMAKE_SYSTEM_NAME=Darwin \
+# -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \
+# -B build_darwin2
+# cmake --build build_darwin2 --config Release --verbose
+#
# - name: 'CMake (configure + build) iOS'
# run: |
# cmake -S "${{ steps.src.outputs.path }}/cmake/test" \
@@ -271,6 +280,15 @@ jobs:
# -Werror=dev \
# -B build_ios
# cmake --build build_ios --config Release --verbose
+#
+# cmake -S "${{ steps.src.outputs.path }}/cmake/test" \
+# -DTEST_SHARED=TRUE \
+# -DTEST_STATIC=FALSE \
+# -DCMAKE_PREFIX_PATH="${{ steps.mount.outputs.mount-point }}/SDL3_net.xcframework/ios-arm64;${{ steps.deps-mount.outputs.path }}/SDL3.xcframework/ios-arm64" \
+# -DCMAKE_SYSTEM_NAME=iOS \
+# -DCMAKE_OSX_ARCHITECTURES="arm64" \
+# -B build_ios2
+# cmake --build build_ios2 --config Release --verbose
# - name: 'CMake (configure + build) tvOS'
# run: |
# cmake -S "${{ steps.src.outputs.path }}/cmake/test" \
@@ -282,6 +300,15 @@ jobs:
# -Werror=dev \
# -B build_tvos
# cmake --build build_tvos --config Release --verbose
+#
+# cmake -S "${{ steps.src.outputs.path }}/cmake/test" \
+# -DTEST_SHARED=TRUE \
+# -DTEST_STATIC=FALSE \
+# -DCMAKE_PREFIX_PATH="${{ steps.mount.outputs.mount-point }}/SDL3_net.xcframework/tvos-arm64;${{ steps.deps-mount.outputs.path }}/SDL3.xcframework/tvos-arm64" \
+# -DCMAKE_SYSTEM_NAME=tvOS \
+# -DCMAKE_OSX_ARCHITECTURES="arm64" \
+# -B build_tvos2
+# cmake --build build_tvos2 --config Release --verbose
# - name: 'CMake (configure + build) iOS simulator'
# run: |
# sysroot=$(xcodebuild -version -sdk iphonesimulator Path)
@@ -296,6 +323,16 @@ jobs:
# -Werror=dev \
# -B build_ios_simulator
# cmake --build build_ios_simulator --config Release --verbose
+#
+# cmake -S "${{ steps.src.outputs.path }}/cmake/test" \
+# -DTEST_SHARED=TRUE \
+# -DTEST_STATIC=FALSE \
+# -DCMAKE_PREFIX_PATH="${{ steps.mount.outputs.mount-point }}/SDL3_net.xcframework/ios-arm64_x86_64-simulator;${{ steps.deps-mount.outputs.path }}/SDL3.xcframework/ios-arm64_x86_64-simulator" \
+# -DCMAKE_SYSTEM_NAME=iOS \
+# -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \
+# -DCMAKE_OSX_SYSROOT="${sysroot}" \
+# -B build_ios_simulator2
+# cmake --build build_ios_simulator2 --config Release --verbose
# - name: 'CMake (configure + build) tvOS simulator'
# run: |
# sysroot=$(xcodebuild -version -sdk appletvsimulator Path)
@@ -310,6 +347,16 @@ jobs:
# -Werror=dev \
# -B build_tvos_simulator
# cmake --build build_tvos_simulator --config Release --verbose
+#
+# cmake -S "${{ steps.src.outputs.path }}/cmake/test" \
+# -DTEST_SHARED=TRUE \
+# -DTEST_STATIC=FALSE \
+# -DCMAKE_PREFIX_PATH="${{ steps.mount.outputs.mount-point }}/SDL3_net.xcframework/tvos-arm64_x86_64-simulator;${{ steps.deps-mount.outputs.path }}/SDL3.xcframework/tvos-arm64_x86_64-simulator" \
+# -DCMAKE_SYSTEM_NAME=tvOS \
+# -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \
+# -DCMAKE_OSX_SYSROOT="${sysroot}" \
+# -B build_tvos_simulator2
+# cmake --build build_tvos_simulator2 --config Release --verbose
msvc:
needs: [src]
runs-on: windows-2025
@@ -622,6 +669,7 @@ jobs:
with:
sparse-checkout: 'build-scripts/build-release.py'
- name: 'Setup Android NDK'
+ id: setup-ndk
uses: nttld/setup-ndk@v1
with:
local-cache: false
@@ -653,6 +701,8 @@ jobs:
run: |
python build-scripts/build-release.py \
--actions download android \
+ --android-api 21 \
+ --android-ndk-home "${{ steps.setup-ndk.outputs.ndk-path }}" \
--commit ${{ inputs.commit }} \
--root "${{ steps.tar.outputs.path }}" \
--github \
@@ -718,6 +768,11 @@ jobs:
run: |
sudo apt-get update -y
sudo apt-get install -y ninja-build
+ - name: 'Verify alignment of libSDL3_net.so (arm64-v8a/x86_64)'
+ run: |
+ set -e
+ ${{ steps.src.outputs.path }}/build-scripts/check_elf_alignment.sh ${{ steps.sdk.outputs.prefix }}/lib/arm64-v8a/libSDL3_net.so
+ ${{ steps.src.outputs.path }}/build-scripts/check_elf_alignment.sh ${{ steps.sdk.outputs.prefix }}/lib/x86_64/libSDL3_net.so
- name: 'CMake (configure + build) x86, x64, arm32, arm64'
run: |
android_abis="x86 x86_64 armeabi-v7a arm64-v8a"
diff --git a/build-scripts/build-release.py b/build-scripts/build-release.py
index e25bda8..79e0894 100755
--- a/build-scripts/build-release.py
+++ b/build-scripts/build-release.py
@@ -1028,6 +1028,7 @@ def create_android_archives(self, android_api: int, android_home: Path, android_
# NDK 21e does not support -ffile-prefix-map
# f'''-DCMAKE_C_FLAGS="-ffile-prefix-map={self.root}=/src/{self.project}"''',
# f'''-DCMAKE_CXX_FLAGS="-ffile-prefix-map={self.root}=/src/{self.project}"''',
+ "-DANDROID_USE_LEGACY_TOOLCHAIN=0",
f"-DCMAKE_EXE_LINKER_FLAGS={extra_link_options}",
f"-DCMAKE_SHARED_LINKER_FLAGS={extra_link_options}",
f"-DCMAKE_TOOLCHAIN_FILE={cmake_toolchain_file}",
@@ -1126,8 +1127,7 @@ def download_dependencies(self):
for dep, depinfo in self.release_info.get("dependencies", {}).items():
startswith = depinfo["startswith"]
dep_repo = depinfo["repo"]
- # FIXME: dropped "--exclude-pre-releases"
- dep_string_data = self.executer.check_output(["gh", "-R", dep_repo, "release", "list", "--exclude-drafts", "--json", "name,createdAt,tagName", "--jq", f'[.[]|select(.name|startswith("{startswith}"))]|max_by(.createdAt)']).strip()
+ dep_string_data = self.executer.check_output(["gh", "-R", dep_repo, "release", "list", "--exclude-drafts", "--exclude-pre-releases", "--json", "name,createdAt,tagName", "--jq", f'[.[]|select(.name|startswith("{startswith}"))]|max_by(.createdAt)']).strip()
dep_data = json.loads(dep_string_data)
dep_tag = dep_data["tagName"]
dep_version = dep_data["name"]
@@ -1517,7 +1517,7 @@ def main(argv=None) -> int:
if args.android_home is None or not Path(args.android_home).is_dir():
parser.error("Invalid $ANDROID_HOME or --android-home: must be a directory containing the Android SDK")
if args.android_ndk_home is None or not Path(args.android_ndk_home).is_dir():
- parser.error("Invalid $ANDROID_NDK_HOME or --android_ndk_home: must be a directory containing the Android NDK")
+ parser.error("Invalid $ANDROID_NDK_HOME or --android-ndk-home: must be a directory containing the Android NDK")
if args.android_api is None:
with section_printer.group("Detect Android APIS"):
args.android_api = releaser._detect_android_api(android_home=args.android_home)
diff --git a/build-scripts/check_elf_alignment.sh b/build-scripts/check_elf_alignment.sh
new file mode 100755
index 0000000..d3846bc
--- /dev/null
+++ b/build-scripts/check_elf_alignment.sh
@@ -0,0 +1,127 @@
+#!/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
+ usage
+ 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=()
+unaligned_critical_libs=()
+
+echo
+echo "=== ELF alignment ==="
+
+matches="$(find "${dir}" -type f)"
+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
+ unaligned_libs+=("${match}")
+ # Check if this is a critical architecture (arm64-v8a or x86_64)
+ if [[ "${match}" == *"arm64-v8a"* ]] || [[ "${match}" == *"x86_64"* ]]; then
+ unaligned_critical_libs+=("${match}")
+ echo -e "${match}: ${RED}UNALIGNED${ENDCOLOR} ($res)"
+ else
+ echo -e "${match}: UNALIGNED ($res)"
+ fi
+ fi
+done
+
+if [ ${#unaligned_libs[@]} -gt 0 ]; then
+ echo -e "Found ${#unaligned_libs[@]} unaligned libs (only arm64-v8a/x86_64 libs need to be aligned).${ENDCOLOR}"
+fi
+echo "====================="
+
+# Exit with appropriate code: 1 if critical unaligned libs found, 0 otherwise
+if [ ${#unaligned_critical_libs[@]} -gt 0 ]; then
+ echo -e "${RED}Found ${#unaligned_critical_libs[@]} critical unaligned libs.${ENDCOLOR}"
+ exit 1
+else
+ echo -e "${GREEN}ELF Verification Successful${ENDCOLOR}"
+ exit 0
+fi