-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Cargo --crate-type
CLI Argument
#3180
Conversation
Please document the commands line syntax to specify multiple values (a subset of the list values in Cargo.toml) Is it |
Wondering out loud: this might be the hook needed for 'cargo test' to be able to run #tests in source files in a wasm32 project. The developer might need to add --target in addition to --crate-type to build the tests for the local platform, but it would be nice to be able to use 'cargo test' in wasm projects. |
I think this should work for |
We talked about this in today's @rust-lang/cargo meeting, and we can understand where this is coming from, but we'd like to understand why it wouldn't suffice to simply have a separate crate exporting the cdylib/staticlib interface. If that's possible, we would prefer that approach. If that wouldn't suffice for your use case, we'd like to understand that aspect of your use case in more detail. |
One further thought from the meeting: it may make sense to restrict this only to |
I believe that having to create two packages just to change the crate type is not very ergonomic. For example, I work on a mobile project where a lib in rust is compiled for android and ios, ie a cdylib for android and a staticlib for ios. What we do is declare the lib as crate-type = ["cdylib", "staticlib"], however this is not ideal, as it generates a .a that will not be used on android, and generates a warning for ios, as that cdylibs are not supported in the platform. |
Currently passing --crate-type to It would be nice if the behavior was changed to overwrite what is in Cargo.toml |
So, in hyper's case (just 1 of the cases in the motivation), the exposed C API uses private implementation details. Shifting it to a separate crate would mean parts of the API could only depend on public details (for example, currently it can check the internal error kind, but publicly I suppose it would need to depend on the unstable But even if hyper could solve all of those problems on its own, the other motivating reason would still exist: cross-compiling. |
There's a big long standing bug that causes all sorts of problems around reexports and explicit cdylib / staticlib top level crates. If you don't use LTO you have to export all of the publicly visible symbols from the top level crate directly, reexporting doesn't work. |
Co-authored-by: Josh Triplett <[email protected]>
@seanmonstar Would |
Currently, If I use Do you mean would it be fine to make that work? Probably. I'm not stuck on it being |
I think there may have been some confusion in some of the comments above. We are suggesting to reword the RFC so that it only adds |
Oh ok, sure! I indeed was a little confused, but that would be perfectly fine. I think. I must admit, I don't know all the finer details that makes them different. It feels like |
Thanks! This looks like a good start to me. @rfcbot fcp merge |
Team member @ehuss has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
As artifact dependencies get stabilized, I would love for normal dependencies to know that they only need the |
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. This will be merged soon. |
Huzzah! The @rust-lang/cargo team has decided to accept this RFC. To track further discussion, subscribe to the tracking issue here: |
Add the ability to provide
--crate-type <crate-type>
as an argument tocargo build
. This would have the same affect of addingcrate-type
in theCargo.toml
, while taking higher priority than any value specified there.Rendered