Skip to content

Modernize Android 3p build scripts for current NDK/CMake - #388

Open
byrcolin wants to merge 1 commit into
o3de:mainfrom
byrcolin:android-build-modernization
Open

Modernize Android 3p build scripts for current NDK/CMake#388
byrcolin wants to merge 1 commit into
o3de:mainfrom
byrcolin:android-build-modernization

Conversation

@byrcolin

@byrcolin byrcolin commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes the Android 3p package build scripts so they work with current NDK and CMake versions. No functional change to package outputs.

  • Toolchain: opt out of the NDK's legacy toolchain wrapper (ANDROID_USE_LEGACY_TOOLCHAIN_FILE OFF), which is broken with CMake 4.x
  • mikkelsen: remove hardcoded NDK r21d path (uses the LY_NDK_DIR env var, which the toolchain already supports), drop the API level pin (toolchain enforces and defaults to 24), remove obsolete arm32 flags (ANDROID_ARM_MODE/ANDROID_ARM_NEON modern NDKs hard-error on disabling NEON, and both are meaningless for arm64-v8a)
  • zlib: pass CMAKE_POLICY_VERSION_MINIMUM=3.5 so zlib's ancient cmake_minimum_required(VERSION 2.4.4) configures under CMake 4.x (must be on the command line the top-level version check runs before the toolchain file is read)
  • .gitignore: exclude build/ folders

How was this tested?

Built with NDK r27.3.13750724 / CMake 4.1 on Windows:

  • mikkelsen: debug + release via Ninja Multi-Config, both installed correctly
  • zlib: build_zlib_android.cmd links libz.a cleanly

Related

Prerequisite for the Android 16KB page alignment work: RFC o3de/o3de#19936

- Toolchain: opt out of the legacy NDK toolchain wrapper, which is broken with CMake 4.x
- mikkelsen: remove hardcoded NDK r21d path (use LY_NDK_DIR env var), drop API level pin (toolchain enforces/defaults to 24), remove obsolete arm32 flags (ANDROID_ARM_MODE/ANDROID_ARM_NEON) that modern NDKs reject
- zlib: pass CMAKE_POLICY_VERSION_MINIMUM=3.5 so zlib's ancient cmake_minimum_required configures under CMake 4.x
- gitignore: exclude build/ folders

Verified: mikkelsen (debug+release via Ninja Multi-Config) and zlib build with NDK r27.3 / CMake 4.1
Signed-off-by: colinb <colinb@accesspointmg.com>
byrcolin added a commit that referenced this pull request Aug 4, 2026
## What does this PR do?

Adds 16KB page size alignment linker flags to the shared Android
toolchain used by all 3p package builds:

```
-Wl,-z,max-page-size=16384 -Wl,-z,common-page-size=16384
```

This ensures all Android shared libraries have ELF LOAD segments aligned
to 16KB boundaries, as required by Google Play for apps targeting
Android 15+ devices (enforced since November 1, 2025). 16KB-aligned
binaries are fully backward compatible with 4KB-page devices.

All packages that build for Android through this toolchain (expat,
freetype, googlebenchmark, libpng, libsamplerate, Lua, lz4, mikkelsen,
OpenSSL, tiff, zlib) will produce aligned output on their next rebuild.

Note: vulkan-validationlayers uses prebuilt Khronos binaries and needs
an updated upstream version separately.

## RFC

**Draft pending acceptance of RFC o3de/o3de#19936** (Android 16KB Page
Size Support for O3DE Native Binaries).

Depends on #388 (build script modernization) for the packages to be
rebuildable with a current NDK/CMake.

## Verification

`llvm-readelf -l <lib.so>` on rebuilt output must show all LOAD segments
with `Align 0x4000` or greater.

@nick-l-o3de nick-l-o3de left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. We should be getting those vars from the YAML for the CI so there's no need to set it.

 # Set NDK folder path in the env vars
        $ndkRoot = "$sdkPath\ndk\$env:ANDROID_NDK_VERSION"
        echo ANDROID_NDK=$ndkRoot >> $env:GITHUB_ENV
        echo ANDROID_NDK_HOME=$ndkRoot >> $env:GITHUB_ENV
        echo ANDROID_NDK_ROOT=$ndkRoot >> $env:GITHUB_ENV

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants