Skip to content

[libclc] Support LLVM_ENABLE_RUNTIMES when building #141574

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libclc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ else()
# Note that we check this later (for both build types) but we can provide a
# more useful error message when built in-tree. We assume that LLVM tools are
# always available so don't warn here.
if( NOT clang IN_LIST LLVM_ENABLE_PROJECTS )
if( NOT LLVM_RUNTIMES_BUILD AND NOT clang IN_LIST LLVM_ENABLE_PROJECTS )
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd quite like to keep this check/error if possible. The error you get if you forget -LLVM_ENABLE_PROJECTS=clang is horrible. Do you think it would it acceptable to pass through LLVM_ENABLE_PROJECTS to the runtimes build, @jhuber6?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The runtimes builds pass this USE_TOOLCHAIN argument which tells the external project utility to grab the clang from the build directory. If we don't have clang it might be more reasonable to just emit a warning there. @petrhosek Is there a reason we don't already emit a warning / error if the user does a runtimes build without clang to bootstrap?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Yes I suppose in the absence of a higher-level warning like you describe, we could probably use USE_TOOLCHAIN to accomplish the same thing in a runtimes build.

With any luck this is all temporary, and a runtimes build will allow us to just take the cmake c compiler.

message(FATAL_ERROR "Clang is not enabled, but is required to build libclc in-tree")
endif()

Expand Down
9 changes: 8 additions & 1 deletion llvm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,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_SUPPORTED_RUNTIMES "libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;openmp;llvm-libgcc;offload;flang-rt")
set(LLVM_SUPPORTED_RUNTIMES "libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;openmp;llvm-libgcc;offload;flang-rt;libclc")
set(LLVM_ENABLE_RUNTIMES "" CACHE STRING
"Semicolon-separated list of runtimes to build, or \"all\" (${LLVM_DEFAULT_RUNTIMES}). Supported runtimes are ${LLVM_SUPPORTED_RUNTIMES}.")
if(LLVM_ENABLE_RUNTIMES STREQUAL "all")
Expand Down Expand Up @@ -204,6 +204,13 @@ if ("flang-rt" IN_LIST LLVM_ENABLE_RUNTIMES)
endif ()
endif ()

if ("libclc" IN_LIST LLVM_ENABLE_PROJECTS)
message(WARNING "Using LLVM_ENABLE_PROJECTS=libclc is deprecated now, and will "
"become a fatal error in the LLVM 21 release. Please use "
"-DLLVM_ENABLE_RUNTIMES=libclc or see the instructions at "
"https://libclc.llvm.org/ for building the runtimes.")
endif()

# Set a shorthand option to enable the GPU build of the 'libc' project.
option(LIBC_GPU_BUILD "Enable the 'libc' project targeting the GPU" OFF)
if(LIBC_GPU_BUILD)
Expand Down
2 changes: 1 addition & 1 deletion llvm/runtimes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ endif()

function(_get_runtime_name name out_var)
string(FIND ${name} "lib" idx)
if(idx EQUAL 0 AND NOT ${name} STREQUAL "libc")
if(idx EQUAL 0 AND NOT (${name} STREQUAL "libc" OR ${name} STREQUAL "libclc"))
string(SUBSTRING ${name} 3 -1 name)
endif()
set(${out_var} ${name} PARENT_SCOPE)
Expand Down
2 changes: 1 addition & 1 deletion runtimes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ list(INSERT CMAKE_MODULE_PATH 0

# We order libraries to mirror roughly how they are layered, except that compiler-rt can depend
# on libc++, so we put it after.
set(LLVM_DEFAULT_RUNTIMES "libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;openmp;offload")
set(LLVM_DEFAULT_RUNTIMES "libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;libclc;openmp;offload")
set(LLVM_SUPPORTED_RUNTIMES "${LLVM_DEFAULT_RUNTIMES};llvm-libgcc;flang-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}.")
Expand Down
Loading