Use the system libjpeg.so in gamescope sessions
Description
Gamescope fails to start on Xiaomi HyperOS devices:
CANNOT LINK EXECUTABLE ".../files/gamescope/bin/gamescope": cannot locate symbol
"jsimd_huff_encode_one_block" referenced by "/system_ext/lib64/libjpeg-hyper.so"
libgndrm_shim.so pulls in libandroid.so, and on HyperOS that reaches libjpeg-hyper.so, which needs the jsimd_* exports of the system libjpeg.so. The session's LD_LIBRARY_PATH puts imagefs/usr/lib ahead of /system/lib64, so libjpeg.so resolved to imagefs's libjpeg-turbo, which exports no jsimd_* symbols. This is the same issue as the Samsung libcrypto.so fix in #2223, so the system libjpeg.so now gets linked into gamescope_system_libs alongside libcrypto.so.
imagefs consumers (libgstjpeg, libtiff, gdk-pixbuf) all need libjpeg.so.8 by soname, so they keep resolving to imagefs's copy.
Not tested on a HyperOS device yet. The diagnosis comes from a user's logcat.
Recording
N/A, this is a link-time 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 failing to start on Xiaomi HyperOS, where linking could not resolve jsimd_huff_encode_one_block because LD_LIBRARY_PATH picked imagefs's libjpeg-turbo over the system's libjpeg.so.
The system libjpeg.so is now symlinked into gamescope_system_libs alongside libcrypto.so, and that directory is prepended to LD_LIBRARY_PATH only when at least one system lib was linked. imagefs consumers still resolve their own copy of libjpeg since they need libjpeg.so.8 by soname.
Summary by CodeRabbit
- New Features
- Gamescope now includes available system crypto and JPEG libraries in its library search path, in addition to the previously supported crypto library. This may improve compatibility with games and applications that rely on these system libraries.