gfx-rs / gfx

[maintenance mode] A low-overhead Vulkan-like GPU API for Rust.
http://gfx-rs.github.io/
Apache License 2.0
5.35k stars 547 forks source link

build error on Solaris: no variant or associated item named `Xcb` found for enum `RawWindowHandle` #3547

Closed psumbera closed 1 year ago

psumbera commented 3 years ago
   Compiling gfx-backend-vulkan v0.6.5 (/builds/psumbera/VULKAN/gfx/src/backend/vulkan)
error[E0599]: no variant or associated item named `Xcb` found for enum `RawWindowHandle` in the current scope
   --> src/backend/vulkan/src/lib.rs:594:30
    |
594 |             RawWindowHandle::Xcb(handle)
    |                              ^^^ variant or associated item not found in `RawWindowHandle`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0599`.
error: could not compile `gfx-backend-vulkan`

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed

Seems to be caused by:

https://github.com/gfx-rs/gfx/commit/a498b475003c03319d9d79ce2eae0c1d3f1e9813

Following seems to fix the issue:

diff --git a/src/backend/vulkan/src/lib.rs b/src/backend/vulkan/src/lib.rs
index c5f27e73..cd378eb3 100644
--- a/src/backend/vulkan/src/lib.rs
+++ b/src/backend/vulkan/src/lib.rs
@@ -586,6 +586,7 @@ impl hal::Instance<Backend> for Instance {
                 Ok(self.create_surface_from_xlib(handle.display as *mut _, handle.window))
             }
             #[cfg(all(
+                feature = "xcb",
                 unix,
                 not(target_os = "android"),
                 not(target_os = "macos"),
kvark commented 3 years ago

We no longer have the "xcb" feature, so we can't follow your suggested fix.

However, what we should do is just mirroring RawWindowHandle feature flags when checking for Xlib. See https://github.com/rust-windowing/raw-window-handle/blob/73a41ea28907b0f261816136b1b3f39cfdd791f3/src/lib.rs#L121-L125

kvark commented 3 years ago

Started the discussion about BSD configs on the rust-internals forum...

psumbera commented 3 years ago

Ok. Shall I wait with submitting following fix?

index c5f27e73..22afacbe 100644
--- a/src/backend/vulkan/src/lib.rs
+++ b/src/backend/vulkan/src/lib.rs
@@ -589,7 +589,8 @@ impl hal::Instance<Backend> for Instance {
                 unix,
                 not(target_os = "android"),
                 not(target_os = "macos"),
-                not(target_os = "ios")
+                not(target_os = "ios"),
+                not(target_os = "solaris"),
             ))]
             RawWindowHandle::Xcb(handle)
                 if self
kvark commented 3 years ago

if you can instead make a PR with the configuration used by RawWindowHandle code, that would be great!

psumbera commented 3 years ago

if you can instead make a PR with the configuration used by RawWindowHandle code, that would be great!

Sorry I think I'm still missing what change I should prepare. Can you please more elaborate what and where I should put.

kvark commented 3 years ago

I believe the match arms for RWH in gfx-rs have to be gated the same way as they are in RWH definition itself, see the link I provided earlier. For Xcb in particular, this would be:

        cfg(any(
            target_os = "linux",
            target_os = "dragonfly",
            target_os = "freebsd",
            target_os = "netbsd",
            target_os = "openbsd"
        ))
psumbera commented 3 years ago

There is actually one year old pull request for that. Can you please have look at it?

https://github.com/rust-windowing/raw-window-handle/pull/44

kvark commented 3 years ago

Thank you! Let's see how they respond now that you pinged them.

ErichDonGubler commented 1 year ago

@psumbera: Is this still an issue we should resolve here?

psumbera commented 1 year ago

No, we can close the issue now.