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

via libc-commits libc-commits at lists.llvm.org
Tue Dec 10 10:17:04 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Carlo Cabrera (carlocab)

<details>
<summary>Changes</summary>

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.


---
Full diff: https://github.com/llvm/llvm-project/pull/119426.diff


1 Files Affected:

- (modified) libc/CMakeLists.txt (+6) 


``````````diff
diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt
index 6d48489284faef..3ad549a66f14e6 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. "
+    "Please see the documentation at https://libc.llvm.org/usage_modes.html for links to build "
+    "instructions depending how you plan to use libc.")
+endif()
+
 # Include LLVM's cmake policies.
 if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS)
   set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)

``````````

</details>


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


More information about the libc-commits mailing list