-
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
Allow crate-type=["staticlib","cdylib"] for [[bin]] #6351
Comments
I'd like to see this as well. I don't know if it makes sense to do this by extending |
See #8628. |
This is a very good proposal. And I have a use case where it would fit perfectly. When it is necessary to use the same target to generate a desktop executable, but a cdylib for android and wasm, and a staticlib for ios. It is related to: rust-lang/rfcs#3180 It would not be possible to use the [lib] target to generate these libraries, as there are #[no_mangle] functions that cannot be present in an ordinary rlib, due to name collision. And that way it is also possible to have several native libraries using just one package. |
This could also be potentially useful for building multiple wasm modules. |
My current workaround is to use |
Cargo currently enforces only one library crate per package which makes total sense for Rust libraries. However it doesn't make much sense for
cdylib
s orstaticlib
s which are not going to be consumed by downstream Rust dependencies. Requiring that only the library crate can be acdylib
orstaticlib
, and not binary crates, sometimes forces people into mixinglib
andcdylib
orstaticlib
and Rust currently produces suboptimal results when doing so. It also means people cannot produce multiplecdylib
s orstaticlib
s from a single package.I'd like to propose extending
[[bin]]
to allowcdylib
andstaticlib
for thecrate-type
.The text was updated successfully, but these errors were encountered: