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

Tom Honermann via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 9 21:20:31 PDT 2025


================
@@ -0,0 +1,115 @@
+#===============================================================================
+# Setup Project
+#===============================================================================
+cmake_minimum_required(VERSION 3.20.0)
+
+set(LLVM_SUBPROJECT_TITLE "libsycl")
+
+set(LIBSYCL_SOURCE_DIR  ${CMAKE_CURRENT_SOURCE_DIR})
+set(LIBSYCL_BINARY_DIR  ${CMAKE_CURRENT_BINARY_DIR})
+
+set(CMAKE_CXX_STANDARD 17)
+set(CMAKE_CXX_STANDARD_REQUIRED YES)
+set(CMAKE_CXX_EXTENSIONS OFF)
+
+#===============================================================================
+# Limitations
+#===============================================================================
+
+if (CMAKE_SYSTEM_NAME STREQUAL Windows AND NOT MSVC)
+# Build with other compilers is not configured, not guaranteed and not tested.
+    message( FATAL_ERROR
+      "On Windows libsycl supports compiler which is some version of Microsoft"
+      " Visual C++ or another compiler simulating the Visual C++ cl"
+      " command-line syntax" )
+endif()
+
+#===============================================================================
+# Setup CMake Options
+#===============================================================================
+
+option(LIBSYCL_ENABLE_WERROR "Treat all warnings as errors in the libsycl project" OFF)
+option(LIBSYCL_ENABLE_PEDANTIC "Compile with pedantic enabled." OFF)
+
+#===============================================================================
+# Configure System
+#===============================================================================
+
+set_property(GLOBAL PROPERTY USE_FOLDERS ON)
+
+set(LIBSYCL_SHARED_OUTPUT_NAME "sycl" CACHE STRING "Output name for the shared libsycl runtime library.")
+
+if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
+  set(LIBSYCL_TARGET_SUBDIR ${LLVM_DEFAULT_TARGET_TRIPLE})
+  if(LIBSYCL_LIBDIR_SUBDIR)
+    string(APPEND LIBSYCL_TARGET_SUBDIR /${LIBSYCL_LIBDIR_SUBDIR})
+  endif()
+  cmake_path(NORMAL_PATH LIBSYCL_TARGET_SUBDIR)
+  set(LIBSYCL_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LIBSYCL_TARGET_SUBDIR})
+  set(LIBSYCL_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LIBSYCL_TARGET_SUBDIR} CACHE STRING
+      "Path where built libsycl libraries should be installed.")
+  unset(LIBSYCL_TARGET_SUBDIR)
+else()
+  if(LLVM_LIBRARY_OUTPUT_INTDIR)
+    set(LIBSYCL_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
+  else()
+    set(LIBSYCL_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBSYCL_LIBDIR_SUFFIX})
+  endif()
+  set(LIBSYCL_INSTALL_LIBRARY_DIR lib${LIBSYCL_LIBDIR_SUFFIX} CACHE STRING
+      "Path where built libsycl libraries should be installed.")
+endif()
+
+set(LIBSYCL_INCLUDE_DIR include)
+set(LIBSYCL_BUILD_INCLUDE_DIR ${LLVM_BINARY_DIR}/${LIBSYCL_INCLUDE_DIR})
+set(LIBSYCL_SOURCE_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
+
+set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBSYCL_LIBRARY_DIR})
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBSYCL_LIBRARY_DIR})
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LIBSYCL_LIBRARY_DIR})
+
+set(LIBSYCL_MAJOR_VERSION 0)
+set(LIBSYCL_MINOR_VERSION 1)
+set(LIBSYCL_PATCH_VERSION 0)
+set(LIBSYCL_VERSION_STRING "${LIBSYCL_MAJOR_VERSION}.${LIBSYCL_MINOR_VERSION}.${LIBSYCL_PATCH_VERSION}")
+set(LIBSYCL_ABI_NAMESPACE "V${LIBSYCL_MAJOR_VERSION}" CACHE STRING
+    "The inline ABI namespace used by libsycl. It defaults to Vn where `n` is the current ABI version.")
----------------
tahonermann wrote:

DPC++ uses `_V1` for the inline ABI namespace. libc++ defaults to `__1` for the inline ABI namespace and specifically requires that the name be a reserved identifier. See https://github.com/llvm/llvm-project/blob/378e9bb7e06c67d8235a8cb5bfb325b63d2ba319/libcxx/CMakeLists.txt#L204-L207.

I'm inclined to match libc++ here or to at least use a reserved identifier; one that is distinct from what DPC++ uses so that we have a chance of the Clang and DPC++ implementations being able to coexist.

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


More information about the llvm-commits mailing list