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

LTO is enabled at opt-level=2 even with lto=false #84527

Closed
Rua opened this issue Apr 24, 2021 · 3 comments
Closed

LTO is enabled at opt-level=2 even with lto=false #84527

Rua opened this issue Apr 24, 2021 · 3 comments
Labels
C-bug Category: This is a bug. T-cargo Relevant to the cargo team, which will review and decide on the PR/issue.

Comments

@Rua
Copy link
Contributor

Rua commented Apr 24, 2021

My project has the following profile settings in the Cargo.toml:

[profile.dev]
opt-level = 2
incremental = true
lto = false

[profile.release]
incremental = true
lto = true

I profiled the building of my project using cargo +nightly rustc -- -Zself-profile. There's no --release so I assume it's going to do a dev build. Then, I run summarize summarize on the profiling file that was produced, and it lists as the very first item, therefore taking the most time:

+--------------------------------------------------+-----------+-----------------+----------+------------+
| Item                                             | Self time | % of total time | Time     | Item count |
+--------------------------------------------------+-----------+-----------------+----------+------------+
| LLVM_lto_optimize                                | 172.31s   | 23.797          | 172.31s  | 256        |
+--------------------------------------------------+-----------+-----------------+----------+------------+

This is unexpected, because LTO is explicitly disabled in the dev profile. I'm assuming that opt-level = 2 simply includes LTO by default, but then why am I not able to override it?

rustc --version --verbose:

rustc 1.53.0-nightly (bb491ed23 2021-04-23)
binary: rustc
commit-hash: bb491ed23937aef876622e4beb68ae95938b3bf9
commit-date: 2021-04-23
host: x86_64-unknown-linux-gnu
release: 1.53.0-nightly
LLVM version: 12.0.0
@Rua Rua added the C-bug Category: This is a bug. label Apr 24, 2021
@ehuss
Copy link
Contributor

ehuss commented Apr 24, 2021

Hi! The profile setting lto = false still does "thin local LTO" when the opt-level is not zero, which is LTO on the local crate across codegen units. To fully disable LTO, the setting needs to be lto = "off". There's more info in the docs. I realize that might be a little confusing (there is rust-lang/cargo#7491 filed for this), but that is how things evolved over time.

@Rua
Copy link
Contributor Author

Rua commented Apr 24, 2021

false and "off" are different things? Yes, that is rather confusing indeed! But thanks for the explanation.

@ChrisDenton ChrisDenton added the needs-triage-legacy Old issue that were never triaged. Remove this label once the issue has been sufficiently triaged. label Jul 16, 2023
@jieyouxu jieyouxu added T-cargo Relevant to the cargo team, which will review and decide on the PR/issue. and removed needs-triage-legacy Old issue that were never triaged. Remove this label once the issue has been sufficiently triaged. labels Feb 18, 2024
@weihanglo
Copy link
Member

Close in favor of rust-lang/cargo#7491.

@weihanglo weihanglo closed this as not planned Won't fix, can't repro, duplicate, stale Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. T-cargo Relevant to the cargo team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants