-
Notifications
You must be signed in to change notification settings - Fork 9
perform full LTO during Android .so build using rustc #649
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Size Comparison Report (x86_64)
|
.bazelrc
Outdated
| build:release-android --android_platforms=@rules_android//:armeabi-v7a,@rules_android//:arm64-v8a,@rules_android//:x86,@rules_android//:x86_64 | ||
| build:release-android --config=release-common | ||
| build:release-android --copt=-flto=thin --linkopt=-flto=thin | ||
| # build:release-android --copt=-flto=thin --linkopt=-flto=thin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why leave this in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, no reason so I'll remove
| // enable 16 KB ELF alignment on Android to support API 35+ | ||
| extraCargoEnv = mapOf( | ||
| "RUSTFLAGS" to "-C link-args=-Wl,-z,max-page-size=16384,--build-id", | ||
| "RUSTFLAGS" to "-C codegen-units=1 -C embed-bitcode -C lto=fat -C opt-level=z -C link-args=-Wl,-z,max-page-size=16384,--build-id", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this still required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just for the cargo build so I figured I'd leave this in so that there is parity between all cargo and bazel. All the other stuff just targets the bazel pipeline so this is still necessary for the gradle build
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
big if true
Size Comparison Report (x86_64)
|
|
Seems like this breaks iOS, looking into it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! This alongside with the regex-lite stuff will be a huge reduction #372
Previously we were building a cc_binary target which seemed to have an issue with the version of LLVM used that prevented LTO from working. Based on some comments it meant that we were not enabling LTO for this reason (despite flags that might indicate this).
Realizing that cargo was able to do this, by moving the final link to rust_shared_library we can use rustc for everything which simplified this and allows us to run fat LTO as part of the .so build.
To get this working I needed to update the std rlib to be built with LTO compile flags.
In addition, this brings in Rust 1.90.0 for both Android and iOS.