Skip to content

LTO ignored for all crate types when building multiple crate types and one doesn't support it #51009

@fitzgen

Description

@fitzgen

https://github.com/rustwasm/rust_wasm_template has

[lib]
crate-type = [
  # Build a cdylib to make a `.wasm` library.
  "cdylib",
  # Build an rlib for testing and benching.
  "rlib"
]

[profile.release]
lto = true

The lto = true is ignored for everything because rlibs don't support LTO. I would expect that the cdylib has LTO and that only the rlib ignores the LTO options.

@alexcrichton tells me this is a rust compiler bug, not a cargo bug.

FWIW, this command does not work either:

cargo rustc -- -C lto=fat --crate-type cdylib

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LTOArea: Link-time optimization (LTO)C-bugCategory: This is a bug.T-compilerRelevant to the compiler 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