Fix gamescope sessions failing to start on Samsung

Merged
UT
18d ago
+10-1

Description

Gamescope sessions crash at launch on Samsung phones. Tested on a Galaxy Z Fold 5 (SM-F946U1, SM8550): every gamescope launch failed before the game started, while X11 worked.

F linker: CANNOT LINK EXECUTABLE ".../files/gamescope/bin/gamescope": cannot locate symbol "OpenSSL_add_all_algorithms" referenced by "/system/lib64/libsqlite.so"

libgndrm_shim.so is preloaded into every gamescope session process and needs libandroid.so. Samsung's libandroid.so needs libandroid_runtime.so -> libsqlite.so -> libcrypto.so. With imagefs/usr/lib ahead of /system/lib64 on LD_LIBRARY_PATH, that libcrypto.so resolved to imagefs's symlink to OpenSSL 3, which doesn't export the BoringSSL symbols libsqlite wants.

Fix: for gamescope sessions, link /system/lib64/libcrypto.so into files/gamescope_system_libs/libcrypto.so and put that dir first on the session path. Only lookups of the exact name libcrypto.so change. I checked the imagefs on the device: every library there that uses OpenSSL needs libcrypto.so.3, so none of them picks up the system one. Nothing under imagefs/opt references libcrypto.

Tested on the Fold 5 (modern debug build):

  • no more link errors across 3 gamescope launches
  • Celeste reaches the title screen at 60 fps under gamescope
  • Persona 5 Royal now starts (P5R.exe, gamescope and Xwayland running) but stays on the splash; looks like a dialog gamescope doesn't show. That's a separate issue.

Recording

N/A, launch-time linker fix.

Type of Change

  • Bug fix
  • Performance / stability improvement
  • Compatibility improvements
  • Other (requires prior approval)

Checklist

  • If I have access to #code-changes, I have discussed this change there and it has been green-lighted. If I do not have access, I have still provided clear context in this PR. If I skip both, I accept that this change may face delays in review, may not be reviewed at all, or may be closed.
  • This change aligns with the current project scope (core functionality, stability, or performance). If not, it has been explicitly approved beforehand.
  • I have attached a recording of the change.
  • I have read and agree to the contribution guidelines in CONTRIBUTING.md.

Summary by cubic

Fixes gamescope sessions failing to start on Samsung devices at launch with a linker error (OpenSSL_add_all_algorithms not found).

The gamescope shim pulls in libandroid.so, which on Samsung chains to libsqlite.so needing the system BoringSSL libcrypto.so. The imagefs OpenSSL 3 symlink was being resolved instead, so the fix symlinks /system/lib64/libcrypto.so into a directory placed first on the gamescope session's LD_LIBRARY_PATH. Only lookups of the exact name libcrypto.so change; nothing in imagefs depends on the system variant.

Summary by CodeRabbit

  • Bug Fixes
    • Improved compatibility when launching Gamescope by making the system crypto library available in its library search path when present.