Skip to content

[libc] Fail fast when building standalone #119426

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 12, 2024

Conversation

carlocab
Copy link
Member

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.

@@ -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. "
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems nicer to me to error out, but I'm open to changing this to a warning instead.

@llvmbot
Copy link
Member

llvmbot commented Dec 10, 2024

@llvm/pr-subscribers-libc

Author: Carlo Cabrera (carlocab)

Changes

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 --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)

@carlocab carlocab force-pushed the libc-standalone-error branch from 750beba to 0a88f17 Compare December 10, 2024 18:30
Building with the source directory rooted in the libc subdirectory isn't
tested in CI and can lead to subtle build problems (cf. llvm#118871).

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

Co-authored-by: Nick Desaulniers <[email protected]>
@nickdesaulniers
Copy link
Member

cc @RossComputerGuy

Copy link
Contributor

@michaelrj-google michaelrj-google left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@carlocab carlocab merged commit e84566f into llvm:main Dec 12, 2024
10 of 11 checks passed
@carlocab carlocab deleted the libc-standalone-error branch December 12, 2024 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants