fix(fex): thunk libOpenGL with the host GL library (#3099)

* fix(fex): x86 programs that use libOpenGL load again

* fix(fex): thunk libOpenGL with the host GL library
This commit is contained in:
MaxsTechReview authored and GitHub committed 2026-11-23 19:09:23 -05:00
1 parent f539660650
commit 8576652fb6
4 files changed
+60 -1

No files matched your search

@@ -0,0 +1,15 @@
diff --git a/Data/ThunksDB.json b/Data/ThunksDB.json
index d52ff04..886379a 100644
--- a/Data/ThunksDB.json
+++ b/Data/ThunksDB.json
@@ -6,7 +6,9 @@
"@PREFIX_LIB@/libGL.so",
"@PREFIX_LIB@/libGL.so.1",
"@PREFIX_LIB@/libGL.so.1.2.0",
- "@PREFIX_LIB@/libGL.so.1.7.0"
+ "@PREFIX_LIB@/libGL.so.1.7.0",
+ "@PREFIX_LIB@/libOpenGL.so.0",
+ "@PREFIX_LIB@/libOpenGL.so.0.0.0"
]
},
"Vulkan": {
@@ -51,7 +51,7 @@ PROVIDED = frozenset((
"libssl.so.3", "libcrypto.so.3",
"libfreetype.so.6", "libpng16.so.16", "libbrotlidec.so.1", "libbrotlicommon.so.1", "libbz2.so.1.0", "libz.so.1",
"libwayland-client.so.0", "libwayland-egl.so.1", "libwayland-server.so.0", "libffi.so.8",
"libgbm.so.1", "libdrm.so.2", "libexpat.so.1",
"libgbm.so.1", "libdrm.so.2", "libexpat.so.1", "libOpenGL.so.0",
))
PROVIDED_NEEDS = {
"libwayland-client.so.0": ("libffi.so.8",),
+15
View File
@@ -526,6 +526,21 @@ class PrepareTest(FexTestCase):
for name in names:
self.assertEqual((Path(fex["rootfs"]) / "lib" / arch / name).read_bytes(), b"new ABI " + name.encode())
def test_opengl_dispatch_library_comes_from_the_newer_runtime_when_the_base_lacks_it(self):
self.fex_tool()
sniper = self.runtime()
FEX["materialize"](str(sniper))
provider = self.graphics(sniper)
for arch in ("x86_64-linux-gnu", "i386-linux-gnu"):
self.write(sniper / "files/lib" / arch / "libGLdispatch.so.0", b"base dispatch")
self.write(provider / "files/lib" / arch / "libOpenGL.so.0.0.0", b"opengl " + arch.encode())
os.symlink("libOpenGL.so.0.0.0", provider / "files/lib" / arch / "libOpenGL.so.0")
fex, _ = self.quiet(FEX["prepare"])
for arch in ("x86_64-linux-gnu", "i386-linux-gnu"):
root = Path(fex["rootfs"]) / "lib" / arch
self.assertEqual((root / "libOpenGL.so.0").read_bytes(), b"opengl " + arch.encode())
self.assertEqual((root / "libGLdispatch.so.0").read_bytes(), b"base dispatch")
def test_gbm_requires_usable_provider_dependencies_on_both_architectures(self):
self.fex_tool()
sniper = self.runtime()
+29
View File
@@ -0,0 +1,29 @@
from pathlib import Path
import re
import unittest
PATCH = Path(__file__).resolve().parents[1] / "fex/patches/0015-gl-thunk-overlays-libopengl.patch"
def hunk(sign):
lines = [line for line in PATCH.read_text().splitlines() if not line.startswith(("diff ", "index ", "--- ", "+++ ", "@@"))]
return re.findall(r'"([^"]+)"', "\n".join(line[1:] for line in lines if line[:1] in (" ", sign)))
class FexGlThunkOverlayTest(unittest.TestCase):
def test_libopengl_joins_the_gl_overlay(self):
before, after = hunk("-"), hunk("+")
self.assertNotIn("@PREFIX_LIB@/libOpenGL.so.0", before)
self.assertIn("@PREFIX_LIB@/libOpenGL.so.0", after)
self.assertIn("@PREFIX_LIB@/libOpenGL.so.0.0.0", after)
self.assertEqual([path for path in before if path.startswith("@PREFIX_LIB@/libGL.")],
[path for path in after if path.startswith("@PREFIX_LIB@/libGL.")])
self.assertLess(after.index("@PREFIX_LIB@/libGL.so.1.7.0"), after.index("Vulkan"))
self.assertLess(after.index("@PREFIX_LIB@/libOpenGL.so.0.0.0"), after.index("Vulkan"))
def test_patch_touches_only_the_thunks_database(self):
self.assertEqual(["Data/ThunksDB.json"], re.findall(r"^diff --git a/(\S+) ", PATCH.read_text(), re.M))
if __name__ == "__main__":
unittest.main()