-
Notifications
You must be signed in to change notification settings - Fork 12
Description
Hi!
Happy badge owner from FOSDEM 2026 here. Thanks a lot for providing a possibility to configure the badge in Rust CLI :)
I noticed that in the Cargo.toml file Link-Time Optimization (LTO) for the project is not enabled. I suggest switching it on since it will reduce the binary size. If you want to read more about LTO and its possible modes, I recommend starting from this Rustc documentation. Additionally, codegen-units option can help too in a similar to LTO way, so I recommend to enable it as well.
I recommend enabling LTO only for Release builds so developers experience won't be affected by the increased build time, and it will be applied to the prebuilt binaries on GitHub CI too (since current CI scripts use the Release profile. Actually, I can propose to use flags directly from the ripgrep profile.
Basically, it can be enabled with the following lines to the root Cargo.toml file:
[profile.release]
codegen-units = 1
lto = true # FullLTO - the most aggressive LTO version
I have made quick tests (Macbook M1 Pro, Rust 1.93, the latest version of the project at the moment, cargo build --locked --release --no-default-features -F cli command (just copied it from the CI scripts, with and without stripping) - here are the results:
- Release (the current profile): 4 Mib (3.3 Mib after the
striputility), clean build time: 40s - Release + FullLTO + CU1: 3 Mib (2.6 Mib after the
striputility, clean build time: 68s
Build time increase shouldn't be a problem since we enable it only for the Release profile.
If you are okay with these changes, I am ready to provide the PR - it will be a really small one :)
Thank you.