[Lldb-commits] [lldb] 428c876 - [libc++] Stop copying headers to the build directory (#115380)

via lldb-commits lldb-commits at lists.llvm.org
Tue Jan 14 05:40:08 PST 2025


Author: Alexander Richardson
Date: 2025-01-14T08:40:04-05:00
New Revision: 428c8767ae997b0f726c0b40160ea8172551babf

URL: https://github.com/llvm/llvm-project/commit/428c8767ae997b0f726c0b40160ea8172551babf
DIFF: https://github.com/llvm/llvm-project/commit/428c8767ae997b0f726c0b40160ea8172551babf.diff

LOG: [libc++] Stop copying headers to the build directory (#115380)

This was needed before https://github.com/llvm/llvm-project/pull/115077
since the compiler-rt test build made assumptions about the build
layout of libc++ and libc++abi, but now they link against a local
installation of these libraries so we no longer need this workaround.

Added: 
    

Modified: 
    libcxx/CMakeLists.txt
    libcxxabi/CMakeLists.txt
    libcxxabi/include/CMakeLists.txt
    lldb/test/CMakeLists.txt
    lldb/utils/lldb-dotest/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index abe12c2805a7cf..5fab3a99e9e862 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -414,15 +414,16 @@ set(LIBCXX_INSTALL_MODULES_DIR "share/libc++/v1" CACHE STRING
 set(LIBCXX_SHARED_OUTPUT_NAME "c++" CACHE STRING "Output name for the shared libc++ runtime library.")
 set(LIBCXX_STATIC_OUTPUT_NAME "c++" CACHE STRING "Output name for the static libc++ runtime library.")
 
+set(LIBCXX_GENERATED_INCLUDE_DIR "${LIBCXX_BINARY_DIR}/include/c++/v1")
+set(LIBCXX_GENERATED_MODULE_DIR "${LIBCXX_BINARY_DIR}/modules/c++/v1")
+
 if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
   set(LIBCXX_TARGET_SUBDIR ${LLVM_DEFAULT_TARGET_TRIPLE})
   if(LIBCXX_LIBDIR_SUBDIR)
     string(APPEND LIBCXX_TARGET_SUBDIR /${LIBCXX_LIBDIR_SUBDIR})
   endif()
   set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LIBCXX_TARGET_SUBDIR})
-  set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1")
-  set(LIBCXX_GENERATED_MODULE_DIR "${LLVM_BINARY_DIR}/modules/c++/v1")
-  set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LLVM_BINARY_DIR}/include/${LIBCXX_TARGET_SUBDIR}/c++/v1")
+  set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LIBCXX_BINARY_DIR}/include/${LIBCXX_TARGET_SUBDIR}/c++/v1")
   set(LIBCXX_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LIBCXX_TARGET_SUBDIR} CACHE STRING
       "Path where built libc++ libraries should be installed.")
   set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${CMAKE_INSTALL_INCLUDEDIR}/${LIBCXX_TARGET_SUBDIR}/c++/v1" CACHE STRING
@@ -431,12 +432,8 @@ if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
 else()
   if(LLVM_LIBRARY_OUTPUT_INTDIR)
     set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
-    set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1")
-    set(LIBCXX_GENERATED_MODULE_DIR "${LLVM_BINARY_DIR}/modules/c++/v1")
   else()
     set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX})
-    set(LIBCXX_GENERATED_INCLUDE_DIR "${CMAKE_BINARY_DIR}/include/c++/v1")
-    set(LIBCXX_GENERATED_MODULE_DIR "${CMAKE_BINARY_DIR}/modules/c++/v1")
   endif()
   set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LIBCXX_GENERATED_INCLUDE_DIR}")
   set(LIBCXX_INSTALL_LIBRARY_DIR lib${LIBCXX_LIBDIR_SUFFIX} CACHE STRING

diff  --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt
index 6dcfc51e553213..4da42faad67413 100644
--- a/libcxxabi/CMakeLists.txt
+++ b/libcxxabi/CMakeLists.txt
@@ -91,12 +91,6 @@ set(LIBCXXABI_STATIC_OUTPUT_NAME "c++abi" CACHE STRING "Output name for the stat
 
 set(LIBCXXABI_INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}/c++/v1" CACHE STRING "Path to install the libc++abi headers at.")
 
-if(LLVM_LIBRARY_OUTPUT_INTDIR)
-  set(LIBCXXABI_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1")
-else()
-  set(LIBCXXABI_GENERATED_INCLUDE_DIR "${CMAKE_BINARY_DIR}/include/c++/v1")
-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 \

diff  --git a/libcxxabi/include/CMakeLists.txt b/libcxxabi/include/CMakeLists.txt
index 5b1cc2545016ec..0deb7b1eb9e715 100644
--- a/libcxxabi/include/CMakeLists.txt
+++ b/libcxxabi/include/CMakeLists.txt
@@ -3,20 +3,7 @@ set(files
   cxxabi.h
   )
 
-foreach(f ${files})
-  set(src "${CMAKE_CURRENT_SOURCE_DIR}/${f}")
-  set(dst "${LIBCXXABI_GENERATED_INCLUDE_DIR}/${f}")
-  add_custom_command(OUTPUT ${dst}
-    DEPENDS ${src}
-    COMMAND ${CMAKE_COMMAND} -E copy_if_
diff erent ${src} ${dst}
-    COMMENT "Copying CXXABI header ${f}")
-  list(APPEND _all_includes "${dst}")
-endforeach()
-
-add_custom_target(generate-cxxabi-headers ALL DEPENDS ${_all_includes})
-
 add_library(cxxabi-headers INTERFACE)
-add_dependencies(cxxabi-headers generate-cxxabi-headers)
 target_include_directories(cxxabi-headers INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}")
 
 if (LIBCXXABI_INSTALL_HEADERS)

diff  --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt
index 6449ac5a9247f6..d51b18d71f3980 100644
--- a/lldb/test/CMakeLists.txt
+++ b/lldb/test/CMakeLists.txt
@@ -157,15 +157,22 @@ if(TARGET clang)
   # TestFullLtoStepping depends on LTO, and only runs when the compiler is clang.
   add_lldb_test_dependency(LTO)
 
-  if (TARGET libcxx OR ("libcxx" IN_LIST LLVM_ENABLE_RUNTIMES))
+  if ("libcxx" IN_LIST LLVM_ENABLE_RUNTIMES)
     set(LLDB_HAS_LIBCXX ON)
+    # libc++ can only be used for tests after installing to a fake prefix
+    # which is done by the install-cxx-test-suite-prefix target in libc++. We
+    # ensure this is run by depending on the runtimes-test-depends target.
+    # While this could build too many dependencies, it is currently the only
+    # test dependencies target exposed by the runtimes build.
+    add_lldb_test_dependency(runtimes-test-depends)
+    set(LIBCXX_TEST_INSTALL_DIR "${CMAKE_BINARY_DIR}/runtimes/runtimes-${LLVM_DEFAULT_TARGET_TRIPLE}-bins/libcxx/test-suite-install")
     if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
-      set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE})
-      set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1")
-      set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LLVM_BINARY_DIR}/include/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1")
+      set(LIBCXX_LIBRARY_DIR ${LIBCXX_TEST_INSTALL_DIR}/lib/${LLVM_DEFAULT_TARGET_TRIPLE})
+      set(LIBCXX_GENERATED_INCLUDE_DIR "${LIBCXX_TEST_INSTALL_DIR}/include/c++/v1")
+      set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LIBCXX_TEST_INSTALL_DIR}/include/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1")
     else()
-      set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX})
-      set(LIBCXX_GENERATED_INCLUDE_DIR "${CMAKE_BINARY_DIR}/include/c++/v1")
+      set(LIBCXX_LIBRARY_DIR ${LIBCXX_TEST_INSTALL_DIR}/lib${LIBCXX_LIBDIR_SUFFIX})
+      set(LIBCXX_GENERATED_INCLUDE_DIR "${LIBCXX_TEST_INSTALL_DIR}/include/c++/v1")
     endif()
   endif()
 

diff  --git a/lldb/utils/lldb-dotest/CMakeLists.txt b/lldb/utils/lldb-dotest/CMakeLists.txt
index 3b8c88b6dc78cb..414caf43df0e6c 100644
--- a/lldb/utils/lldb-dotest/CMakeLists.txt
+++ b/lldb/utils/lldb-dotest/CMakeLists.txt
@@ -14,13 +14,19 @@ llvm_canonicalize_cmake_booleans(
 
 if ("libcxx" IN_LIST LLVM_ENABLE_RUNTIMES)
   set(LLDB_HAS_LIBCXX ON)
+  # libc++ can only be used for tests after installing to a fake prefix
+  # which is done by the install-cxx-test-suite-prefix target in libc++. We
+  # ensure this is run by depending on the runtimes-test-depends target.
+  # While this could build too many dependencies, it is currently the only
+  # test dependencies target exposed by the runtimes build.
+  set(LIBCXX_TEST_INSTALL_DIR "${CMAKE_BINARY_DIR}/runtimes/runtimes-${LLVM_DEFAULT_TARGET_TRIPLE}-bins/libcxx/test-suite-install")
   if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
-    set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE})
-    set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1")
-    set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LLVM_BINARY_DIR}/include/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1")
+    set(LIBCXX_LIBRARY_DIR ${LIBCXX_TEST_INSTALL_DIR}/lib/${LLVM_DEFAULT_TARGET_TRIPLE})
+    set(LIBCXX_GENERATED_INCLUDE_DIR "${LIBCXX_TEST_INSTALL_DIR}/include/c++/v1")
+    set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LIBCXX_TEST_INSTALL_DIR}/include/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1")
   else()
-    set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX})
-    set(LIBCXX_GENERATED_INCLUDE_DIR "${CMAKE_BINARY_DIR}/include/c++/v1")
+    set(LIBCXX_LIBRARY_DIR ${LIBCXX_TEST_INSTALL_DIR}/lib${LIBCXX_LIBDIR_SUFFIX})
+    set(LIBCXX_GENERATED_INCLUDE_DIR "${LIBCXX_TEST_INSTALL_DIR}/include/c++/v1")
   endif()
 endif()
 


        


More information about the lldb-commits mailing list