[libcxx-commits] [PATCH] D132526: [libcxxabi] Unbreak `LLVM_ENABLE_RUNTIMES=libcxxabi` build v2

John Ericson via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Aug 23 20:37:59 PDT 2022


Ericson2314 created this revision.
Ericson2314 added reviewers: ldionne, phosek.
Herald added a subscriber: mgorny.
Herald added a project: All.
Ericson2314 requested review of this revision.
Herald added a project: libc++abi.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++abi.

New version of D132298 <https://reviews.llvm.org/D132298>.

There is no more fragile `IN_LIST`. CMake code dealing with libc++ is
pulled out into a (libcxxabi-only) `HandleLibCXX` module.

I tested this with my distro packaging, replacing D132298 <https://reviews.llvm.org/D132298>. It moves more
code around, but does less because with `-DLIBCXXABI_INCLUDE_TESTS=OFF`
I don't need to worry about `LIBCXXABI_TEST_DEPS` containing the other
libraries.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D132526

Files:
  libcxxabi/CMakeLists.txt
  libcxxabi/cmake/Modules/HandleLibCXX.cmake


Index: libcxxabi/cmake/Modules/HandleLibCXX.cmake
===================================================================
--- /dev/null
+++ libcxxabi/cmake/Modules/HandleLibCXX.cmake
@@ -0,0 +1,27 @@
+set(LIBCXXABI_LIBCXX_PATH "${LIBCXXABI_SOURCE_DIR}/../libcxx" CACHE PATH
+    "Specify path to libc++ source.")
+
+# TODO: Move this under the conditional. All usages should use `cxx-headers`
+# instead of this, so this is us used to make the "fake" cxx-headers below and
+# nothing else.
+set(LIBCXXABI_LIBCXX_INCLUDES "" CACHE PATH
+    "Specify path to libc++ includes.")
+if (NOT TARGET cxx-headers)
+  if (NOT IS_DIRECTORY ${LIBCXXABI_LIBCXX_INCLUDES})
+    message(FATAL_ERROR
+      "LIBCXXABI_LIBCXX_INCLUDES=${LIBCXXABI_LIBCXX_INCLUDES} is not a valid directory. "
+      "Since we are not also building libc++, "
+      "please provide the path to where the libc++ headers have been installed.")
+
+  endif()
+  add_library(cxx-headers INTERFACE)
+  target_include_directories(cxx-headers INTERFACE "${LIBCXXABI_LIBCXX_INCLUDES}")
+endif()
+
+if (LIBCXXABI_INCLUDE_TESTS)
+  # The libraries are just needed for the "lit tests"
+
+  # By default, libcxx and libcxxabi share a library directory.
+  set(LIBCXXABI_LIBCXX_LIBRARY_PATH "${LIBCXXABI_LIBRARY_DIR}" CACHE PATH
+      "The path to libc++ library.")
+endif()
Index: libcxxabi/CMakeLists.txt
===================================================================
--- libcxxabi/CMakeLists.txt
+++ libcxxabi/CMakeLists.txt
@@ -20,8 +20,6 @@
 
 set(LIBCXXABI_SOURCE_DIR  ${CMAKE_CURRENT_SOURCE_DIR})
 set(LIBCXXABI_BINARY_DIR  ${CMAKE_CURRENT_BINARY_DIR})
-set(LIBCXXABI_LIBCXX_PATH "${CMAKE_CURRENT_LIST_DIR}/../libcxx" CACHE PATH
-        "Specify path to libc++ source.")
 
 include(GNUInstallDirs)
 
@@ -37,6 +35,7 @@
 #===============================================================================
 include(CMakeDependentOption)
 include(HandleCompilerRT)
+include(HandleLibCXX)
 
 # Define options.
 option(LIBCXXABI_ENABLE_EXCEPTIONS
@@ -92,7 +91,6 @@
   message(WARNING "LIBCXXABI_SYSROOT, LIBCXXABI_TARGET_TRIPLE and LIBCXXABI_GCC_TOOLCHAIN are not supported anymore, please use the native CMake equivalents instead")
 endif()
 
-set(LIBCXXABI_LIBCXX_LIBRARY_PATH "" CACHE PATH "The path to libc++ library.")
 set(LIBCXXABI_LIBRARY_VERSION "1.0" CACHE STRING
 "Version of libc++abi. This will be reflected in the name of the shared \
 library produced. For example, -DLIBCXXABI_LIBRARY_VERSION=x.y will \
@@ -131,11 +129,6 @@
   message(FATAL_ERROR "libc++abi must be built as either a shared or static library.")
 endif()
 
-# TODO: Remove this, which shouldn't be necessary since we know we're being built
-#       side-by-side with libc++.
-set(LIBCXXABI_LIBCXX_INCLUDES "" CACHE PATH
-    "Specify path to libc++ includes.")
-
 set(LIBCXXABI_HERMETIC_STATIC_LIBRARY_DEFAULT OFF)
 if (WIN32)
   set(LIBCXXABI_HERMETIC_STATIC_LIBRARY_DEFAULT ON)
@@ -209,12 +202,6 @@
 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBCXXABI_LIBRARY_DIR})
 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LIBCXXABI_LIBRARY_DIR})
 
-# By default, libcxx and libcxxabi share a library directory.
-if (NOT LIBCXXABI_LIBCXX_LIBRARY_PATH)
-  set(LIBCXXABI_LIBCXX_LIBRARY_PATH "${LIBCXXABI_LIBRARY_DIR}" CACHE PATH
-      "The path to libc++ library." FORCE)
-endif()
-
 # Declare libc++abi configuration variables.
 # They are intended for use as follows:
 # LIBCXXABI_C_FLAGS: General flags for both the c++ compiler and linker.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132526.455063.patch
Type: text/x-patch
Size: 3456 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220824/2d9084e2/attachment.bin>


More information about the libcxx-commits mailing list