X11: Fix sonames for loaded libraries on OpenBSD

The OpenBSD ports tree assigns its own soname version numbers, so the
hardcoded sonames GLFW uses to load libraries on non-macOS Unices are
often incorrect.  Instead OpenBSD recommends that run-time loading
should leave out the version numbers entirely.  The OpenBSD ld.so then
finds the correct library.

This upstreams the ports tree fixes for Xcursor and EGL, and adds the
corresponding fix for all other run-time loaded library sonames.

Tested on OpenBSD 7.0.

This issue was initially reported on IRC.
This commit is contained in:
Camilla Löwy 2021-12-22 22:19:25 +01:00
parent f8ef3ca719
commit 7d060ba4f1
6 changed files with 35 additions and 0 deletions

View File

@ -264,6 +264,7 @@ information on what to include when reporting a bug.
- [X11] Bugfix: Changing `GLFW_FLOATING` could leak memory - [X11] Bugfix: Changing `GLFW_FLOATING` could leak memory
- [X11] Bugfix: Icon pixel format conversion worked only by accident, relying on - [X11] Bugfix: Icon pixel format conversion worked only by accident, relying on
undefined behavior (#1986) undefined behavior (#1986)
- [X11] Bugfix: Dynamic loading on OpenBSD failed due to soname differences
- [Wayland] Added dynamic loading of all Wayland libraries - [Wayland] Added dynamic loading of all Wayland libraries
- [Wayland] Removed support for `wl_shell` (#1443) - [Wayland] Removed support for `wl_shell` (#1443)
- [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432) - [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432)

View File

@ -325,6 +325,8 @@ GLFWbool _glfwInitEGL(void)
"libEGL.dylib", "libEGL.dylib",
#elif defined(__CYGWIN__) #elif defined(__CYGWIN__)
"libEGL-1.so", "libEGL-1.so",
#elif defined(__OpenBSD__)
"libEGL.so",
#else #else
"libEGL.so.1", "libEGL.so.1",
#endif #endif
@ -700,6 +702,8 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
"libGLES_CM.dll", "libGLES_CM.dll",
#elif defined(_GLFW_COCOA) #elif defined(_GLFW_COCOA)
"libGLESv1_CM.dylib", "libGLESv1_CM.dylib",
#elif defined(__OpenBSD__)
"libGLESv1_CM.so",
#else #else
"libGLESv1_CM.so.1", "libGLESv1_CM.so.1",
"libGLES_CM.so.1", "libGLES_CM.so.1",
@ -717,6 +721,8 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
"libGLESv2.dylib", "libGLESv2.dylib",
#elif defined(__CYGWIN__) #elif defined(__CYGWIN__)
"libGLESv2-2.so", "libGLESv2-2.so",
#elif defined(__OpenBSD__)
"libGLESv2.so",
#else #else
"libGLESv2.so.2", "libGLESv2.so.2",
#endif #endif
@ -728,6 +734,8 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
_GLFW_OPENGL_LIBRARY, _GLFW_OPENGL_LIBRARY,
#elif defined(_GLFW_WIN32) #elif defined(_GLFW_WIN32)
#elif defined(_GLFW_COCOA) #elif defined(_GLFW_COCOA)
#elif defined(__OpenBSD__)
"libGL.so",
#else #else
"libGL.so.1", "libGL.so.1",
#endif #endif

View File

@ -259,6 +259,8 @@ GLFWbool _glfwInitGLX(void)
_GLFW_GLX_LIBRARY, _GLFW_GLX_LIBRARY,
#elif defined(__CYGWIN__) #elif defined(__CYGWIN__)
"libGL-1.so", "libGL-1.so",
#elif defined(__OpenBSD__)
"libGL.so",
#else #else
"libGL.so.1", "libGL.so.1",
"libGL.so", "libGL.so",

View File

@ -124,6 +124,8 @@ GLFWbool _glfwInitOSMesa(void)
"libOSMesa.8.dylib", "libOSMesa.8.dylib",
#elif defined(__CYGWIN__) #elif defined(__CYGWIN__)
"libOSMesa-8.so", "libOSMesa-8.so",
#elif defined(__OpenBSD__)
"libOSMesa.so",
#else #else
"libOSMesa.so.8", "libOSMesa.so.8",
"libOSMesa.so.6", "libOSMesa.so.6",

View File

@ -63,6 +63,8 @@ GLFWbool _glfwInitVulkan(int mode)
_glfw.vk.handle = _glfwPlatformLoadModule("libvulkan.1.dylib"); _glfw.vk.handle = _glfwPlatformLoadModule("libvulkan.1.dylib");
if (!_glfw.vk.handle) if (!_glfw.vk.handle)
_glfw.vk.handle = _glfwLoadLocalVulkanLoaderCocoa(); _glfw.vk.handle = _glfwLoadLocalVulkanLoaderCocoa();
#elif defined(__OpenBSD__)
_glfw.vk.handle = _glfwPlatformLoadModule("libvulkan.so");
#else #else
_glfw.vk.handle = _glfwPlatformLoadModule("libvulkan.so.1"); _glfw.vk.handle = _glfwPlatformLoadModule("libvulkan.so.1");
#endif #endif

View File

@ -601,7 +601,11 @@ static void detectEWMH(void)
// //
static GLFWbool initExtensions(void) static GLFWbool initExtensions(void)
{ {
#if defined(__OpenBSD__)
_glfw.x11.vidmode.handle = _glfwPlatformLoadModule("libXxf86vm.so");
#else
_glfw.x11.vidmode.handle = _glfwPlatformLoadModule("libXxf86vm.so.1"); _glfw.x11.vidmode.handle = _glfwPlatformLoadModule("libXxf86vm.so.1");
#endif
if (_glfw.x11.vidmode.handle) if (_glfw.x11.vidmode.handle)
{ {
_glfw.x11.vidmode.QueryExtension = (PFN_XF86VidModeQueryExtension) _glfw.x11.vidmode.QueryExtension = (PFN_XF86VidModeQueryExtension)
@ -621,6 +625,8 @@ static GLFWbool initExtensions(void)
#if defined(__CYGWIN__) #if defined(__CYGWIN__)
_glfw.x11.xi.handle = _glfwPlatformLoadModule("libXi-6.so"); _glfw.x11.xi.handle = _glfwPlatformLoadModule("libXi-6.so");
#elif defined(__OpenBSD__)
_glfw.x11.xi.handle = _glfwPlatformLoadModule("libXi.so");
#else #else
_glfw.x11.xi.handle = _glfwPlatformLoadModule("libXi.so.6"); _glfw.x11.xi.handle = _glfwPlatformLoadModule("libXi.so.6");
#endif #endif
@ -651,6 +657,8 @@ static GLFWbool initExtensions(void)
#if defined(__CYGWIN__) #if defined(__CYGWIN__)
_glfw.x11.randr.handle = _glfwPlatformLoadModule("libXrandr-2.so"); _glfw.x11.randr.handle = _glfwPlatformLoadModule("libXrandr-2.so");
#elif defined(__OpenBSD__)
_glfw.x11.randr.handle = _glfwPlatformLoadModule("libXrandr.so");
#else #else
_glfw.x11.randr.handle = _glfwPlatformLoadModule("libXrandr.so.2"); _glfw.x11.randr.handle = _glfwPlatformLoadModule("libXrandr.so.2");
#endif #endif
@ -743,6 +751,8 @@ static GLFWbool initExtensions(void)
#if defined(__CYGWIN__) #if defined(__CYGWIN__)
_glfw.x11.xcursor.handle = _glfwPlatformLoadModule("libXcursor-1.so"); _glfw.x11.xcursor.handle = _glfwPlatformLoadModule("libXcursor-1.so");
#elif defined(__OpenBSD__)
_glfw.x11.xcursor.handle = _glfwPlatformLoadModule("libXcursor.so");
#else #else
_glfw.x11.xcursor.handle = _glfwPlatformLoadModule("libXcursor.so.1"); _glfw.x11.xcursor.handle = _glfwPlatformLoadModule("libXcursor.so.1");
#endif #endif
@ -764,6 +774,8 @@ static GLFWbool initExtensions(void)
#if defined(__CYGWIN__) #if defined(__CYGWIN__)
_glfw.x11.xinerama.handle = _glfwPlatformLoadModule("libXinerama-1.so"); _glfw.x11.xinerama.handle = _glfwPlatformLoadModule("libXinerama-1.so");
#elif defined(__OpenBSD__)
_glfw.x11.xinerama.handle = _glfwPlatformLoadModule("libXinerama.so");
#else #else
_glfw.x11.xinerama.handle = _glfwPlatformLoadModule("libXinerama.so.1"); _glfw.x11.xinerama.handle = _glfwPlatformLoadModule("libXinerama.so.1");
#endif #endif
@ -817,6 +829,8 @@ static GLFWbool initExtensions(void)
{ {
#if defined(__CYGWIN__) #if defined(__CYGWIN__)
_glfw.x11.x11xcb.handle = _glfwPlatformLoadModule("libX11-xcb-1.so"); _glfw.x11.x11xcb.handle = _glfwPlatformLoadModule("libX11-xcb-1.so");
#elif defined(__OpenBSD__)
_glfw.x11.x11xcb.handle = _glfwPlatformLoadModule("libX11-xcb.so");
#else #else
_glfw.x11.x11xcb.handle = _glfwPlatformLoadModule("libX11-xcb.so.1"); _glfw.x11.x11xcb.handle = _glfwPlatformLoadModule("libX11-xcb.so.1");
#endif #endif
@ -830,6 +844,8 @@ static GLFWbool initExtensions(void)
#if defined(__CYGWIN__) #if defined(__CYGWIN__)
_glfw.x11.xrender.handle = _glfwPlatformLoadModule("libXrender-1.so"); _glfw.x11.xrender.handle = _glfwPlatformLoadModule("libXrender-1.so");
#elif defined(__OpenBSD__)
_glfw.x11.xrender.handle = _glfwPlatformLoadModule("libXrender.so");
#else #else
_glfw.x11.xrender.handle = _glfwPlatformLoadModule("libXrender.so.1"); _glfw.x11.xrender.handle = _glfwPlatformLoadModule("libXrender.so.1");
#endif #endif
@ -857,6 +873,8 @@ static GLFWbool initExtensions(void)
#if defined(__CYGWIN__) #if defined(__CYGWIN__)
_glfw.x11.xshape.handle = _glfwPlatformLoadModule("libXext-6.so"); _glfw.x11.xshape.handle = _glfwPlatformLoadModule("libXext-6.so");
#elif defined(__OpenBSD__)
_glfw.x11.xshape.handle = _glfwPlatformLoadModule("libXext.so");
#else #else
_glfw.x11.xshape.handle = _glfwPlatformLoadModule("libXext.so.6"); _glfw.x11.xshape.handle = _glfwPlatformLoadModule("libXext.so.6");
#endif #endif
@ -1203,6 +1221,8 @@ GLFWbool _glfwConnectX11(int platformID, _GLFWplatform* platform)
#if defined(__CYGWIN__) #if defined(__CYGWIN__)
void* module = _glfwPlatformLoadModule("libX11-6.so"); void* module = _glfwPlatformLoadModule("libX11-6.so");
#elif defined(__OpenBSD__)
void* module = _glfwPlatformLoadModule("libX11.so");
#else #else
void* module = _glfwPlatformLoadModule("libX11.so.6"); void* module = _glfwPlatformLoadModule("libX11.so.6");
#endif #endif