Skip to content

Commit 9dbedca

Browse files
authored
[build] Check RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES for libc also (#82561)
When checking whether we need to build libc-hdrgen, we need to check LLVM_ENABLE_RUNTIMES and RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES, just the former is not sufficient since libc may be enabled only for certain targets.
1 parent d3f6dd6 commit 9dbedca

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

libc/CMakeLists.txt

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,21 @@ if(LLVM_LIBC_FULL_BUILD OR LIBC_GPU_BUILD OR LIBC_GPU_ARCHITECTURES)
5757
endif()
5858
endif()
5959

60+
set(NEED_LIBC_HDRGEN FALSE)
61+
if(NOT LLVM_RUNTIMES_BUILD)
62+
if("libc" IN_LIST LLVM_ENABLE_RUNTIMES)
63+
set(NEED_LIBC_HDRGEN TRUE)
64+
else()
65+
foreach(_name ${LLVM_RUNTIME_TARGETS})
66+
if("libc" IN_LIST RUNTIMES_${_name}_LLVM_ENABLE_RUNTIMES)
67+
set(NEED_LIBC_HDRGEN TRUE)
68+
break()
69+
endif()
70+
endforeach()
71+
endif()
72+
endif()
6073
option(LIBC_HDRGEN_ONLY "Only build the 'libc-hdrgen' executable" OFF)
61-
if(("libc" IN_LIST LLVM_ENABLE_RUNTIMES AND NOT LLVM_RUNTIMES_BUILD) OR
62-
LIBC_HDRGEN_ONLY)
74+
if(LIBC_HDRGEN_ONLY OR NEED_LIBC_HDRGEN)
6375
# When libc is build as part of the runtimes/bootstrap build's CMake run, we
6476
# only need to build the host tools to build the libc. So, we just do enough
6577
# to build libc-hdrgen and return.
@@ -70,6 +82,7 @@ if(("libc" IN_LIST LLVM_ENABLE_RUNTIMES AND NOT LLVM_RUNTIMES_BUILD) OR
7082
endif()
7183
return()
7284
endif()
85+
unset(NEED_LIBC_HDRGEN)
7386

7487
option(LIBC_CMAKE_VERBOSE_LOGGING
7588
"Log details warnings and notifications during CMake configuration." OFF)

llvm/CMakeLists.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,18 @@ foreach(proj IN LISTS LLVM_ENABLE_RUNTIMES)
168168
endif()
169169
endforeach()
170170

171-
if ("libc" IN_LIST LLVM_ENABLE_RUNTIMES)
171+
set(NEED_LIBC_HDRGEN FALSE)
172+
if("libc" IN_LIST LLVM_ENABLE_RUNTIMES)
173+
set(NEED_LIBC_HDRGEN TRUE)
174+
else()
175+
foreach(_name ${LLVM_RUNTIME_TARGETS})
176+
if("libc" IN_LIST RUNTIMES_${_name}_LLVM_ENABLE_RUNTIMES)
177+
set(NEED_LIBC_HDRGEN TRUE)
178+
break()
179+
endif()
180+
endforeach()
181+
endif()
182+
if(NEED_LIBC_HDRGEN)
172183
# To build the libc runtime, we need to be able to build few libc build
173184
# tools from the "libc" project. So, we add it to the list of enabled
174185
# projects.
@@ -177,6 +188,7 @@ if ("libc" IN_LIST LLVM_ENABLE_RUNTIMES)
177188
list(APPEND LLVM_ENABLE_PROJECTS "libc")
178189
endif()
179190
endif()
191+
unset(NEED_LIBC_HDRGEN)
180192

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

0 commit comments

Comments
 (0)