Repository navigation
build: pack Android relocations by LIBXRAY_ANDROID_API - #172
Merged
Merged
Conversation
LIBXRAY_ANDROID_API (default 21) selects the -androidapi passed to gomobile bind, which also becomes the AAR's minSdkVersion. From 23, the Android libraries are linked with --pack-dyn-relocs=android (DT_ANDROID_REL/RELA, loaded since API 23), and from 28 with --pack-dyn-relocs=relr --use-android-relr-tags (DT_ANDROID_RELR, loaded since API 28). The default build is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Each 64-bit
libgojni.soin the AAR carries ~3.6 MiB of plainRELAdynamic relocations. lld can store them packed (--pack-dyn-relocs=android, loaded since Android 6.0 / API 23) or as RELR (DT_ANDROID_RELR, since Android 9 / API 28), but the build targets API 21.So the default stays as is, and
LIBXRAY_ANDROID_API(default21) sets-androidapi, which is also the AAR'sminSdkVersion. From23the libraries are linked with--pack-dyn-relocs=android, from28with--pack-dyn-relocs=relr --use-android-relr-tags(what NDK r30 already passes there, so a later flag does not override it).libgojni.so(NDK r30)LIBXRAY_ANDROID_API=23LIBXRAY_ANDROID_API=28Only the relocation table changes; data sections keep their sizes. A build at API 23 without packing is within ~3.5 KB of the default, so the gain comes from packing. Standard
DT_RELR(API 30) gives the same bytes asDT_ANDROID_RELRand is not used.minSdk: the comment next to
-androidapi 21says "keep same with flutter", and Flutter now requires API 24. Raising the default to 23 would give every build the packed sizes while dropping only Android 5.x; this PR leaves that choice to the maintainers.Tested:
python3 build/test_build.py; built at 21, 23 and 28,llvm-readelf -dshowsRELA/REL,ANDROID_RELA/ANDROID_RELandANDROID_RELR. Not run on a device yet.🤖 Generated with Claude Code