Skip to content

[build] Check RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES for libc also #82561

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 1 commit into from
Feb 22, 2024
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
17 changes: 15 additions & 2 deletions libc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,21 @@ if(LLVM_LIBC_FULL_BUILD OR LIBC_GPU_BUILD OR LIBC_GPU_ARCHITECTURES)
endif()
endif()

set(NEED_LIBC_HDRGEN FALSE)
if(NOT LLVM_RUNTIMES_BUILD)
if("libc" IN_LIST LLVM_ENABLE_RUNTIMES)
set(NEED_LIBC_HDRGEN TRUE)
else()
foreach(_name ${LLVM_RUNTIME_TARGETS})
if("libc" IN_LIST RUNTIMES_${_name}_LLVM_ENABLE_RUNTIMES)
set(NEED_LIBC_HDRGEN TRUE)
break()
endif()
endforeach()
endif()
endif()
option(LIBC_HDRGEN_ONLY "Only build the 'libc-hdrgen' executable" OFF)
if(("libc" IN_LIST LLVM_ENABLE_RUNTIMES AND NOT LLVM_RUNTIMES_BUILD) OR
LIBC_HDRGEN_ONLY)
if(LIBC_HDRGEN_ONLY OR NEED_LIBC_HDRGEN)
# When libc is build as part of the runtimes/bootstrap build's CMake run, we
# only need to build the host tools to build the libc. So, we just do enough
# to build libc-hdrgen and return.
Expand All @@ -70,6 +82,7 @@ if(("libc" IN_LIST LLVM_ENABLE_RUNTIMES AND NOT LLVM_RUNTIMES_BUILD) OR
endif()
return()
endif()
unset(NEED_LIBC_HDRGEN)

option(LIBC_CMAKE_VERBOSE_LOGGING
"Log details warnings and notifications during CMake configuration." OFF)
Expand Down
14 changes: 13 additions & 1 deletion llvm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,18 @@ foreach(proj IN LISTS LLVM_ENABLE_RUNTIMES)
endif()
endforeach()

if ("libc" IN_LIST LLVM_ENABLE_RUNTIMES)
set(NEED_LIBC_HDRGEN FALSE)
if("libc" IN_LIST LLVM_ENABLE_RUNTIMES)
set(NEED_LIBC_HDRGEN TRUE)
else()
foreach(_name ${LLVM_RUNTIME_TARGETS})
if("libc" IN_LIST RUNTIMES_${_name}_LLVM_ENABLE_RUNTIMES)
set(NEED_LIBC_HDRGEN TRUE)
break()
endif()
endforeach()
endif()
if(NEED_LIBC_HDRGEN)
# To build the libc runtime, we need to be able to build few libc build
# tools from the "libc" project. So, we add it to the list of enabled
# projects.
Expand All @@ -177,6 +188,7 @@ if ("libc" IN_LIST LLVM_ENABLE_RUNTIMES)
list(APPEND LLVM_ENABLE_PROJECTS "libc")
endif()
endif()
unset(NEED_LIBC_HDRGEN)

# LLVM_ENABLE_PROJECTS_USED is `ON` if the user has ever used the
# `LLVM_ENABLE_PROJECTS` CMake cache variable. This exists for
Expand Down