Skip to content

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

Closed as not planned
Closed as not planned
@Rua

Description

@Rua

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.T-cargoRelevant to the cargo team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions