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.

(cherry picked from commit 7d060ba4f1)
This commit is contained in:
Camilla Löwy 2021-12-22 22:19:25 +01:00
parent 8ecb49d143
commit 65fc4fa625
6 changed files with 31 additions and 0 deletions

View File

@ -123,6 +123,7 @@ information on what to include when reporting a bug.
## Changelog ## Changelog
- [X11] Bugfix: Dynamic loading on OpenBSD failed due to soname differences
- [Wayland] Bugfix: Key repeat could lead to a race condition (#1710) - [Wayland] Bugfix: Key repeat could lead to a race condition (#1710)
- [Wayland] Bugfix: Activating a window would emit two input focus events - [Wayland] Bugfix: Activating a window would emit two input focus events
- [Wayland] Bugfix: Disable key repeat mechanism when window loses input focus - [Wayland] Bugfix: Disable key repeat mechanism when window loses input focus

View File

@ -320,6 +320,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
@ -641,6 +643,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",
@ -658,6 +662,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
@ -669,6 +675,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

@ -260,6 +260,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

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

View File

@ -568,7 +568,11 @@ static void detectEWMH(void)
// //
static GLFWbool initExtensions(void) static GLFWbool initExtensions(void)
{ {
#if defined(__OpenBSD__)
_glfw.x11.vidmode.handle = _glfw_dlopen("libXxf86vm.so");
#else
_glfw.x11.vidmode.handle = _glfw_dlopen("libXxf86vm.so.1"); _glfw.x11.vidmode.handle = _glfw_dlopen("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)
@ -588,6 +592,8 @@ static GLFWbool initExtensions(void)
#if defined(__CYGWIN__) #if defined(__CYGWIN__)
_glfw.x11.xi.handle = _glfw_dlopen("libXi-6.so"); _glfw.x11.xi.handle = _glfw_dlopen("libXi-6.so");
#elif defined(__OpenBSD__)
_glfw.x11.xi.handle = _glfw_dlopen("libXi.so");
#else #else
_glfw.x11.xi.handle = _glfw_dlopen("libXi.so.6"); _glfw.x11.xi.handle = _glfw_dlopen("libXi.so.6");
#endif #endif
@ -618,6 +624,8 @@ static GLFWbool initExtensions(void)
#if defined(__CYGWIN__) #if defined(__CYGWIN__)
_glfw.x11.randr.handle = _glfw_dlopen("libXrandr-2.so"); _glfw.x11.randr.handle = _glfw_dlopen("libXrandr-2.so");
#elif defined(__OpenBSD__)
_glfw.x11.randr.handle = _glfw_dlopen("libXrandr.so");
#else #else
_glfw.x11.randr.handle = _glfw_dlopen("libXrandr.so.2"); _glfw.x11.randr.handle = _glfw_dlopen("libXrandr.so.2");
#endif #endif
@ -710,6 +718,8 @@ static GLFWbool initExtensions(void)
#if defined(__CYGWIN__) #if defined(__CYGWIN__)
_glfw.x11.xcursor.handle = _glfw_dlopen("libXcursor-1.so"); _glfw.x11.xcursor.handle = _glfw_dlopen("libXcursor-1.so");
#elif defined(__OpenBSD__)
_glfw.x11.xcursor.handle = _glfw_dlopen("libXcursor.so");
#else #else
_glfw.x11.xcursor.handle = _glfw_dlopen("libXcursor.so.1"); _glfw.x11.xcursor.handle = _glfw_dlopen("libXcursor.so.1");
#endif #endif
@ -725,6 +735,8 @@ static GLFWbool initExtensions(void)
#if defined(__CYGWIN__) #if defined(__CYGWIN__)
_glfw.x11.xinerama.handle = _glfw_dlopen("libXinerama-1.so"); _glfw.x11.xinerama.handle = _glfw_dlopen("libXinerama-1.so");
#elif defined(__OpenBSD__)
_glfw.x11.xinerama.handle = _glfw_dlopen("libXinerama.so");
#else #else
_glfw.x11.xinerama.handle = _glfw_dlopen("libXinerama.so.1"); _glfw.x11.xinerama.handle = _glfw_dlopen("libXinerama.so.1");
#endif #endif
@ -776,6 +788,8 @@ static GLFWbool initExtensions(void)
#if defined(__CYGWIN__) #if defined(__CYGWIN__)
_glfw.x11.x11xcb.handle = _glfw_dlopen("libX11-xcb-1.so"); _glfw.x11.x11xcb.handle = _glfw_dlopen("libX11-xcb-1.so");
#elif defined(__OpenBSD__)
_glfw.x11.x11xcb.handle = _glfw_dlopen("libX11-xcb.so");
#else #else
_glfw.x11.x11xcb.handle = _glfw_dlopen("libX11-xcb.so.1"); _glfw.x11.x11xcb.handle = _glfw_dlopen("libX11-xcb.so.1");
#endif #endif
@ -787,6 +801,8 @@ static GLFWbool initExtensions(void)
#if defined(__CYGWIN__) #if defined(__CYGWIN__)
_glfw.x11.xrender.handle = _glfw_dlopen("libXrender-1.so"); _glfw.x11.xrender.handle = _glfw_dlopen("libXrender-1.so");
#elif defined(__OpenBSD__)
_glfw.x11.xrender.handle = _glfw_dlopen("libXrender.so");
#else #else
_glfw.x11.xrender.handle = _glfw_dlopen("libXrender.so.1"); _glfw.x11.xrender.handle = _glfw_dlopen("libXrender.so.1");
#endif #endif