-
Notifications
You must be signed in to change notification settings - Fork 975
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
Make wgpu-hal
crate features target aware
#3465
Comments
Thanks for raising this issue! I think we'd like to be able to rely on the Similarly we don't allow cross compilation of some backends (e.g., cross compiling the Metal backend on Linux) so I think it would be better to fail at compile-time to let the person know instead of runtime with a no-op. Is there a reason we need to support |
It is not a "need", there are plenty of ways to work around that. Mainly I was motivated by making the docs.rs build work, because right now it is using It is also beneficial for downstream users, specifically reducing the amount of
Could you elaborate on that? How does relying on the
I'm not following here, I can't see that the current crate feature system disallows cross compilation anywhere. Could you point me into the right direction? Lots of crates do it like this, think of I was under the impression that such a change really would have no downsides except the fact that it is a change and people have to be aware that using these target features is no-op on certain systems. I would like to better understand any potential issues here. |
I'm not sure if this is possible because we can't certain build dependencies of the
I mean being able to disable/enable features conditionally based on the target by default. e.g., Lines 115 to 117 in 9908f3e
target_os = "macos" which is convenient because some dependencies for that backend are gated in the same way Lines 98 to 101 in 9908f3e
Ideally we'd like to say that certain features can only be enabled on specific targets but as far as I know there isn't a way to express target-specific features in
I don't think In case it's helpful, the discussion at #1221 is also relevant and talks about the issue with target-specific features. |
That ability doesn't go away with what I'm proposing, see #3466.
Indeed, I was specifically talking about
That is really interesting, I think my proposal here would address this issue nicely! |
I left a comment on #1221 (comment). I think that one is more about disabling the GLES and DX11 backends. |
I noticed that the way
wgpu-hal
s crate features are designed is target independent.The problem is of course that using
--all-features
or any other non-compatible crate feature will break compilation. See #3463 for example.I propose that activating crate features on
wgpu-hal
that only work on specific targets should be no-op on non-compatible targets.For example activating the
vulkan
crate feature onwasm32-unknown-unknown
should do nothing.Additionally I think removing
wgpu/wgpu-hal/src/lib.rs
Lines 54 to 61 in 5b8c55c
I think the only downside this change would introduce is that you could have activated crate features that you don't really need for your target, which shouldn't really have any downside if they are no-op.
The text was updated successfully, but these errors were encountered: