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.
If you're using Clang for your C toolchain, it's possible to do cross language optimizations between Rust and C, see Rust's Linker-plugin-based LTO docs for more info.
This PR adds a new
@rules_rust//rust/settings:experimental_cross_language_lto
(off by default) which when building a Rust binary will set-Clinker-plugin-lto
. If LTO is enabled for both Rust and C will then delay optimizations to the linker, resulting in cross language optimizations.This feature is highly experimental. To have it work correctly you need to be using a Clang toolchain with
lld
as the linker that is recent enough to understand the bitcode emitted byrustc
. There is much more we can do here to make the feature more stable, but this seemed like a good starting point?