I have several crates in a workspace, and some badly need LTO (say foo
), whereas others would suffer absurdly long compile times with it. But when I naively apply
[profile.release.package.foo]
lto = true
for the crates that need it, I get
error: failed to parse manifest at ...
Caused by:
`lto` may not be specified in a `package` profile
I thought I could solve this by passing the flag at runtime, e.g. RUSTFLAGS="-C lto=true" cargo build --release -p foo
. But when I do that, it requires me to also use the nightly compiler and set -C embed-bitcode=true -Zdylib-lto
. Is this really the right way to configure LTO at the command line?