[native_toolchain_c] Android 15 16kb elf alignment
Android 15 has the support to require dylib elf sections to be 16kb aligned.
We should probably have a default flag for this in package:native_toolchain_c so that packages using flutter create --template package_ffi will work out of the box for Android 15 devices with 16kb memory pages.
Context:
- https://github.com/flutter/flutter/pull/155508
- https://developer.android.com/guide/practices/page-sizes#compile-r26-lower
Also possibly related https://github.com/flutter/flutter/issues/125090
Out of curiosity: Does Android's NDK compiler toolchain not automatically use 16 KB by-default? Or is this for handling older Android compiler toolchains that don't have that default yet?
Related: https://github.com/dart-lang/native/issues/1608
Out of curiosity: Does Android's NDK compiler toolchain not automatically use 16 KB by-default? Or is this for handling older Android compiler toolchains that don't have that default yet?
NDK r27 does with this flag set: -DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON
Out of curiosity: Does Android's NDK compiler toolchain not automatically use 16 KB by-default? Or is this for handling older Android compiler toolchains that don't have that default yet?
We're currently still on r26b on the CI here:
https://github.com/dart-lang/native/blob/16918aef9da60646e5ae0ad0307fe0e1a64355b2/.github/workflows/native.yaml#L55
Also flutter_tools is at 26 at the moment:
https://github.com/flutter/flutter/blob/9be22b58c4bfe8b6cb447de13a500db4e1bd8c33/packages/flutter_tools/gradle/src/main/groovy/flutter.groovy#L58-L63
If you invoke 27 or up directly (not via Groovy, Kotlin, or Application.mk) it also requires passing the flag:
https://developer.android.com/guide/practices/page-sizes#other-build-systems
Bumping the version on the CI here:
- https://github.com/dart-lang/native/pull/1612
Workaround before we address this:
final cbuilder = CBuilder.library(
name: packageName,
assetName: '${packageName}_bindings_generated.dart',
sources: [
'src/$packageName.c',
],
flags: ['-Wl,-z,max-page-size=16384',], // <----
);