diff --git a/libcxx/cmake/Modules/HandleLibCXXABI.cmake b/libcxx/cmake/Modules/HandleLibCXXABI.cmake --- a/libcxx/cmake/Modules/HandleLibCXXABI.cmake +++ b/libcxx/cmake/Modules/HandleLibCXXABI.cmake @@ -10,17 +10,9 @@ # abidefines: A list of defines needed to compile libc++ with the ABI library # abishared : The shared ABI library to link against. # abistatic : The static ABI library to link against. -# abifiles : A list of files (which may be relative paths) to copy into the -# libc++ build tree for the build. These files will be copied -# twice: once into include/, so the libc++ build itself can find -# them, and once into include/c++/v1, so that a clang built into -# the same build area will find them. These files will also be -# installed alongside the libc++ headers. -# abidirs : A list of relative paths to create under an include directory -# in the libc++ build directory. # -macro(setup_abi_lib abidefines abishared abistatic abifiles abidirs) +macro(setup_abi_lib abidefines abishared abistatic) list(APPEND LIBCXX_COMPILE_FLAGS ${abidefines}) set(LIBCXX_CXX_ABI_INCLUDE_PATHS "${LIBCXX_CXX_ABI_INCLUDE_PATHS}" CACHE PATH @@ -32,54 +24,6 @@ ) set(LIBCXX_CXX_SHARED_ABI_LIBRARY ${abishared}) set(LIBCXX_CXX_STATIC_ABI_LIBRARY ${abistatic}) - set(LIBCXX_ABILIB_FILES ${abifiles}) - - foreach(fpath ${LIBCXX_ABILIB_FILES}) - set(found FALSE) - foreach(incpath ${LIBCXX_CXX_ABI_INCLUDE_PATHS}) - message(STATUS "Looking for ${fpath} in ${incpath}") - if (EXISTS "${incpath}/${fpath}") - set(found TRUE) - message(STATUS "Looking for ${fpath} in ${incpath} - found") - get_filename_component(dstdir ${fpath} PATH) - get_filename_component(ifile ${fpath} NAME) - set(src ${incpath}/${fpath}) - - set(dst ${LIBCXX_BINARY_INCLUDE_DIR}/${dstdir}/${ifile}) - add_custom_command(OUTPUT ${dst} - DEPENDS ${src} - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst} - COMMENT "Copying C++ ABI header ${fpath}...") - list(APPEND abilib_headers "${dst}") - - # TODO: libc++ shouldn't be responsible for copying the libc++abi - # headers into the right location. - set(dst "${LIBCXX_GENERATED_INCLUDE_DIR}/${dstdir}/${fpath}") - add_custom_command(OUTPUT ${dst} - DEPENDS ${src} - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst} - COMMENT "Copying C++ ABI header ${fpath}...") - list(APPEND abilib_headers "${dst}") - - if (LIBCXX_INSTALL_HEADERS) - install(FILES "${LIBCXX_BINARY_INCLUDE_DIR}/${fpath}" - DESTINATION include/c++/v1/${dstdir} - COMPONENT cxx-headers - PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ - ) - endif() - else() - message(STATUS "Looking for ${fpath} in ${incpath} - not found") - endif() - endforeach() - if (NOT found) - message(WARNING "Failed to find ${fpath} in ${LIBCXX_CXX_ABI_INCLUDE_PATHS}") - endif() - endforeach() - - include_directories("${LIBCXX_BINARY_INCLUDE_DIR}") - add_custom_target(cxx_abi_headers ALL DEPENDS ${abilib_headers}) - set(LIBCXX_CXX_ABI_HEADER_TARGET "cxx_abi_headers") endmacro() @@ -99,7 +43,7 @@ endif() setup_abi_lib( "-D__GLIBCXX__ ${_LIBSUPCXX_DEFINES}" - "${_LIBSUPCXX_LIBNAME}" "${_LIBSUPCXX_LIBNAME}" "${_LIBSUPCXX_INCLUDE_FILES}" "bits" + "${_LIBSUPCXX_LIBNAME}" "${_LIBSUPCXX_LIBNAME}" ) elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxabi") if(NOT LIBCXX_CXX_ABI_INCLUDE_PATHS) @@ -116,7 +60,7 @@ setup_abi_lib( "-DLIBCXX_BUILDING_LIBCXXABI" - "${shared}" "${static}" "cxxabi.h;__cxxabi_config.h" "") + "${shared}" "${static}") elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxrt") if(NOT LIBCXX_CXX_ABI_INCLUDE_PATHS) set(LIBCXX_CXX_ABI_INCLUDE_PATHS "/usr/include/c++/v1") @@ -125,7 +69,7 @@ set(LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS ON) setup_abi_lib( "-DLIBCXXRT" - "cxxrt" "cxxrt" "cxxabi.h;unwind.h;unwind-arm.h;unwind-itanium.h" "" + "cxxrt" "cxxrt" ) elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "vcruntime") # Nothing to do diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt --- a/libcxx/include/CMakeLists.txt +++ b/libcxx/include/CMakeLists.txt @@ -450,7 +450,7 @@ add_custom_target(generate-cxx-headers ALL DEPENDS ${_all_includes}) add_library(cxx-headers INTERFACE) -add_dependencies(cxx-headers generate-cxx-headers ${LIBCXX_CXX_ABI_HEADER_TARGET}) +add_dependencies(cxx-headers generate-cxx-headers) # TODO: Use target_include_directories once we figure out why that breaks the runtimes build if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" OR "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC") target_compile_options(cxx-headers INTERFACE /I${LIBCXX_GENERATED_INCLUDE_DIR} diff --git a/libcxx/src/CMakeLists.txt b/libcxx/src/CMakeLists.txt --- a/libcxx/src/CMakeLists.txt +++ b/libcxx/src/CMakeLists.txt @@ -180,10 +180,6 @@ endif() function(cxx_set_common_defines name) - if(LIBCXX_CXX_ABI_HEADER_TARGET) - add_dependencies(${name} ${LIBCXX_CXX_ABI_HEADER_TARGET}) - endif() - if (LIBCXX_ENABLE_PARALLEL_ALGORITHMS) target_link_libraries(${name} PUBLIC pstl::ParallelSTL) endif() diff --git a/libcxx/utils/ci/apple-install-libcxx.sh b/libcxx/utils/ci/apple-install-libcxx.sh --- a/libcxx/utils/ci/apple-install-libcxx.sh +++ b/libcxx/utils/ci/apple-install-libcxx.sh @@ -156,7 +156,6 @@ any_arch=$(echo ${architectures} | cut -d ' ' -f 1) mkdir -p "${install_dir}/usr/include" ditto "${build_dir}/${any_arch}-install/include" "${install_dir}/usr/include" -ditto "${llvm_root}/libcxxabi/include" "${install_dir}/usr/include" # TODO: libcxxabi should install its headers in CMake if [[ $EUID -eq 0 ]]; then # Only chown if we're running as root chown -R root:wheel "${install_dir}/usr/include" fi diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt --- a/libcxxabi/CMakeLists.txt +++ b/libcxxabi/CMakeLists.txt @@ -110,7 +110,9 @@ option(LIBCXXABI_INCLUDE_TESTS "Generate build targets for the libc++abi unit tests." ${LLVM_INCLUDE_TESTS}) set(LIBCXXABI_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING "Define suffix of library directory name (32/64)") +option(LIBCXXABI_INSTALL_HEADERS "Install the libc++abi headers." ON) option(LIBCXXABI_INSTALL_LIBRARY "Install the libc++abi library." ON) +set(LIBCXXABI_INSTALL_INCLUDE_DIR "include/c++/v1" CACHE PATH "Path to install the libc++abi headers at.") set(LIBCXXABI_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}" CACHE STRING "Target triple for cross compiling.") set(LIBCXXABI_GCC_TOOLCHAIN "" CACHE PATH "GCC toolchain for cross compiling.") set(LIBCXXABI_SYSROOT "" CACHE PATH "Sysroot for cross compiling.") @@ -521,7 +523,6 @@ set(LIBCXXABI_LIBUNWIND_PATH "${LIBCXXABI_LIBUNWIND_PATH}" CACHE PATH "Specify path to libunwind source." FORCE) -include_directories(include) if (LIBCXXABI_USE_LLVM_UNWINDER OR LLVM_NATIVE_ARCH MATCHES ARM) find_path(LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL libunwind.h PATHS ${LIBCXXABI_LIBUNWIND_INCLUDES} @@ -545,6 +546,7 @@ # Add source code. This also contains all of the logic for deciding linker flags # soname, etc... +add_subdirectory(include) add_subdirectory(src) if (LIBCXXABI_INCLUDE_TESTS) diff --git a/libcxxabi/include/CMakeLists.txt b/libcxxabi/include/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/libcxxabi/include/CMakeLists.txt @@ -0,0 +1,26 @@ +set(files + __cxxabi_config.h + cxxabi.h + ) + +add_library(cxxabi-headers INTERFACE) +target_include_directories(cxxabi-headers INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}") + +if (LIBCXXABI_INSTALL_HEADERS) + foreach(file ${files}) + get_filename_component(dir ${file} DIRECTORY) + install(FILES ${file} + DESTINATION ${LIBCXXABI_INSTALL_INCLUDE_DIR}/${dir} + COMPONENT cxxabi-headers + PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ + ) + endforeach() + + add_custom_target(install-cxxabi-headers + DEPENDS cxxabi-headers + COMMAND "${CMAKE_COMMAND}" + -DCMAKE_INSTALL_COMPONENT=cxxabi-headers + -P "${CMAKE_BINARY_DIR}/cmake_install.cmake") + # Stripping is a no-op for headers + add_custom_target(install-cxxabi-headers-stripped DEPENDS install-cxxabi-headers) +endif() diff --git a/libcxxabi/src/CMakeLists.txt b/libcxxabi/src/CMakeLists.txt --- a/libcxxabi/src/CMakeLists.txt +++ b/libcxxabi/src/CMakeLists.txt @@ -177,6 +177,7 @@ if (LIBCXXABI_ENABLE_SHARED) add_library(cxxabi_shared SHARED ${LIBCXXABI_SOURCES} ${LIBCXXABI_HEADERS}) target_link_libraries(cxxabi_shared PRIVATE cxx-headers ${LIBCXXABI_SHARED_LIBRARIES} ${LIBCXXABI_LIBRARIES}) + target_link_libraries(cxxabi_shared PUBLIC cxxabi-headers) if (TARGET pstl::ParallelSTL) target_link_libraries(cxxabi_shared PUBLIC pstl::ParallelSTL) endif() @@ -233,6 +234,7 @@ if (LIBCXXABI_ENABLE_STATIC) add_library(cxxabi_static STATIC ${LIBCXXABI_SOURCES} ${LIBCXXABI_HEADERS}) target_link_libraries(cxxabi_static PRIVATE cxx-headers ${LIBCXXABI_STATIC_LIBRARIES} ${LIBCXXABI_LIBRARIES}) + target_link_libraries(cxxabi_static PUBLIC cxxabi-headers) if (TARGET pstl::ParallelSTL) target_link_libraries(cxxabi_static PUBLIC pstl::ParallelSTL) endif() @@ -300,7 +302,7 @@ if (NOT CMAKE_CONFIGURATION_TYPES AND LIBCXXABI_INSTALL_LIBRARY) add_custom_target(install-cxxabi - DEPENDS cxxabi + DEPENDS cxxabi install-cxxabi-headers COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=cxxabi -P "${LIBCXXABI_BINARY_DIR}/cmake_install.cmake")