-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
can't specify lto in profile #9330
Comments
Thanks for the report! Can you say more about your use case? LTO only works for the final artifact, so it can't be set per-dependency. Is this maybe an executable in a workspace? |
library crates (like clap-rs) can enable LTO. If the toolchain does not support LTO the build is gonna fail even though the binary crate you're trying to build doesn't have that enabled. |
Yes, multiple executables, they can easily need different build settings. I encountered the same issue, but with
The worst thing is that there's no reasonable workaround for this (or at least I haven't found one). |
10 more people encountered the same issue here - #8264 (comment). (I consider all of the "may not be specified in a |
Looks like it's possible to make a separate profile that inherits from the main one, but overrides panic or lto.
Ugh, looks like different executables may share built dependencies, which is obviously good, but will prevent overriding things like |
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
|
Same issue here. |
Well, in the Cargo documentation it's already mentioned that What I ignore is if it could be supported or not. |
This is honestly pretty painful. I am giving up on the workspace for my toy example due to this, but it will arise in larger contexts. Anything that could be done to kludge around it? |
I'm experiencing this same issue. Would love a way around this. |
Any news on this? |
Since its not mentioned, the workaround for this is to define different profiles and build the different binaries with the relevant profiles. |
@petrochenkov commented that it's not clear that using different profiles is sufficient? I don't think I understand this workaround very well. |
Missed that in the among the different commes but not seeing what the downside to it is. |
For LTO I don't know that it matters much if some deps are built with and some without: should be just a small performance surprise. For |
Similar issue.
|
The need to use multiple profiles definitely isn't ideal, since you can't just For those coming from google looking for a resolution, there are 2 workarounds. The first is to define a second profile with the relevant settings:
and compile using The second is to add a
where the contents of config.toml are the same as a standard cargo.toml and will override the workspace cargo.toml. Note that this will NOT work if you call cargo build from workspace root ( This works great for the very common use-case of wasm-pack (which seems to be the use-case for several people in a related thread). |
Profile in workspace works fine now and solves original problem I had. I consider this as resolved. |
I think this may be worth leaving open to track a way to do this using the |
Problem
Cargo doesn't accept
lto
in profile as below:Steps
This result in following error message:
The text was updated successfully, but these errors were encountered: