Description: Link tracer wrappers against the PIC shared libsnappy.so
 OpenKylin's libsnappy-static archive (libsnappy.a / libsnappy-shared.a) is not
 built with -fPIC, so referencing it from the LD_PRELOAD shared-library tracers
 (glxtrace.so / egltrace.so) fails to link on amd64 with
 "relocation R_X86_64_32S ... can not be used when making a shared object".
 Prefer the PIC shared libsnappy.so, falling back to the generic libsnappy
 library if it is unavailable.
Author: tangxiaofeng <tangxiaofeng@kylinos.cn>
Forwarded: not-needed
Last-Update: 2026-08-27

--- apitrace-13.0+repack.orig/thirdparty/CMakeLists.txt
+++ apitrace-13.0+repack/thirdparty/CMakeLists.txt
@@ -34,8 +34,13 @@ endif ()
 if (ENABLE_STATIC_SNAPPY OR NOT Snappy_FOUND)
     message (STATUS "Using static SNAPPY")
     find_package(Snappy REQUIRED)
-    # Our libsnappy package builds a PIC libsnappy-shared.a archive.
-    find_library(SNAPPY_STATIC_LIBRARIES libsnappy-shared.a)
+    # OpenKylin's libsnappy-static archive (libsnappy.a / libsnappy-shared.a) is not
+    # compiled with -fPIC, so it cannot be linked into the LD_PRELOAD shared-library
+    # tracers (glxtrace.so / egltrace.so). Prefer the PIC shared libsnappy.so instead.
+    find_library(SNAPPY_STATIC_LIBRARIES libsnappy.so)
+    if (NOT SNAPPY_STATIC_LIBRARIES)
+        find_library(SNAPPY_STATIC_LIBRARIES libsnappy)
+    endif ()
 endif ()
 
 if (NOT ZLIB_FOUND)
