-
Notifications
You must be signed in to change notification settings - Fork 525
feat: Add //rust/settings:lto
#3104
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
Merged
Merged
Conversation
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
UebelAndre
approved these changes
Dec 16, 2024
Collaborator
UebelAndre
left a comment
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! Thank you!
github-merge-queue bot
pushed a commit
that referenced
this pull request
Dec 29, 2024
Related to #3119 Adds an option named "manual" to `//rust/settings/lto` which was introduced in #3104. When set to "manual" we will not automatically set any flags so users with customized setups can configure the relevant flags on their own. FWIW this was an oversight and IMO should have been included in the original PR. Apologies to anyone who stumbled over this or encountered build issues!
ParkMyCar
added a commit
to MaterializeInc/rules_rust
that referenced
this pull request
Feb 11, 2025
Fixes bazelbuild#3045 This PR adds a new build setting `//rust/settings:lto=(off|thin|fat)` which changes how we specify the following flags: * [`lto`](https://doc.rust-lang.org/rustc/codegen-options/index.html#lto) * [`embed-bitcode`](https://doc.rust-lang.org/rustc/codegen-options/index.html#embed-bitcode) * [`linker-plugin-lto`](https://doc.rust-lang.org/rustc/codegen-options/index.html#linker-plugin-lto) The way we invoke the flags was based on how Cargo does it today ([code](https://github.com/rust-lang/cargo/blob/769f622e12db0001431d8ae36d1093fb8727c5d9/src/cargo/core/compiler/lto.rs#L4)) and based on suggestions from the [Rust docs](https://doc.rust-lang.org/rustc/codegen-options/index.html#embed-bitcode). When LTO is not enabled, we will specify `-Cembed-bitcode=no` which tells `rustc` to skip embedding LLVM bitcode and should speed up builds. Similarly when LTO is enabled we specify `-Clinker-plugin-lto` which will cause `rustc` to skip generating objects files entirely, and instead replace them with LLVM bitcode*. *only when building an `rlib`, when building other crate types we continue generating object files. I added unit tests to make sure we pass the flags correctly, as well as some docs describing the new setting. Please let me know if I should add more!
gibfahn
added a commit
to gibfahn/rules_py
that referenced
this pull request
Oct 21, 2025
The -Clto flag can conflict with parent module's Rust toolchain configuration, particularly when embed-bitcode=no is set. This change removes the hardcoded LTO flag to allow proper inheritance of toolchain settings. Related: bazelbuild/rules_rust#3104
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.
Fixes #3045
This PR adds a new build setting
//rust/settings:lto=(off|thin|fat)which changes how we specify the following flags:ltoembed-bitcodelinker-plugin-ltoThe way we invoke the flags was based on how Cargo does it today (code) and based on suggestions from the Rust docs.
When LTO is not enabled, we will specify
-Cembed-bitcode=nowhich tellsrustcto skip embedding LLVM bitcode and should speed up builds. Similarly when LTO is enabled we specify-Clinker-plugin-ltowhich will causerustcto skip generating objects files entirely, and instead replace them with LLVM bitcode*.*only when building an
rlib, when building other crate types we continue generating object files.I added unit tests to make sure we pass the flags correctly, as well as some docs describing the new setting. Please let me know if I should add more!