Skip to content

Commit 6306f0f

Browse files
authored
[libclc] Support LLVM_ENABLE_RUNTIMES when building (#141574)
This commit deprecates the use of LLVM_ENABLE_PROJECTS in favour of LLVM_ENABLE_RUNTIMES when building libclc. Alternatively, using -DLLVM_RUNTIME_TARGETS=<triple> combined with -DRUNTIMES_<triple>_LLVM_ENABLE_RUNTIMES=libclc also gets pretty far but fails due to zlib problems building the LLVM utility 'prepare_builtins'. I'm not sure what's going on there but I don't think it's required at this stage. More work would be required to support that option. This does nothing to change how the host tools are found in order to be used to actually build the libclc libraries. Note that under such a configuration the final libclc builtin libraries are placed in `<build>/runtimes/runtimes-bins/libclc/`, which differs from a non-runtimes build. The installation location remains the same. Fixes #124013.
1 parent 64c094b commit 6306f0f

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

libclc/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ else()
7272
# Note that we check this later (for both build types) but we can provide a
7373
# more useful error message when built in-tree. We assume that LLVM tools are
7474
# always available so don't warn here.
75-
if( NOT clang IN_LIST LLVM_ENABLE_PROJECTS )
75+
if( NOT LLVM_RUNTIMES_BUILD AND NOT clang IN_LIST LLVM_ENABLE_PROJECTS )
7676
message(FATAL_ERROR "Clang is not enabled, but is required to build libclc in-tree")
7777
endif()
7878

llvm/CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ endforeach()
141141
# As we migrate runtimes to using the bootstrapping build, the set of default runtimes
142142
# should grow as we remove those runtimes from LLVM_ENABLE_PROJECTS above.
143143
set(LLVM_DEFAULT_RUNTIMES "libcxx;libcxxabi;libunwind")
144-
set(LLVM_SUPPORTED_RUNTIMES "libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;openmp;llvm-libgcc;offload;flang-rt")
144+
set(LLVM_SUPPORTED_RUNTIMES "libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;openmp;llvm-libgcc;offload;flang-rt;libclc")
145145
set(LLVM_ENABLE_RUNTIMES "" CACHE STRING
146146
"Semicolon-separated list of runtimes to build, or \"all\" (${LLVM_DEFAULT_RUNTIMES}). Supported runtimes are ${LLVM_SUPPORTED_RUNTIMES}.")
147147
if(LLVM_ENABLE_RUNTIMES STREQUAL "all")
@@ -204,6 +204,13 @@ if ("flang-rt" IN_LIST LLVM_ENABLE_RUNTIMES)
204204
endif ()
205205
endif ()
206206

207+
if ("libclc" IN_LIST LLVM_ENABLE_PROJECTS)
208+
message(WARNING "Using LLVM_ENABLE_PROJECTS=libclc is deprecated now, and will "
209+
"become a fatal error in the LLVM 21 release. Please use "
210+
"-DLLVM_ENABLE_RUNTIMES=libclc or see the instructions at "
211+
"https://libclc.llvm.org/ for building the runtimes.")
212+
endif()
213+
207214
# Set a shorthand option to enable the GPU build of the 'libc' project.
208215
option(LIBC_GPU_BUILD "Enable the 'libc' project targeting the GPU" OFF)
209216
if(LIBC_GPU_BUILD)

llvm/runtimes/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ endif()
193193

194194
function(_get_runtime_name name out_var)
195195
string(FIND ${name} "lib" idx)
196-
if(idx EQUAL 0 AND NOT ${name} STREQUAL "libc")
196+
if(idx EQUAL 0 AND NOT (${name} STREQUAL "libc" OR ${name} STREQUAL "libclc"))
197197
string(SUBSTRING ${name} 3 -1 name)
198198
endif()
199199
set(${out_var} ${name} PARENT_SCOPE)

runtimes/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ list(INSERT CMAKE_MODULE_PATH 0
3535

3636
# We order libraries to mirror roughly how they are layered, except that compiler-rt can depend
3737
# on libc++, so we put it after.
38-
set(LLVM_DEFAULT_RUNTIMES "libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;openmp;offload")
38+
set(LLVM_DEFAULT_RUNTIMES "libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;libclc;openmp;offload")
3939
set(LLVM_SUPPORTED_RUNTIMES "${LLVM_DEFAULT_RUNTIMES};llvm-libgcc;flang-rt")
4040
set(LLVM_ENABLE_RUNTIMES "" CACHE STRING
4141
"Semicolon-separated list of runtimes to build, or \"all\" (${LLVM_DEFAULT_RUNTIMES}). Supported runtimes are ${LLVM_SUPPORTED_RUNTIMES}.")

0 commit comments

Comments
 (0)