Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[GPU] Link gpu plugin with -z nodelete when built with SYCL (#37873)

Akihiro-Tabuchi77060f449efd
diff --git a/src/plugins/intel_gpu/CMakeLists.txt b/src/plugins/intel_gpu/CMakeLists.txt
index 5560e2990d1..5f79e7f10ea 100644
--- a/src/plugins/intel_gpu/CMakeLists.txt
+++ b/src/plugins/intel_gpu/CMakeLists.txt
@@ -148,6 +148,16 @@ target_compile_options(${TARGET_NAME} PRIVATE
target_link_libraries(${TARGET_NAME} PRIVATE openvino_intel_gpu_graph openvino::pugixml)
+# Unloading a .so with SYCL code is unsafe in two ways:
+# 1. libsycl.so drops the kernel name index on unregister, so kernels provided
+# by another loaded module go missing.
+# 2. libsycl.so's static destructor touches vtables (e.g., SYCLMemObjAllocatorHolder)
+# emitted in the unloaded module at process exit (observed on an NVIDIA backend).
+# Mark the plugin NODELETE so it is never unloaded.
+if(OV_GPU_WITH_SYCL AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ target_link_options(${TARGET_NAME} PRIVATE "LINKER:-z,nodelete")
+endif()
+
target_include_directories(${TARGET_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include/)