From e61090515ac517f2c4afd6ea0ac32af70c1954c9 Mon Sep 17 00:00:00 2001 From: maxjivi05 Date: Tue, 10 Nov 2026 13:54:56 -0500 Subject: [PATCH] fix(fex): supply current Wayland libraries in the shared runtime --- .../overlay/usr/local/bin/droiddeck-fex | 3 +- tools/tests/test_droiddeck_fex.py | 79 +++++++++++++++++++ 2 files changed, 81 insertions(+), 1 deletion(-) diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-fex b/tools/linuxfs/overlay/usr/local/bin/droiddeck-fex index bf18c79d3c..741799f368 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-fex +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-fex @@ -37,7 +37,7 @@ RUNTIMES = {SNIPER_APPID: ("sniper_platform_", "Steam Linux Runtime 3.0 (sniper" SLR4_APPID: ("steamrt4_platform_", "Steam Linux Runtime 4.0 (steamrt4")} MARKER = ".droiddeck-fex" LAYOUT = 1 -ROOTFS_LAYOUT = 2 +ROOTFS_LAYOUT = 3 ARCH_DIRS = ("x86_64-linux-gnu", "i386-linux-gnu") INTERPRETERS = ("ld-linux-x86-64.so.2", "ld-linux.so.2") PROVIDED = frozenset(( @@ -46,6 +46,7 @@ PROVIDED = frozenset(( "libnss_compat.so.2", "libnss_dns.so.2", "libnss_files.so.2", "libnss_hesiod.so.2", "libthread_db.so.1", "libmemusage.so", "libpcprofile.so", "libc_malloc_debug.so.0", "gconv", "libstdc++.so.6", "libgcc_s.so.1", "libssl.so.3", "libcrypto.so.3", + "libwayland-client.so.0", "libwayland-cursor.so.0", "libwayland-egl.so.1", "libwayland-server.so.0", "libffi.so.8", )) GLIBC_BUILD = re.compile(r"^(?:ld|lib[A-Za-z_]+)-2\.[0-9]+\.so$|^libSegFault\.so$") GUEST_LIBDIRS = (("x86_64", "lib/x86_64-linux-gnu"), ("i386", "lib/i386-linux-gnu")) diff --git a/tools/tests/test_droiddeck_fex.py b/tools/tests/test_droiddeck_fex.py index 7bfb73b067..a7ff927fce 100644 --- a/tools/tests/test_droiddeck_fex.py +++ b/tools/tests/test_droiddeck_fex.py @@ -7,6 +7,7 @@ import runpy import shutil import struct import subprocess +import sys import tempfile import unittest from pathlib import Path @@ -450,6 +451,84 @@ class PrepareTest(FexTestCase): self.assertIn("built the x86 runtime", self.quiet(FEX["prepare"])[1]) self.assertEqual(sorted(os.listdir(root.parent)), ["config", "lock", "rootfs", "status.json"]) + def test_wayland_and_its_ffi_dependency_come_from_the_newer_runtime(self): + self.fex_tool() + sniper = self.runtime() + FEX["materialize"](str(sniper)) + provider = self.graphics(sniper) + names = ("libwayland-client.so.0", "libwayland-cursor.so.0", "libwayland-egl.so.1", + "libwayland-server.so.0", "libffi.so.8") + for arch in ("x86_64-linux-gnu", "i386-linux-gnu"): + for name in names: + base = sniper / "files/lib" / arch / name + if name != "libffi.so.8": + self.write(base, b"old ABI") + source = provider / "files/lib" / arch / name + self.write(str(source) + ".new", b"new ABI " + name.encode()) + os.symlink(name + ".new", source) + self.write(sniper / "files/lib" / arch / "libffi.so.7", b"old ffi") + fex, _ = self.quiet(FEX["prepare"]) + root = Path(fex["rootfs"]) + for arch in ("x86_64-linux-gnu", "i386-linux-gnu"): + for name in names: + library = root / "lib" / arch / name + self.assertEqual(library.resolve(), (provider / "files/lib" / arch / name).resolve()) + self.assertEqual(library.read_bytes(), b"new ABI " + name.encode()) + self.assertEqual((root / "lib" / arch / "libffi.so.7").read_bytes(), b"old ffi") + self.assertEqual((sniper / "files/lib/x86_64-linux-gnu/libwayland-client.so.0").read_bytes(), b"old ABI") + + @unittest.skipUnless(shutil.which("cc"), "C compiler unavailable") + def test_bundled_library_resolves_the_new_wayland_symbol(self): + self.fex_tool() + sniper = self.runtime() + FEX["materialize"](str(sniper)) + provider = self.graphics(sniper) + base = sniper / "files/lib/x86_64-linux-gnu" + newer = provider / "files/lib/x86_64-linux-gnu" + source = self.tmp / "library.c" + for folder, symbol in ((base, "wl_proxy_marshal"), (newer, "wl_proxy_marshal_flags")): + source.write_text("void *%s(void) { return 0; }\n" % symbol) + subprocess.run(["cc", "-shared", "-fPIC", "-nostdlib", "-Wl,-soname,libwayland-client.so.0", + "-o", str(folder / "libwayland-client.so.0"), str(source)], check=True, capture_output=True) + fex, _ = self.quiet(FEX["prepare"]) + root = Path(fex["rootfs"]) / "lib/x86_64-linux-gnu" + source.write_text("extern void *wl_proxy_marshal_flags(void);\nvoid *probe(void) { return wl_proxy_marshal_flags(); }\n") + probe = self.tmp / "libprobe.so" + subprocess.run(["cc", "-shared", "-fPIC", "-nostdlib", "-o", str(probe), str(source), + "-L" + str(newer), "-l:libwayland-client.so.0", "-Wl,-rpath," + str(root)], + check=True, capture_output=True) + command = [sys.executable, "-c", + "import ctypes,sys; " + "ctypes.CDLL(sys.argv[2], mode=ctypes.RTLD_GLOBAL) if len(sys.argv) > 2 else None; " + "ctypes.CDLL(sys.argv[1]).probe()", + str(probe)] + env = {k: v for k, v in os.environ.items() if not k.startswith("LD_")} + broken = subprocess.run(command + [str(base / "libwayland-client.so.0")], env=env, capture_output=True, text=True) + self.assertNotEqual(broken.returncode, 0) + self.assertIn("undefined symbol: wl_proxy_marshal_flags", broken.stderr) + fixed = subprocess.run(command, env=env, capture_output=True, text=True) + self.assertEqual(fixed.returncode, 0, fixed.stderr) + + def test_missing_provider_libraries_keep_the_base_runtime_libraries(self): + self.fex_tool() + sniper = self.runtime() + FEX["materialize"](str(sniper)) + self.graphics(sniper) + base = self.write(sniper / "files/lib/x86_64-linux-gnu/libwayland-client.so.0", b"base wayland") + fex, _ = self.quiet(FEX["prepare"]) + self.assertEqual((Path(fex["rootfs"]) / "lib/x86_64-linux-gnu/libwayland-client.so.0").resolve(), base) + + def test_the_old_rootfs_layout_is_rebuilt(self): + self.fex_tool() + sniper = self.runtime() + FEX["materialize"](str(sniper)) + self.graphics(sniper) + with mock.patch.dict(G, {"ROOTFS_LAYOUT": 2}): + self.quiet(FEX["prepare"]) + _, said = self.quiet(FEX["prepare"]) + self.assertIn("built the x86 runtime", said) + self.assertNotIn("built the x86 runtime", self.quiet(FEX["prepare"])[1]) + def test_a_runtime_that_is_not_newer_is_left_out(self): self.fex_tool() sniper = self.runtime()