Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a3455c8

Browse files
committedJan 3, 2023
Fix dl-libxcb feature on OpenBSD and NetBSD
Turns out that libtool uses a different logic for turning its "-version-info" into a file name on OpenBSD and NetBSD than on Linux, Darwin, and FreeBSD. On the affected BSDs, this just takes "current", which is the first argument to "-version-info". Everywhere else, the logic is "current - age". Since libxcb uses "-version-info 2:0:1", this means that we end up with libxcb.so.2 on OpenBSD and NetBSD instead of the libxcb.so.1 that the code expects. Thus, we failed to load libxcb. Fix this by correcting the library name on OpenBSD and NetBSD. Additionally, the folder is apparently not in the default search path, so we need an absolute path. No idea whether this is also needed on OpenBSD. I will wait for someone to complain/test. Fixes: #785 Signed-off-by: Uli Schlachter <[email protected]>
1 parent c8b4c9b commit a3455c8

File tree

1 file changed

+5
-2
lines changed
  • x11rb/src/xcb_ffi/raw_ffi

1 file changed

+5
-2
lines changed
 

‎x11rb/src/xcb_ffi/raw_ffi/ffi.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,13 @@ pub(crate) mod libxcb_library {
3232
#[inline(never)]
3333
unsafe fn load() -> Result<Self, LibxcbLoadError> {
3434
// TODO: Names for non-unix platforms
35-
#[cfg(unix)]
36-
const LIB_NAME: &str = "libxcb.so.1";
3735
#[cfg(not(unix))]
3836
compile_error!("dl-libxcb feature is not supported on non-unix");
37+
#[cfg(all(unix, not(any(target_os = "openbsd", target_os = "netbsd"))))]
38+
const LIB_NAME: &str = "libxcb.so.1";
39+
// libtool turns -version-info differently into SONAMES on Open and NetBSD
40+
#[cfg(any(target_os = "openbsd", target_os = "netbsd"))]
41+
const LIB_NAME: &str = "libxcb.so.2";
3942

4043
let library = libloading::Library::new(LIB_NAME)
4144
.map_err(|e| LibxcbLoadError::OpenLibError(LIB_NAME.into(), e.to_string()))?;

0 commit comments

Comments
 (0)
Please sign in to comment.