Skip to content
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

feat: Add //rust/settings:lto #3104

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

ParkMyCar
Copy link
Contributor

Fixes #3045

This PR adds a new build setting //rust/settings:lto=(off|thin|fat) which changes how we specify the following flags:

The 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=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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rustc: set --embed-bitcode=no if LTO is not enabled
1 participant