cargo: can't specify lto in profile

Problem

Cargo doesn’t accept lto in profile as below:

[profile.release.package.fluvio-filter-test]
lto = true

Steps This result in following error message:

$ cargo check
error: failed to parse manifest at `/home/ubuntu/fluvio/Cargo.toml`

Caused by:
  `lto` may not be specified in a `package` profile
$ cargo version
cargo 1.51.0 (43b129a20 2021-03-16)

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 7
  • Comments: 16 (11 by maintainers)

Most upvoted comments

I’m experiencing this same issue. Would love a way around this.

Same issue here.

Since its not mentioned, the workaround for this is to define different profiles and build the different binaries with the relevant profiles.

Is this being taken care of?

I’m having the same issue. Of many packages and crates in the workspace, I was hoping some specific crates to be compiled with different settings. Specifying profile in the non-root package caused warnings hence I put those in the workspace which throws out errors.

workspace
  - pkg1
    - lib crate
    - lib crate
    - bin crate
  - pkg2
    - lib crate (needs the compilation-specific settings)
  - other pkgs...

@ehuss

Is this maybe an executable in a workspace?

Yes, multiple executables, they can easily need different build settings. In general, crates in the build tree aren’t necessarily built together into the same binary.

I encountered the same issue, but with panic instead of lto

`panic` may not be specified in a `package` profile

The worst thing is that there’s no reasonable workaround for this (or at least I haven’t found one).