[libcxx-commits] [libcxxabi] 1687f2b - [libcxxabi] Use cxx-headers target to consume libcxx headers
Petr Hosek via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Mar 26 13:28:00 PDT 2021
Author: Petr Hosek
Date: 2021-03-26T13:27:51-07:00
New Revision: 1687f2bbe2e2aaa092f942d4a97d41fad43eedfb
URL: https://github.com/llvm/llvm-project/commit/1687f2bbe2e2aaa092f942d4a97d41fad43eedfb
DIFF: https://github.com/llvm/llvm-project/commit/1687f2bbe2e2aaa092f942d4a97d41fad43eedfb.diff
LOG: [libcxxabi] Use cxx-headers target to consume libcxx headers
Rather than including libc++ include dir, use the cxx-headers target.
Differential Revision: https://reviews.llvm.org/D98367
Added:
Modified:
libcxxabi/CMakeLists.txt
libcxxabi/src/CMakeLists.txt
libcxxabi/test/libcxxabi/test/config.py
libcxxabi/test/lit.site.cfg.in
Removed:
################################################################################
diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt
index 8b0c88689df3..2ffd8b611930 100644
--- a/libcxxabi/CMakeLists.txt
+++ b/libcxxabi/CMakeLists.txt
@@ -156,9 +156,23 @@ if (NOT LIBCXXABI_ENABLE_SHARED AND NOT LIBCXXABI_ENABLE_STATIC)
message(FATAL_ERROR "libc++abi must be built as either a shared or static library.")
endif()
-set(LIBCXXABI_LIBCXX_INCLUDES "${LIBCXXABI_LIBCXX_PATH}/include" CACHE PATH
+# TODO: This is a workaround for the fact that Standalone builds can't use
+# targets from the other runtimes (so the cxx-headers target doesn't exist).
+set(LIBCXXABI_LIBCXX_INCLUDES "" CACHE PATH
"Specify path to libc++ includes.")
-message(STATUS "Libc++abi will be using libc++ includes from ${LIBCXXABI_LIBCXX_INCLUDES}")
+if (LIBCXXABI_STANDALONE_BUILD)
+ if (NOT IS_DIRECTORY ${LIBCXXABI_LIBCXX_INCLUDES})
+ message(FATAL_ERROR
+ "LIBCXXABI_LIBCXX_INCLUDES=${LIBCXXABI_LIBCXX_INCLUDES} is not a valid directory. "
+ "Please provide the path to where the libc++ headers have been installed.")
+ endif()
+ add_library(cxx-headers INTERFACE)
+ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" OR "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC")
+ target_compile_options(cxx-headers INTERFACE /I "${LIBCXXABI_LIBCXX_INCLUDES}")
+ else()
+ target_compile_options(cxx-headers INTERFACE -I "${LIBCXXABI_LIBCXX_INCLUDES}")
+ endif()
+endif()
option(LIBCXXABI_HERMETIC_STATIC_LIBRARY
"Do not export any symbols from the static library." OFF)
@@ -180,6 +194,7 @@ set(CMAKE_MODULE_PATH
)
if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
+ set(LIBCXXABI_HEADER_DIR ${LLVM_BINARY_DIR})
set(LIBCXXABI_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++)
set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++)
if(LIBCXX_LIBDIR_SUBDIR)
@@ -187,9 +202,11 @@ if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
string(APPEND LIBCXXABI_INSTALL_LIBRARY_DIR /${LIBCXXABI_LIBDIR_SUBDIR})
endif()
elseif(LLVM_LIBRARY_OUTPUT_INTDIR)
+ set(LIBCXXABI_HEADER_DIR ${LLVM_BINARY_DIR})
set(LIBCXXABI_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LIBCXXABI_LIBDIR_SUFFIX})
else()
+ set(LIBCXXABI_HEADER_DIR ${CMAKE_BINARY_DIR})
set(LIBCXXABI_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXXABI_LIBDIR_SUFFIX})
set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LIBCXXABI_LIBDIR_SUFFIX})
endif()
diff --git a/libcxxabi/src/CMakeLists.txt b/libcxxabi/src/CMakeLists.txt
index a28da22fdec4..32a998e02f48 100644
--- a/libcxxabi/src/CMakeLists.txt
+++ b/libcxxabi/src/CMakeLists.txt
@@ -56,8 +56,6 @@ if (MSVC_IDE OR XCODE)
endif()
endif()
-include_directories("${LIBCXXABI_LIBCXX_INCLUDES}")
-
# stdlib_stdexcept.cpp depends on libc++ internals.
include_directories("${LIBCXXABI_LIBCXX_PATH}")
@@ -178,7 +176,7 @@ endif()
# Build the shared library.
if (LIBCXXABI_ENABLE_SHARED)
add_library(cxxabi_shared SHARED ${LIBCXXABI_SOURCES} ${LIBCXXABI_HEADERS})
- target_link_libraries(cxxabi_shared PRIVATE ${LIBCXXABI_SHARED_LIBRARIES} ${LIBCXXABI_LIBRARIES})
+ target_link_libraries(cxxabi_shared PRIVATE cxx-headers ${LIBCXXABI_SHARED_LIBRARIES} ${LIBCXXABI_LIBRARIES})
if (TARGET pstl::ParallelSTL)
target_link_libraries(cxxabi_shared PUBLIC pstl::ParallelSTL)
endif()
@@ -245,7 +243,7 @@ endif()
# Build the static library.
if (LIBCXXABI_ENABLE_STATIC)
add_library(cxxabi_static STATIC ${LIBCXXABI_SOURCES} ${LIBCXXABI_HEADERS})
- target_link_libraries(cxxabi_static PRIVATE ${LIBCXXABI_STATIC_LIBRARIES} ${LIBCXXABI_LIBRARIES})
+ target_link_libraries(cxxabi_static PRIVATE cxx-headers ${LIBCXXABI_STATIC_LIBRARIES} ${LIBCXXABI_LIBRARIES})
if (TARGET pstl::ParallelSTL)
target_link_libraries(cxxabi_static PUBLIC pstl::ParallelSTL)
endif()
diff --git a/libcxxabi/test/libcxxabi/test/config.py b/libcxxabi/test/libcxxabi/test/config.py
index 280a60a864bc..5357bb18b931 100644
--- a/libcxxabi/test/libcxxabi/test/config.py
+++ b/libcxxabi/test/libcxxabi/test/config.py
@@ -16,12 +16,16 @@ class Configuration(LibcxxConfiguration):
# pylint: disable=redefined-outer-name
def __init__(self, lit_config, config):
super(Configuration, self).__init__(lit_config, config)
+ self.libcxxabi_hdr_root = None
self.libcxxabi_src_root = None
self.libcxxabi_obj_root = None
self.abi_library_root = None
self.libcxx_src_root = None
def configure_src_root(self):
+ self.libcxxabi_hdr_root = self.get_lit_conf(
+ 'libcxxabi_hdr_root',
+ self.project_obj_root)
self.libcxxabi_src_root = self.get_lit_conf(
'libcxxabi_src_root',
os.path.dirname(self.config.test_source_root))
@@ -57,9 +61,8 @@ def configure_compile_flags(self):
def configure_compile_flags_header_includes(self):
self.configure_config_site_header()
- cxx_headers = self.get_lit_conf(
- 'cxx_headers',
- os.path.join(self.libcxx_src_root, '/include'))
+ cxx_headers = self.get_lit_conf('cxx_headers', None) or \
+ os.path.join(self.libcxxabi_hdr_root, 'include', 'c++', 'v1')
if cxx_headers == '':
self.lit_config.note('using the systems c++ headers')
else:
diff --git a/libcxxabi/test/lit.site.cfg.in b/libcxxabi/test/lit.site.cfg.in
index 1b7713e3ef73..76072187101c 100644
--- a/libcxxabi/test/lit.site.cfg.in
+++ b/libcxxabi/test/lit.site.cfg.in
@@ -5,6 +5,7 @@ import site
config.cxx_under_test = "@CMAKE_CXX_COMPILER@"
config.project_obj_root = "@CMAKE_BINARY_DIR@"
+config.libcxxabi_hdr_root = "@LIBCXXABI_HEADER_DIR@"
config.libcxxabi_src_root = "@LIBCXXABI_SOURCE_DIR@"
config.libcxxabi_obj_root = "@LIBCXXABI_BINARY_DIR@"
config.abi_library_root = "@LIBCXXABI_LIBRARY_DIR@"
More information about the libcxx-commits
mailing list