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

Enable LTO for profile.release and profile.bench in new packages #14738

Closed
wants to merge 3 commits into from

Conversation

foxtran
Copy link

@foxtran foxtran commented Oct 27, 2024

Hi!

This PR enables fat Link-Time Optimization (LTO) by default for new packages which are started via cargo init command. To speed-up development cycle, LTO is enabled only for performance-related build types (release, bench). For library targets, only bench profile gets enabled LTO.

The main advantage is that new projects will no longer need to enable LTO manually. This means users will benefit from binaries that are a bit more optimized for both size and speed just from the start of their projects. Since projects are generally small in the early stages, this change should not significantly impact compilation time or memory usage — these issues usually arise only in the compilation with LTO of really large projects.

This PR does not affect existing packages. I've test these changes via cargo test command or more precisely:

cargo test --test testsuite -- cargo_init::
cargo test --test testsuite -- cargo_new::

because only these tests were affected by my changes.

Hope these changes will be merged and all Rust community gets faster packages from scratch :)

@rustbot
Copy link
Collaborator

rustbot commented Oct 27, 2024

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @weihanglo (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added Command-new S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 27, 2024
@foxtran foxtran force-pushed the feature/default-lto branch from b4ae611 to bd4a5e3 Compare October 27, 2024 21:06
@Rustin170506
Copy link
Member

Thanks for your PR. But before you submit your PR I would suggest opening an issue to discuss your request and changes. See more https://doc.crates.io/contrib/process/working-on-cargo.html#before-hacking-on-cargo.

@epage
Copy link
Contributor

epage commented Oct 28, 2024

Agreed with @Rustin170506. Thank you for your interest in improving the ecosystem. To add to why we prefer Issues is that there are many angles to look at (what settings, set in init or default profile, etc) and PRs aren't ideal for this type of setup.

#11298 might be a good place for discussing this. Closing this until there is resolution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Command-new S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants