-
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
lib with multiple crate types appears to override profile.release #2301
Comments
Ah this is because the compiler only accepts There could likely be a warning here, however. |
Just to double check, it seems like what you'd want is Again just to be clear, what happens now is that |
Ah and in fact it looks like there's an explicit check that matches only cargo/src/cargo/core/manifest.rs Line 359 in 3775b3f
If this isn't intentional I'd be willing to take a look at fixing/changing this, though I'm still relatively new to Rust. |
Yeah this is currently intentional and expected behavior. The compiler is only invoked once despite any number of crate types, and the compiler will reject To add support for this it'd likely want to start upstream by fixing the compiler to not reject this situation. |
This is also a problem with the new Looks like LTO will still be performed though with @alexcrichton any suggestions for a workaround here? Our use case is that we wanted to write integration tests for our crate, which requires that it be an rlib, but then adding rlib as a crate type disabled LTO. Workarounds I've come up with:
|
I believe this is a compiler limitation, you can't
I'd probably recommend splitting up into a separate crate so you can write tests for one and LTO the other |
Closing this since the fix first needs to be made in rust-lang/rust and there's a workaround. |
I ran into this issue independently, and it took a bit of work to actually track down the root cause. Even if there needs to be an upstream fix first, you can add a warning in the meantime. |
hi @Lymia, could you open a new issue for adding a warning please? thanks! |
There is a problem when adding lib because it disables lto for cdylib :( rust-lang/cargo#2301 sorry about that 🙈
I have a crate with the following in Cargo.toml:
The static library it produces is around 4.4mb.
If remove rlib:
The static library is around 1.3 mb.
It seems like building both an rlib and a static lib overrides profile.release? Or at least lto?
I'm trying to build both a static lib and an rlib because I want to build both a static library and a binary for the crate and the binary depends on the library.
The text was updated successfully, but these errors were encountered: