Skip to content

Conversation

@snowp
Copy link
Contributor

@snowp snowp commented Sep 25, 2025

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.

@snowp snowp changed the title Match gradle perform full LTO during Android .so build using rustc Sep 25, 2025
@github-actions
Copy link

github-actions bot commented Sep 25, 2025

Size Comparison Report (x86_64)

Metric APK (KB) SO (KB)
Baseline 3566 1452
Current 3306 1188
Difference -260 -264

APK size decreased by 260 KB. SO size decreased by 264 KB.

@snowp snowp marked this pull request as ready for review September 25, 2025 03:42
@snowp snowp requested a review from murki September 29, 2025 18:30
.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
Copy link
Contributor

Choose a reason for hiding this comment

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

why leave this in?

Copy link
Contributor Author

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",
Copy link
Contributor

Choose a reason for hiding this comment

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

is this still required?

Copy link
Contributor Author

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

Copy link
Contributor

@murki murki left a comment

Choose a reason for hiding this comment

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

big if true

@github-actions
Copy link

Size Comparison Report (x86_64)

Metric APK (KB) SO (KB)
Baseline 3558 1444
Current 3302 1188
Difference -256 -256

APK size decreased by 256 KB. SO size decreased by 256 KB.

@snowp
Copy link
Contributor Author

snowp commented Sep 29, 2025

Seems like this breaks iOS, looking into it

@snowp snowp marked this pull request as draft September 29, 2025 19:47
Copy link
Contributor

@FranAguilera FranAguilera left a 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

@snowp snowp marked this pull request as ready for review October 3, 2025 15:48
@snowp snowp merged commit 9050b46 into main Oct 3, 2025
15 checks passed
@snowp snowp deleted the match-gradle branch October 3, 2025 16:14
@github-actions github-actions bot locked and limited conversation to collaborators Oct 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants