Skip to content

Commit

Permalink
[libc++] Stop copying headers to the build directory (llvm#115380)
Browse files Browse the repository at this point in the history
This was needed before llvm#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.
  • Loading branch information
arichardson authored Jan 14, 2025
1 parent 1393f4e commit 428c876
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 37 deletions.
11 changes: 4 additions & 7 deletions libcxx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 0 additions & 6 deletions libcxxabi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
13 changes: 0 additions & 13 deletions libcxxabi/include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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_different ${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)
Expand Down
19 changes: 13 additions & 6 deletions lldb/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
16 changes: 11 additions & 5 deletions lldb/utils/lldb-dotest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit 428c876

Please sign in to comment.