[llvm] [llvm][cmake] Do not emit error on `libc`'s use of project + runtime build (PR #110038)

Joseph Huber via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 25 13:21:15 PDT 2024


https://github.com/jhuber6 created https://github.com/llvm/llvm-project/pull/110038

Summary:
The `libc` project automatically adds `libc` to the projects list if
it's in the runtimes list. This then causes it to enter the projects
directory to bootstrap a handful of utilities, This useage conflicts
with a new error message with effectively stopped us from doing this.

This patch weakens the error message to permit this single case.


>From ba1defbf0bf942369a1a356a24e6690c35740ef5 Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Wed, 25 Sep 2024 15:19:26 -0500
Subject: [PATCH] [llvm][cmake] Do not emit error on `libc`'s use of project +
 runtime build

Summary:
The `libc` project automatically adds `libc` to the projects list if
it's in the runtimes list. This then causes it to enter the projects
directory to bootstrap a handful of utilities, This useage conflicts
with a new error message with effectively stopped us from doing this.

This patch weakens the error message to permit this single case.
---
 llvm/CMakeLists.txt | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 330db65e85cabb..0044c38f566a78 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -161,12 +161,6 @@ foreach(proj IN LISTS LLVM_ENABLE_RUNTIMES)
   endif()
 endforeach()
 
-foreach(proj IN LISTS LLVM_ENABLE_RUNTIMES)
-  if ("${proj}" IN_LIST LLVM_ENABLE_PROJECTS)
-    message(FATAL_ERROR "Runtime project \"${proj}\" found in LLVM_ENABLE_PROJECTS and LLVM_ENABLE_RUNTIMES. It must only appear in one of them and that one should almost always be LLVM_ENABLE_RUNTIMES.")
-  endif()
-endforeach()
-
 # 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)
@@ -204,6 +198,16 @@ if(NEED_LIBC_HDRGEN)
     list(APPEND LLVM_ENABLE_PROJECTS "libc")
   endif()
 endif()
+
+foreach(proj IN LISTS LLVM_ENABLE_RUNTIMES)
+  if("${proj}" IN_LIST LLVM_ENABLE_PROJECTS)
+    # The 'libc' project bootstraps a few executables via the project build and
+    # should not emit an error currently.
+    if(NOT (NEED_LIBC_HDRGEN AND "${proj}" STREQUAL "libc"))
+      message(FATAL_ERROR "Runtime project \"${proj}\" found in LLVM_ENABLE_PROJECTS and LLVM_ENABLE_RUNTIMES. It must only appear in one of them and that one should almost always be LLVM_ENABLE_RUNTIMES.")
+    endif()
+  endif()
+endforeach()
 unset(NEED_LIBC_HDRGEN)
 
 # LLVM_ENABLE_PROJECTS_USED is `ON` if the user has ever used the



More information about the llvm-commits mailing list