[libc-commits] [libc] [libc] Fail fast when building standalone (PR #119426)

Carlo Cabrera via libc-commits libc-commits at lists.llvm.org
Tue Dec 10 10:30:30 PST 2024


https://github.com/carlocab updated https://github.com/llvm/llvm-project/pull/119426

>From 24c3680dc63323dbe64dcfba57e605c1887f16b2 Mon Sep 17 00:00:00 2001
From: Carlo Cabrera <github at carlo.cab>
Date: Wed, 11 Dec 2024 02:07:10 +0800
Subject: [PATCH] [libc] Fail fast when building standalone

Building with the source directory rooted in the libc subdirectory isn't
tested in CI and can lead to subtle build problems (cf. #118871).

Let's fail fast with a helpful error message instead to help users
configure libc correctly.

Co-authored-by: Nick Desaulniers <nickdesaulniers at users.noreply.github.com>
---
 libc/CMakeLists.txt | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt
index 6d48489284faef..88cc75e83b043d 100644
--- a/libc/CMakeLists.txt
+++ b/libc/CMakeLists.txt
@@ -1,6 +1,12 @@
 cmake_minimum_required(VERSION 3.20.0)
 set(LLVM_SUBPROJECT_TITLE "libc")
 
+if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
+  message(FATAL_ERROR "Builds rooted in the libc directory are not supported. "
+    "Builds should be rooted in the runtimes directory instead. "
+    "Please see the documentation at https://libc.llvm.org/usage_modes.html for more info.")
+endif()
+
 # Include LLVM's cmake policies.
 if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS)
   set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)



More information about the libc-commits mailing list