From c5c3bff69e326791064b59cc95e06a77feac8a7a Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Fri, 20 Aug 2021 01:06:38 -0400
Subject: [PATCH] vendor source 1.5.9

---
 libepoxy/meson.build           |  2 +-
 libepoxy/src/dispatch_common.c | 18 ++++++++++++------
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/libepoxy/meson.build b/libepoxy/meson.build
index bb283ed..93b9c1a 100644
--- a/libepoxy/meson.build
+++ b/libepoxy/meson.build
@@ -1,4 +1,4 @@
-project('libepoxy', 'c', version: '1.5.7',
+project('libepoxy', 'c', version: '1.5.9',
         default_options: [
           'buildtype=debugoptimized',
           'c_std=gnu99',
diff --git a/libepoxy/src/dispatch_common.c b/libepoxy/src/dispatch_common.c
index 62b7134..592df38 100644
--- a/libepoxy/src/dispatch_common.c
+++ b/libepoxy/src/dispatch_common.c
@@ -670,17 +670,23 @@ epoxy_load_gl(void)
     get_dlopen_handle(&api.gl_handle, OPENGL_LIB, true, true);
 #else
 
+    // Prefer GLX_LIB over OPENGL_LIB to maintain existing behavior.
+    // Using the inverse ordering OPENGL_LIB -> GLX_LIB, causes issues such as:
+    // https://github.com/anholt/libepoxy/issues/240 (apitrace missing calls)
+    // https://github.com/anholt/libepoxy/issues/252 (Xorg boot crash)
+    get_dlopen_handle(&api.glx_handle, GLX_LIB, false, true);
+    api.gl_handle = api.glx_handle;
+
 #if defined(OPENGL_LIB)
     if (!api.gl_handle)
-	get_dlopen_handle(&api.gl_handle, OPENGL_LIB, false, true);
+        get_dlopen_handle(&api.gl_handle, OPENGL_LIB, false, true);
 #endif
+
     if (!api.gl_handle) {
-	get_dlopen_handle(&api.gl_handle, GLX_LIB, true, true);
-#if PLATFORM_HAS_GLX
-        if (!api.glx_handle)
-	    api.glx_handle = api.gl_handle;
-#endif
+        fprintf(stderr, "Couldn't open %s or %s\n", GLX_LIB, OPENGL_LIB);
+        abort();
     }
+
 #endif
 }
 
-- 
GitLab