Description: Link SYCL runtime against shared zstd when available
 The SYCL runtime library unconditionally linked the static zstd library,
 which on openKylin is not built with -fPIC and therefore fails to link into
 the shared libsycl.so / libsycl-preview.so with R_X86_64_32 relocation errors.
 Prefer the shared zstd library (zstd::libzstd_shared) unless static zstd is
 explicitly requested, mirroring LLVM's own Support library logic.
Author: tangxiaofeng <tangxiaofeng@kylinos.cn>
Origin: vendor
Forwarded: not-needed
Last-Update: 2026-09-16

--- intel-dpcpp-6.2.0.orig/sycl/source/CMakeLists.txt
+++ intel-dpcpp-6.2.0/sycl/source/CMakeLists.txt
@@ -111,7 +111,11 @@ function(add_sycl_rt_library LIB_NAME LI
   if (NOT LLVM_ENABLE_ZSTD)
     target_compile_definitions(${LIB_OBJ_NAME} PRIVATE SYCL_RT_ZSTD_NOT_AVAIABLE)
   else()
-    target_link_libraries(${LIB_NAME} PRIVATE ${zstd_STATIC_LIBRARY})
+    if (TARGET zstd::libzstd_shared AND NOT LLVM_USE_STATIC_ZSTD)
+      target_link_libraries(${LIB_NAME} PRIVATE zstd::libzstd_shared)
+    else()
+      target_link_libraries(${LIB_NAME} PRIVATE ${zstd_STATIC_LIBRARY})
+    endif()
     target_include_directories(${LIB_OBJ_NAME} PRIVATE ${zstd_INCLUDE_DIR})
   endif()
 
