[llvm] [SYCL] Add libsycl, a SYCL RT library implementation project (PR #144372)

Tom Honermann via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 1 23:20:02 PDT 2025


================
@@ -0,0 +1,111 @@
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../runtimes/cmake/Modules")
+include(WarningFlags)
+
+function(add_sycl_rt_library LIB_NAME LIB_OBJ_NAME)
+  if (NOT LLVM_ENABLE_PIC)
+    message( FATAL_ERROR "Position-Independent Code generation is required for libsycl shared library" )
+  endif()
+  # Add an optional argument so we can get the library name to
+  # link with for Windows Debug version
+  cmake_parse_arguments(ARG "" "IMPLIB_NAME" "COMPILE_OPTIONS;SOURCES" ${ARGN})
+
+  add_library(${LIB_OBJ_NAME} OBJECT ${ARG_SOURCES})
+
+  # Common compilation step setup
+  target_compile_definitions(${LIB_OBJ_NAME} PRIVATE $<$<BOOL:${MSVC}>:_LIBSYCL_BUILD_SYCL_DLL>)
+  cxx_add_warning_flags(${LIB_OBJ_NAME} ${LIBSYCL_ENABLE_WERROR} ${LIBSYCL_ENABLE_PEDANTIC})
+
+  target_include_directories(
+    ${LIB_OBJ_NAME}
+    PRIVATE
+      ${CMAKE_CURRENT_SOURCE_DIR}
+      ${LIBSYCL_BUILD_INCLUDE_DIR}
+  )
+
+  add_library(${LIB_NAME} SHARED
+              $<TARGET_OBJECTS:${LIB_OBJ_NAME}>)
+
+  add_dependencies(${LIB_OBJ_NAME}
+    sycl-headers
+  )
+
+  set_target_properties(${LIB_NAME} PROPERTIES LINKER_LANGUAGE CXX)
+
+  if (WIN32)
+    target_link_libraries(${LIB_NAME} PRIVATE shlwapi)
----------------
tahonermann wrote:

There is a chance that the dependency won't be needed once the code that currently requires it is put up for review. LLVM already provides abstractions for many of the features provided by shlwapi. Depending on what functionality is needed, it might make more sense to add an abstraction for it in one of the low-level LLVM libraries like `llvm/Support`.

https://github.com/llvm/llvm-project/pull/144372


More information about the llvm-commits mailing list