[libc-commits] [libc] [llvm] [build] Check RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES for libc also (PR #82561)
Petr Hosek via libc-commits
libc-commits at lists.llvm.org
Wed Feb 21 16:56:23 PST 2024
https://github.com/petrhosek created https://github.com/llvm/llvm-project/pull/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.
>From 7b9814cfc2bce47637e2aa238c1352dd34e7ebff Mon Sep 17 00:00:00 2001
From: Petr Hosek <phosek at google.com>
Date: Thu, 22 Feb 2024 00:51:26 +0000
Subject: [PATCH] [build] Check RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES for
libc also
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.
---
libc/CMakeLists.txt | 17 +++++++++++++++--
llvm/CMakeLists.txt | 14 +++++++++++++-
2 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt
index 3d775736616745..73877fd3d7fd02 100644
--- a/libc/CMakeLists.txt
+++ b/libc/CMakeLists.txt
@@ -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.
@@ -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)
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index a760a19efcb6b1..fe0091be9d9494 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -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.
@@ -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
More information about the libc-commits
mailing list