-
Notifications
You must be signed in to change notification settings - Fork 940
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
Build is broken with default features disabled #3174
Comments
Add these lines in Cargo.toml, it currently works for me:
And then
|
this is expected, because you've disabled both |
As I explained in the original post:
Binary crates are not the use case. The status quo makes it impossible to compile library crates depending on winit without forcing decisions that should be left to binaries. |
Winit can't work without either x11 or wayland because how it's designed. You simply want to build docs without internal dispatching somehow just by leaving top-level definitions. If you want something like that you could try to send a patch, but I have no desire to maintain support for unusable platform configuration. Could just build macOS docs at this point. |
I'm not trying to build docs. I'm trying to make a library pass CI without forcing decisions on downstream. Please reopen this issue. |
But you understand that the library is unusable? They can't use none of the winit APIs without either x11 or wayland, why we should support such a case? winit by default forces both wayland and x11, so the application works, since winit a cross platform toolkit, so we should enable all the platforms we can. I don't want winit to support building without both, since it'll require us annotate a lot of code to suppress rust warnings, because suddenly nothing works. We need especial code handling to panic when you try to run It can theoretically, build, but why should we support something that can't function? |
Downstream users will enable one or more backends. Libraries should not make that decision for them.
Because it allows libraries to depend on winit without having to choose between being forcing decisions they don't care about on their users or having hopelessly broken CI/rust-analyzer/etc. |
I don't want to continue in this conversation, it's not like you or I will change my mind. I want a library to have a sensible set of defaults. It's not like we don't let users opt-out and it's not like
Fix these tools, not complain that library enabled features, which don't even link to system libraries by default because we pick dlopen based linked.
I'm not arguing against having non-working code, sorry. Feel free to work on that if you want to, but be aware that I won't maintain non-functional mess it'll create and lots of Maybe I should just remove |
in https://github.com/imgui-rs/imgui-rs we used to get spurious errors for this ALL THE TIME until we went with Letting us build in CI and pass these bugs into user space would be great. We are an example of a library which users winit types but doesn't actually construct the backend ourselves, so we don't care what features winit is being used with |
@sanbox-irl how you do you work outside of linux then? Do you know that you link system libraries on them? I'm pretty sure no-one understands that and just want to go on a rant how bad am I for forcing users into a working library. |
So Imgui-rs is a library, not a binary. So we don't need to be executable. Users do:
If Also I'm sorry that you feel like we're "ranting" at you -- I think though that Ralith's point is respectfully delivered. If this isn't the way winit wants to go, I understand, but this is a valid concern to raise IMO! |
Please don't remove x11 - we need it for renderdoc support. I can see the argument for allowing no default features, as it stands, all libraries (egui-winit, imgui-winit, etc) that depend on winit, needs to replicate the x11/wayland feature, with defaults, so the end binary user can disable both winit and the crate's default features and enable just one backend if they do desire. On the other hand if this will cause undue maintence burden on winit, it can be worked around (see above) so it's not the end of the world. |
It is fine to have sensible defaults. That is not relevant to the problem here.
How, exactly, do you expect rustc/rust-analyzer to be fixed to successfully compile code that is malformed with default features disabled?
I'd be happy to have a go at it. I suspect it won't be as messy as you fear since the cost for backends being cfg'd out has already been paid, but I guess we'll see.
I'd be just as happy to have all backend code cfg'd out for libraries with |
I just don't understand desire for non-working library.
Exactly, it'll just spread and most users don't care. The only reason those features do exist in the first place because alacritty users asked a lot to have a way to compile without X11 at all. I'd also point that what you want to do here is very different to how it should be done. You want a way to have winit types in your downstream, not winit itself. Otherwise if you want winit itself you want to be consistent and we should have features like
And some backends have dl/non-dl varants, and Wayland has decorations variants. So in the end we end up with ~15 features, 9 of them are essential to have something working for the majority of users. |
I'll leave this up to you if you want to work on something like that, but it should meet the following:
Then I might consider it into winit, even when I don't understand the end goal with all of that when what it really sounds to me is that you want a Toolkits have a core without winit itself, but have integrations to work with winit, those integrations should pick default winit features, imho, otherwise users won't be able to run example. Do you want to tell the user to enable I'd also note that I have to deal with WAYLAND IS FUNDAMENTALLY BROKEN comments in winit for over 2 years because we haven't showed a window in examples, even tough I said that before. I really don't want to go through all of that again and read what I see sometimes, thanks. |
Thanks, I'll have a go as time permits.
This would solve some instances of the problem. However:
I agree that libraries which can be used by binaries which do not themselves have a direct dependency on winit should enable supported backends by default, if not unconditionally. However, if a binary needs a direct dependency on winit regardless (common for lightweight integration crates), then winit's own default features take effect, providing a good user experience.
I agree that avoiding confusion downstream is paramount. Leaving the default features as-is should prevent any effect on the overwhelming majority of users: today, nobody building for Linux is compiling with |
winit fails with errors including, but not limited to,
when built with
default-features = false
and no features enabled. This configuration is desirable for e.g. libraries that translate winit event types but which shouldn't have an opinion on enabled backends or configuration thereof.The text was updated successfully, but these errors were encountered: