From: Louis Dionne Date: Wed, 21 Oct 2020 20:52:21 +0000 (-0400) Subject: [libc++] Fix compiler-rt build by copying libc++ headers to /include X-Git-Tag: llvmorg-13-init~8564 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=69c2087283cf7b17ca75f69daebf4ffc158b754a;p=platform%2Fupstream%2Fllvm.git [libc++] Fix compiler-rt build by copying libc++ headers to /include This commit should really be named "Workaround external projects depending on libc++ build system implementation details". It seems that the compiler-rt build (and perhaps other projects) is relying on the fact that we copy libc++ and libc++abi headers to `/include/c++/v1`. This was changed by 5d796645, which moved the headers to `/projects/libcxx/include/c++/v1` and broke the compiler-rt build. I'm committing this workaround to fix the compiler-rt build, but we should remove reliance on implementation details like that. The correct way to setup the compiler-rt build would be to "link" against the `cxx-headers` target in CMake, or to run `install-cxx-headers` using an appropriate installation prefix, and then manually add a `-I` path to that location. --- diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt index bdfecf6..eb19646 100644 --- a/libcxx/CMakeLists.txt +++ b/libcxx/CMakeLists.txt @@ -31,7 +31,6 @@ set(CMAKE_MODULE_PATH set(LIBCXX_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(LIBCXX_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) set(LIBCXX_BINARY_INCLUDE_DIR "${LIBCXX_BINARY_DIR}/include/c++build") -set(LIBCXX_GENERATED_INCLUDE_DIR "${LIBCXX_BINARY_DIR}/include/c++/v1") if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR LIBCXX_STANDALONE_BUILD) project(libcxx CXX C) @@ -398,9 +397,11 @@ endif () # Configure System #=============================================================================== +# TODO: Other projects rely on the location where we generate the libc++ headers +# internally. We should get rid of these dependencies. if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++) - set(LIBCXX_HEADER_DIR ${LLVM_BINARY_DIR}) + set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1") set(LIBCXX_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++) if(LIBCXX_LIBDIR_SUBDIR) string(APPEND LIBCXX_LIBRARY_DIR /${LIBCXX_LIBDIR_SUBDIR}) @@ -408,11 +409,11 @@ if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) endif() elseif(LLVM_LIBRARY_OUTPUT_INTDIR) set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) - set(LIBCXX_HEADER_DIR ${LLVM_BINARY_DIR}) + set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1") set(LIBCXX_INSTALL_LIBRARY_DIR lib${LIBCXX_LIBDIR_SUFFIX}) else() set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX}) - set(LIBCXX_HEADER_DIR ${CMAKE_BINARY_DIR}) + set(LIBCXX_GENERATED_INCLUDE_DIR "${CMAKE_BINARY_DIR}/include/c++/v1") set(LIBCXX_INSTALL_LIBRARY_DIR lib${LIBCXX_LIBDIR_SUFFIX}) endif() diff --git a/libcxx/cmake/Modules/HandleLibCXXABI.cmake b/libcxx/cmake/Modules/HandleLibCXXABI.cmake index c5aa267..6f50853 100644 --- a/libcxx/cmake/Modules/HandleLibCXXABI.cmake +++ b/libcxx/cmake/Modules/HandleLibCXXABI.cmake @@ -52,8 +52,10 @@ macro(setup_abi_lib abidefines abishared abistatic abifiles abidirs) COMMENT "Copying C++ ABI header ${fpath}...") list(APPEND abilib_headers "${dst}") - if (LIBCXX_HEADER_DIR) - set(dst "${LIBCXX_HEADER_DIR}/include/c++/v1/${dstdir}/${fpath}") + if (LIBCXX_GENERATED_INCLUDE_DIR) # always true + # TODO: libc++ shouldn't be responsible for copying the libc++abi + # headers into the right location. + set(dst "${LIBCXX_GENERATED_INCLUDE_DIR}/include/c++/v1/${dstdir}/${fpath}") add_custom_command(OUTPUT ${dst} DEPENDS ${src} COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst} diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt index 82af0e77..a63b565 100644 --- a/libcxx/include/CMakeLists.txt +++ b/libcxx/include/CMakeLists.txt @@ -185,7 +185,7 @@ if(LIBCXX_INSTALL_SUPPORT_HEADERS) ) endif() -if(LIBCXX_HEADER_DIR) +if (LIBCXX_GENERATED_INCLUDE_DIR) # Always true configure_file("__config_site.in" "${LIBCXX_GENERATED_INCLUDE_DIR}/__config_site" @ONLY) set(_all_includes "${LIBCXX_GENERATED_INCLUDE_DIR}/__config_site") diff --git a/libcxxabi/test/libcxxabi/test/config.py b/libcxxabi/test/libcxxabi/test/config.py index 4d44d88..e7c0196 100644 --- a/libcxxabi/test/libcxxabi/test/config.py +++ b/libcxxabi/test/libcxxabi/test/config.py @@ -58,7 +58,7 @@ class Configuration(LibcxxConfiguration): def configure_compile_flags_header_includes(self): cxx_headers = self.get_lit_conf( 'cxx_headers', - os.path.join(self.libcxx_obj_root, 'include', 'c++', 'v1')) + os.path.join(self.project_obj_root, 'include', 'c++', 'v1')) if cxx_headers == '': self.lit_config.note('using the systems c++ headers') else: