[libcxx-commits] [libcxx] [libc++] Improve diagnostic for libcxxabi missing from the runtimes (PR #208274)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jul 8 10:46:00 PDT 2026


https://github.com/ldionne created https://github.com/llvm/llvm-project/pull/208274

When libc++ is configured to use libc++abi as an ABI library but libcxxabi is not part of the runtimes, we'd end up with a confusing build error about a missing <cxxabi.h> header. Instead, diagnose at CMake configuration time.

Closes #136480

>From 46f65633ffa15d30079697228e06b4156174faa6 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Wed, 8 Jul 2026 13:44:02 -0400
Subject: [PATCH] [libc++] Improve diagnostic for libcxxabi missing from the
 runtimes

When libc++ is configured to use libc++abi as an ABI library but libcxxabi
is not part of the runtimes, we'd end up with a confusing build error about
a missing <cxxabi.h> header. Instead, diagnose at CMake configuration time.

Closes #136480
---
 libcxx/cmake/Modules/HandleLibCXXABI.cmake | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libcxx/cmake/Modules/HandleLibCXXABI.cmake b/libcxx/cmake/Modules/HandleLibCXXABI.cmake
index 52236f473f35d..4b4ff7c7f9d5f 100644
--- a/libcxx/cmake/Modules/HandleLibCXXABI.cmake
+++ b/libcxx/cmake/Modules/HandleLibCXXABI.cmake
@@ -148,6 +148,12 @@ elseif ("${LIBCXX_CXX_ABI}" STREQUAL "libcxxabi")
     add_library(libcxx-abi-static-objects ALIAS cxxabi_static_objects)
   endif()
 
+  if (NOT TARGET cxxabi_static AND NOT TARGET cxxabi_shared
+      AND NOT TARGET cxxabi_static_objects AND NOT TARGET cxxabi_shared_objects)
+    message(FATAL_ERROR "Can't find any libc++abi target but LIBCXX_CXX_ABI is set to libcxxabi, "
+                        "did you forget to include libcxxabi in LLVM_ENABLE_RUNTIMES?")
+  endif()
+
 # Link against a system-provided libc++abi
 elseif ("${LIBCXX_CXX_ABI}" STREQUAL "system-libcxxabi")
   if(NOT LIBCXX_CXX_ABI_INCLUDE_PATHS)



More information about the libcxx-commits mailing list