Repository navigation
GitHub Actions: Use Android packed relocations for Android builds - #7343
Merged
Merged
Conversation
Collaborator
Member
|
@Art34222 rebase |
Collaborator
|
暂时没什么意见,要么看看反应,炸了再回滚 |
Member
|
@KobeArthurScofield 那你在这个 PR 内改下 README.md 吧 |
Collaborator
done |
Pass -Wl,--pack-dyn-relocs=android to lld when building for Android. Go PIE binaries carry ~155k R_*_RELATIVE relocations (3.56 MiB as RELA); APS2 packing shrinks the table to ~0.64 MiB, making the binary ~2.9 MiB (~8%) smaller on both arm64 and amd64. Supported by bionic since Android 6.0 (API 23), below the current API 24 target. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Art34222
force-pushed
the
ci/android-packed-relocs
branch
from
November 8, 2026 11:09
6236f7c to
1f874cf
Compare
Collaborator
|
标一下 todo,后续升级最低支持版本的时候可以调新的参数 |
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.
Android builds are PIE, and a Go PIE binary carries ~155k
R_*_RELATIVEdynamic relocations (pointers in type descriptors, itabs, static string/slice headers, etc.). Stored as plain RELA (24 bytes each) they take 3.56 MiB of every Android binary.This PR passes
-Wl,--pack-dyn-relocs=androidto lld (NDK r28b, already used by the Android jobs), so the table is stored in Android's packed format (APS2) instead.Result (NDK r28b, same command line as
release.yml)RELA)ANDROID_RELA)The download (zip) shrinks less (~0.3 MiB) because RELA compresses well; the gain is mostly on-disk / installed size. Code and data are unchanged: only the encoding of the relocation table differs (e.g.
.data.rel.rohas the same size in both builds).Compatibility
DT_ANDROID_RELAis supported by the bionic loader since Android 6.0 (API 23). The Android jobs already target API 24 (*-linux-android24-clang, "Android 7+" since Workflows: Build Android(7+) using NDK; Add Android(7+) amd64 build #4664), so the supported range does not change.--pack-dyn-relocs=relr) would save ~0.6 MiB more, but needs Android 9 (API 28,DT_ANDROID_RELR) or Android 11 (API 30,DT_RELR), so it is intentionally not used here.Testing
On a physical device (Android 16 / API 36, arm64), comparing the unchanged build with the packed one:
xray version,xray x25519,xray run -test: OK200 OKcommon/buf,common/crypto,common/protocol,common/serial,common/net,infra/conf,proxy/vless/encoding,app/router): identical results for both builds, all PASS (geosite-dependent router tests skipped: nogeosite.daton the device)Not tested on Android 6–8 hardware; compatibility there is based on the dynamic tags (
llvm-readelf -dshowsANDROID_RELA/ANDROID_RELASZ) and bionic's documented support.🤖 Generated with Claude Code