Skip to content

LTO behavior depends on root targets #8337

@ehuss

Description

@ehuss

Comparing these two commands building Cargo itself with lto='thin':

  1. cargo build --release
  2. cargo build --release --bin cargo

The first command does not engage the LTO codegen optimization added in #8192. On my system, the total build time goes from 187s to 150s.

It is a bit surprising, since the two commands generally produce the same output, so I would not expect them to use different settings.

Would it make sense to be a little smarter about how the root units are chosen? I think the crux of the issue is this line where it starts the lib at Lto::None in the first case. In the second case, it is computed as a dependency with Lto::OnlyBitcode.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ltoArea: link-time optimization

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions