From 5333f4bc7b0b38f3459c4f124f83a5a53631e8cd Mon Sep 17 00:00:00 2001 From: Wenju He Date: Thu, 5 Feb 2026 07:08:02 +0100 Subject: [PATCH 1/7] [libclc] build libclc as LLVM runtime Upstream commit a3a15f3252de moved libclc from LLVM_ALL_PROJECTS to LLVM_DEFAULT_RUNTIMES. libclc should be built as a runtime. --- buildbot/configure.py | 10 +++++++--- libclc/utils/libclc-remangler/CMakeLists.txt | 4 +++- llvm/CMakeLists.txt | 4 ++-- sycl/CMakeLists.txt | 4 ++-- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/buildbot/configure.py b/buildbot/configure.py index ddeda193d9f58..ff3f4ec1e518d 100644 --- a/buildbot/configure.py +++ b/buildbot/configure.py @@ -81,7 +81,9 @@ def do_configure(args, passthrough_args): libclc_enabled = args.cuda or args.hip or args.native_cpu if libclc_enabled: - llvm_enable_projects += ";libclc" + if llvm_enable_runtimes: + llvm_enable_runtimes += ";" + llvm_enable_runtimes += "libclc" # DeviceRTL uses -fuse-ld=lld, so enable lld. if args.offload: @@ -149,12 +151,14 @@ def do_configure(args, passthrough_args): # For clang-format, clang-tidy and code coverage llvm_enable_projects += ";clang-tools-extra" + if llvm_enable_runtimes: + llvm_enable_runtimes += ";" llvm_enable_runtimes += "compiler-rt" if sys.platform != "darwin": # libclc is required for CI validation libclc_enabled = True - if "libclc" not in llvm_enable_projects: - llvm_enable_projects += ";libclc" + if "libclc" not in llvm_enable_runtimes: + llvm_enable_runtimes += ";libclc" # libclc passes `--nvvm-reflect-enable=false`, build NVPTX to enable it if "NVPTX" not in llvm_targets_to_build: llvm_targets_to_build += ";NVPTX" diff --git a/libclc/utils/libclc-remangler/CMakeLists.txt b/libclc/utils/libclc-remangler/CMakeLists.txt index c764eed682f06..0a30ba45f02ab 100644 --- a/libclc/utils/libclc-remangler/CMakeLists.txt +++ b/libclc/utils/libclc-remangler/CMakeLists.txt @@ -10,6 +10,8 @@ set(LLVM_LINK_COMPONENTS TargetParser ) +list( PREPEND CMAKE_MODULE_PATH ${LIBCLC_SOURCE_DIR}/../clang/cmake/modules ) +include( AddClang ) add_clang_tool(libclc-remangler LibclcRemangler.cpp) setup_host_tool( libclc-remangler LIBCLC_REMANGLER @@ -17,7 +19,7 @@ setup_host_tool( libclc-remangler LIBCLC_REMANGLER target_include_directories(libclc-remangler PRIVATE ${CMAKE_SOURCE_DIR}/../clang/include - ${CMAKE_BINARY_DIR}/tools/clang/include) + ${LLVM_BINARY_DIR}/tools/clang/include) clang_target_link_libraries(libclc-remangler PRIVATE diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 89fe7a0b62b02..6011ea2458bbb 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -104,7 +104,7 @@ endif() # This allows an easy way of setting up a build directory for llvm and another # one for llvm+clang+... using the same sources. # These projects will be included when "all" is included in LLVM_ENABLE_PROJECTS. -set(LLVM_ALL_PROJECTS "bolt;clang;clang-tools-extra;compiler-rt;cross-project-tests;libclc;lld;lldb;mlir;openmp;polly") +set(LLVM_ALL_PROJECTS "bolt;clang;clang-tools-extra;compiler-rt;cross-project-tests;lld;lldb;mlir;openmp;polly") set(LLVM_ALL_PROJECTS "${LLVM_ALL_PROJECTS};${LLVM_EXTERNAL_PROJECTS}") if ("${CMAKE_SYSTEM_NAME}" MATCHES "AIX") # Disallow 'openmp' as a LLVM PROJECT on AIX as the supported way is to use @@ -137,7 +137,7 @@ endforeach() # # As we migrate runtimes to using the bootstrapping build, the set of default runtimes # should grow as we remove those runtimes from LLVM_ENABLE_PROJECTS above. -set(LLVM_DEFAULT_RUNTIMES "libcxx;libcxxabi;libunwind") +set(LLVM_DEFAULT_RUNTIMES "libcxx;libcxxabi;libunwind;libclc") set(LLVM_SUPPORTED_RUNTIMES "libc;libunwind;libcxxabi;libcxx;compiler-rt;openmp;llvm-libgcc;offload;flang-rt;libclc;libsycl;orc-rt") set(LLVM_ENABLE_RUNTIMES "" CACHE STRING "Semicolon-separated list of runtimes to build, or \"all\" (${LLVM_DEFAULT_RUNTIMES}). Supported runtimes are ${LLVM_SUPPORTED_RUNTIMES}.") diff --git a/sycl/CMakeLists.txt b/sycl/CMakeLists.txt index 3586a8d725ab2..9b39f4bb320cd 100644 --- a/sycl/CMakeLists.txt +++ b/sycl/CMakeLists.txt @@ -533,7 +533,7 @@ endif() if("cuda" IN_LIST SYCL_ENABLE_BACKENDS) # Ensure that libclc is enabled. - list(FIND LLVM_ENABLE_PROJECTS libclc LIBCLC_FOUND) + list(FIND LLVM_ENABLE_RUNTIMES libclc LIBCLC_FOUND) if( LIBCLC_FOUND EQUAL -1 ) message(FATAL_ERROR "CUDA support requires adding \"libclc\" to the CMake argument \"LLVM_ENABLE_PROJECTS\"") @@ -545,7 +545,7 @@ endif() if("hip" IN_LIST SYCL_ENABLE_BACKENDS) # Ensure that libclc is enabled. - list(FIND LLVM_ENABLE_PROJECTS libclc LIBCLC_FOUND) + list(FIND LLVM_ENABLE_RUNTIMES libclc LIBCLC_FOUND) if( LIBCLC_FOUND EQUAL -1 ) message(FATAL_ERROR "HIP support requires adding \"libclc\" to the CMake argument \"LLVM_ENABLE_PROJECTS\"") From 0f6f6a0b1f130b8ce4030fd166ec3a467dee3634 Mon Sep 17 00:00:00 2001 From: Wenju He Date: Fri, 6 Feb 2026 09:10:23 +0100 Subject: [PATCH 2/7] fix sycl-toolchain and deploy-sycl-toolchain dependency --- sycl/CMakeLists.txt | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/sycl/CMakeLists.txt b/sycl/CMakeLists.txt index 9b39f4bb320cd..af397a74f1031 100644 --- a/sycl/CMakeLists.txt +++ b/sycl/CMakeLists.txt @@ -526,8 +526,8 @@ if("lld" IN_LIST LLVM_ENABLE_PROJECTS) list(APPEND SYCL_TOOLCHAIN_DEPLOY_COMPONENTS lld) endif() -if("libclc" IN_LIST LLVM_ENABLE_PROJECTS) - add_dependencies(sycl-toolchain libspirv-builtins) +if("libclc" IN_LIST LLVM_ENABLE_RUNTIMES) + add_dependencies(sycl-toolchain libclc) list(APPEND SYCL_TOOLCHAIN_DEPLOY_COMPONENTS libspirv-builtins) endif() @@ -577,24 +577,37 @@ add_custom_command(OUTPUT __force_it set(__chain_dep __force_it) set(manifest_list) +set(RUNTIME_INSTALL_SCRIPT "${CMAKE_BINARY_DIR}/runtimes/runtimes-bins/cmake_install.cmake") foreach( comp ${SYCL_TOOLCHAIN_DEPLOY_COMPONENTS} ) + set(INSTALL_SCRIPT "${CMAKE_BINARY_DIR}/cmake_install.cmake") + + set(RUNTIME_TARGET) + if("${comp}" STREQUAL "libspirv-builtins") + set(RUNTIME_TARGET libclc) + set(INSTALL_SCRIPT ${RUNTIME_INSTALL_SCRIPT}) + endif() message( STATUS "Adding component ${comp} to deploy") set (manifest_file ${CMAKE_CURRENT_BINARY_DIR}/install_manifest_${comp}.txt) add_custom_command(OUTPUT ${manifest_file} COMMAND "${CMAKE_COMMAND}" "-DCMAKE_INSTALL_COMPONENT=${comp}" - -P "${CMAKE_BINARY_DIR}/cmake_install.cmake" - DEPENDS ${__chain_dep} + -P "${INSTALL_SCRIPT}" + DEPENDS ${__chain_dep} ${RUNTIME_TARGET} COMMENT "Deploying component ${comp}" USES_TERMINAL ) - list(APPEND manifest_list ${manifest_file}) + if(RUNTIME_TARGET) + add_custom_target(manifest_target_${comp} DEPENDS ${manifest_file}) + list(APPEND manifest_targets manifest_target_${comp}) + else() + list(APPEND manifest_list ${manifest_file}) + endif() set(__chain_dep ${manifest_file}) endforeach( comp ) add_custom_target(deploy-sycl-toolchain - DEPENDS sycl-toolchain ${manifest_list} + DEPENDS sycl-toolchain ${manifest_targets} ${manifest_list} ) # SYCL Runtime documentation From 046c130e4895a01cb11bee160e86b7e3ca6663d1 Mon Sep 17 00:00:00 2001 From: Wenju He Date: Fri, 6 Feb 2026 04:09:42 -0800 Subject: [PATCH 3/7] fix sycl-jit libspirv install --- sycl-jit/jit-compiler/CMakeLists.txt | 12 +++++++++--- sycl/CMakeLists.txt | 9 ++------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/sycl-jit/jit-compiler/CMakeLists.txt b/sycl-jit/jit-compiler/CMakeLists.txt index 30ef7f7205dd2..3ec8f859b4e98 100644 --- a/sycl-jit/jit-compiler/CMakeLists.txt +++ b/sycl-jit/jit-compiler/CMakeLists.txt @@ -20,7 +20,7 @@ set(SYCL_JIT_RESOURCE_INSTALL_COMPONENTS clang-resource-headers libsycldevice) -if ("libclc" IN_LIST LLVM_ENABLE_PROJECTS) +if ("libclc" IN_LIST LLVM_ENABLE_RUNTIMES) # If some targets required `libclc` then we should embed it for the # `sycl-jit`. list(APPEND SYCL_JIT_RESOURCE_INSTALL_COMPONENTS libspirv-builtins) @@ -30,12 +30,18 @@ set(SYCL_JIT_RESOURCE_INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/rtc-resources-inst set(SYCL_JIT_PREPARE_RESOURCE_COMMANDS) foreach(component IN LISTS SYCL_JIT_RESOURCE_INSTALL_COMPONENTS) + set(BINARY_DIR ${CMAKE_BINARY_DIR}) + if("${component}" STREQUAL "libspirv-builtins") + set(BINARY_DIR ${CMAKE_BINARY_DIR}/runtimes/runtimes-bins) + list(APPEND SYCL_JIT_RESOURCE_DEPS libclc) + else() + list(APPEND SYCL_JIT_RESOURCE_DEPS ${component}) + endif() list(APPEND SYCL_JIT_PREPARE_RESOURCE_COMMANDS - COMMAND ${CMAKE_COMMAND} --install ${CMAKE_BINARY_DIR} --prefix ${SYCL_JIT_RESOURCE_INSTALL_DIR} --component "${component}" + COMMAND ${CMAKE_COMMAND} --install ${BINARY_DIR} --prefix ${SYCL_JIT_RESOURCE_INSTALL_DIR} --component "${component}" ) endforeach() -set(SYCL_JIT_RESOURCE_DEPS ${SYCL_JIT_RESOURCE_INSTALL_COMPONENTS}) # OpenCL-Headers doesn't have a corresponding build target: list(FILTER SYCL_JIT_RESOURCE_DEPS EXCLUDE REGEX "^OpenCL-Headers$") diff --git a/sycl/CMakeLists.txt b/sycl/CMakeLists.txt index af397a74f1031..4ccec9e702ff2 100644 --- a/sycl/CMakeLists.txt +++ b/sycl/CMakeLists.txt @@ -597,17 +597,12 @@ foreach( comp ${SYCL_TOOLCHAIN_DEPLOY_COMPONENTS} ) COMMENT "Deploying component ${comp}" USES_TERMINAL ) - if(RUNTIME_TARGET) - add_custom_target(manifest_target_${comp} DEPENDS ${manifest_file}) - list(APPEND manifest_targets manifest_target_${comp}) - else() - list(APPEND manifest_list ${manifest_file}) - endif() + list(APPEND manifest_list ${manifest_file}) set(__chain_dep ${manifest_file}) endforeach( comp ) add_custom_target(deploy-sycl-toolchain - DEPENDS sycl-toolchain ${manifest_targets} ${manifest_list} + DEPENDS sycl-toolchain ${manifest_list} ) # SYCL Runtime documentation From 36612dd7ea614a4f738daec69507a0999acf224c Mon Sep 17 00:00:00 2001 From: Wenju He Date: Fri, 6 Feb 2026 04:17:16 -0800 Subject: [PATCH 4/7] hoist RUNTIMES_BINARY_DIR out of loop --- sycl-jit/jit-compiler/CMakeLists.txt | 3 ++- sycl/CMakeLists.txt | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/sycl-jit/jit-compiler/CMakeLists.txt b/sycl-jit/jit-compiler/CMakeLists.txt index 3ec8f859b4e98..fe55fadd21ae6 100644 --- a/sycl-jit/jit-compiler/CMakeLists.txt +++ b/sycl-jit/jit-compiler/CMakeLists.txt @@ -29,10 +29,11 @@ endif() set(SYCL_JIT_RESOURCE_INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/rtc-resources-install) set(SYCL_JIT_PREPARE_RESOURCE_COMMANDS) +set(RUNTIMES_BINARY_DIR ${CMAKE_BINARY_DIR}/runtimes/runtimes-bins) foreach(component IN LISTS SYCL_JIT_RESOURCE_INSTALL_COMPONENTS) set(BINARY_DIR ${CMAKE_BINARY_DIR}) if("${component}" STREQUAL "libspirv-builtins") - set(BINARY_DIR ${CMAKE_BINARY_DIR}/runtimes/runtimes-bins) + set(BINARY_DIR ${RUNTIMES_BINARY_DIR}) list(APPEND SYCL_JIT_RESOURCE_DEPS libclc) else() list(APPEND SYCL_JIT_RESOURCE_DEPS ${component}) diff --git a/sycl/CMakeLists.txt b/sycl/CMakeLists.txt index 4ccec9e702ff2..9f81a34a9ae30 100644 --- a/sycl/CMakeLists.txt +++ b/sycl/CMakeLists.txt @@ -577,14 +577,14 @@ add_custom_command(OUTPUT __force_it set(__chain_dep __force_it) set(manifest_list) -set(RUNTIME_INSTALL_SCRIPT "${CMAKE_BINARY_DIR}/runtimes/runtimes-bins/cmake_install.cmake") +set(RUNTIMES_INSTALL_SCRIPT "${CMAKE_BINARY_DIR}/runtimes/runtimes-bins/cmake_install.cmake") foreach( comp ${SYCL_TOOLCHAIN_DEPLOY_COMPONENTS} ) set(INSTALL_SCRIPT "${CMAKE_BINARY_DIR}/cmake_install.cmake") set(RUNTIME_TARGET) if("${comp}" STREQUAL "libspirv-builtins") set(RUNTIME_TARGET libclc) - set(INSTALL_SCRIPT ${RUNTIME_INSTALL_SCRIPT}) + set(INSTALL_SCRIPT ${RUNTIMES_INSTALL_SCRIPT}) endif() message( STATUS "Adding component ${comp} to deploy") From 0753bc01fc63a1a2fbe7dfb32c1db092a77f8837 Mon Sep 17 00:00:00 2001 From: Wenju He Date: Fri, 6 Feb 2026 04:31:03 -0800 Subject: [PATCH 5/7] llvm_enable_runtimes.lstrip ; --- buildbot/configure.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/buildbot/configure.py b/buildbot/configure.py index ff3f4ec1e518d..79c2ae766f40f 100644 --- a/buildbot/configure.py +++ b/buildbot/configure.py @@ -81,9 +81,7 @@ def do_configure(args, passthrough_args): libclc_enabled = args.cuda or args.hip or args.native_cpu if libclc_enabled: - if llvm_enable_runtimes: - llvm_enable_runtimes += ";" - llvm_enable_runtimes += "libclc" + llvm_enable_runtimes += ";libclc" # DeviceRTL uses -fuse-ld=lld, so enable lld. if args.offload: @@ -151,9 +149,7 @@ def do_configure(args, passthrough_args): # For clang-format, clang-tidy and code coverage llvm_enable_projects += ";clang-tools-extra" - if llvm_enable_runtimes: - llvm_enable_runtimes += ";" - llvm_enable_runtimes += "compiler-rt" + llvm_enable_runtimes += ";compiler-rt" if sys.platform != "darwin": # libclc is required for CI validation libclc_enabled = True @@ -225,7 +221,7 @@ def do_configure(args, passthrough_args): if llvm_enable_runtimes: cmake_cmd.extend( [ - "-DLLVM_ENABLE_RUNTIMES={}".format(llvm_enable_runtimes), + "-DLLVM_ENABLE_RUNTIMES={}".format(llvm_enable_runtimes.lstrip(';')), ] ) From 2e03bfd704c03b3c4f3cccc1fe46d3c02b184aae Mon Sep 17 00:00:00 2001 From: Wenju He Date: Fri, 6 Feb 2026 04:34:28 -0800 Subject: [PATCH 6/7] remove an empty line --- sycl/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/sycl/CMakeLists.txt b/sycl/CMakeLists.txt index 9f81a34a9ae30..2ea6b180a0ec1 100644 --- a/sycl/CMakeLists.txt +++ b/sycl/CMakeLists.txt @@ -580,7 +580,6 @@ set(manifest_list) set(RUNTIMES_INSTALL_SCRIPT "${CMAKE_BINARY_DIR}/runtimes/runtimes-bins/cmake_install.cmake") foreach( comp ${SYCL_TOOLCHAIN_DEPLOY_COMPONENTS} ) set(INSTALL_SCRIPT "${CMAKE_BINARY_DIR}/cmake_install.cmake") - set(RUNTIME_TARGET) if("${comp}" STREQUAL "libspirv-builtins") set(RUNTIME_TARGET libclc) From 9f0c806843e6027af12f9e406904d081f7c7ac70 Mon Sep 17 00:00:00 2001 From: Wenju He Date: Fri, 6 Feb 2026 04:51:21 -0800 Subject: [PATCH 7/7] code format --- buildbot/configure.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildbot/configure.py b/buildbot/configure.py index 79c2ae766f40f..bd336bc1e5124 100644 --- a/buildbot/configure.py +++ b/buildbot/configure.py @@ -221,7 +221,7 @@ def do_configure(args, passthrough_args): if llvm_enable_runtimes: cmake_cmd.extend( [ - "-DLLVM_ENABLE_RUNTIMES={}".format(llvm_enable_runtimes.lstrip(';')), + "-DLLVM_ENABLE_RUNTIMES={}".format(llvm_enable_runtimes.lstrip(";")), ] )