diff --git a/wgpu-hal/src/gles/egl.rs b/wgpu-hal/src/gles/egl.rs index 1b50d22af4..f1c7695355 100644 --- a/wgpu-hal/src/gles/egl.rs +++ b/wgpu-hal/src/gles/egl.rs @@ -114,20 +114,30 @@ fn open_x_display() -> Option<(ptr::NonNull, libloading::Library)> } } +unsafe fn find_library(paths: &[&str]) -> Option { + for path in paths { + match libloading::Library::new(path) { + Ok(lib) => return Some(lib), + _ => continue, + }; + } + None +} + fn test_wayland_display() -> Option { /* We try to connect and disconnect here to simply ensure there * is an active wayland display available. */ log::info!("Loading Wayland library to get the current display"); let library = unsafe { - let client_library = libloading::Library::new("libwayland-client.so").ok()?; + let client_library = find_library(&["libwayland-client.so.0", "libwayland-client.so"])?; let wl_display_connect: libloading::Symbol = client_library.get(b"wl_display_connect").unwrap(); let wl_display_disconnect: libloading::Symbol = client_library.get(b"wl_display_disconnect").unwrap(); let display = ptr::NonNull::new(wl_display_connect(ptr::null()))?; wl_display_disconnect(display.as_ptr()); - libloading::Library::new("libwayland-egl.so").ok()? + find_library(&["libwayland-egl.so.1", "libwayland-egl.so"])? }; Some(library) }