Skip to content
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 features are not additive #3

Closed
mgeier opened this issue Aug 23, 2020 · 4 comments
Closed

Cargo features are not additive #3

mgeier opened this issue Aug 23, 2020 · 4 comments
Labels
bug Something isn't working

Comments

@mgeier
Copy link

mgeier commented Aug 23, 2020

I've just learned that Rust features are supposed to be additive, see

The features of the rmp3 crate are not additive.

For example, if the rmp3 crate appears more than once in the dependency tree and one of the instances requests the float feature, it will be activated for all instances, most likely leading to compilation errors.

Other features like no-simd will probably not lead to compilation errors, but just to very much unexpected minimp3 build options.

I don't have any practical experience with this, is this a problem?

If yes, what is the solution?

I'm asking this because I'm working on similar bindings: https://github.com/mgeier/minimp3_ex-sys.

@0x08088405
Copy link
Owner

0x08088405 commented Aug 23, 2020

Yeah, that is indeed an issue. However these features map to non-additive features in minimp3 itself, so I'm not sure if there is a good solution for that. Should I just add a warning? I have thought about compiling multiple instances of minimp3 as a workaround in the past but that would lead to ugly linker errors unless I write a script to substitute function names and definitions, I suppose, but that still wouldn't work with things like NO_SIMD.

@0x08088405 0x08088405 added the bug Something isn't working label Aug 23, 2020
@mgeier
Copy link
Author

mgeier commented Aug 25, 2020

Should I just add a warning?

I don't know.
Do you mean a warning in the documentation?
Or is there a way to create a warning during the build process?

Would this problem even appear in practice?
Is it realistic that there are multiple dependencies to rmp3 in a project?

@mgeier
Copy link
Author

mgeier commented Aug 30, 2020

FYI, I've just published my crate: https://docs.rs/minimp3_ex-sys/0.1.0/

I've removed all features that I don't need myself, leaving only the float-output feature.
For this I've added a warning to the docs.

In the rare case of a feature mismatch this should lead to a hard compilation error.

A mismatch in the other features would not easily be noticed be users, so I completely removed them for now (mgeier/minimp3_ex-sys@74e0b27).
If and when we find a good solution for those non-additive features, I can add them back.

@0x08088405
Copy link
Owner

This is extremely late, but I've released 0.3, a complete rewrite, and I inverted most of the flags where applicable so they can be additive. For float, I also just added a warning and linked the explanation linked here. Not much else you can do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants