[libcxx-commits] [libcxx] 69c2087 - [libc++] Fix compiler-rt build by copying libc++ headers to <build>/include
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Oct 21 13:58:46 PDT 2020
Author: Louis Dionne
Date: 2020-10-21T16:56:33-04:00
New Revision: 69c2087283cf7b17ca75f69daebf4ffc158b754a
URL: https://github.com/llvm/llvm-project/commit/69c2087283cf7b17ca75f69daebf4ffc158b754a
DIFF: https://github.com/llvm/llvm-project/commit/69c2087283cf7b17ca75f69daebf4ffc158b754a.diff
LOG: [libc++] Fix compiler-rt build by copying libc++ headers to <build>/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 `<build-root>/include/c++/v1`. This was changed
by 5d796645, which moved the headers to `<build-root>/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.
Added:
Modified:
libcxx/CMakeLists.txt
libcxx/cmake/Modules/HandleLibCXXABI.cmake
libcxx/include/CMakeLists.txt
libcxxabi/test/libcxxabi/test/config.py
Removed:
################################################################################
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index bdfecf6c0c60..eb19646646f0 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 c5aa26739e36..6f50853189a2 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_
diff erent ${src} ${dst}
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 82af0e77e1ef..a63b565e4400 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 4d44d88ccc36..e7c019688f1a 100644
--- a/libcxxabi/test/libcxxabi/test/config.py
+++ b/libcxxabi/test/libcxxabi/test/config.py
@@ -58,7 +58,7 @@ def configure_compile_flags(self):
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:
More information about the libcxx-commits
mailing list