[libc++abi] Fix the standalone build after the __config_site change
In 5d796645, we stopped looking at the LIBCXXABI_LIBCXX_INCLUDES variable,
which broke users of the Standalone build. This patch reinstates that
variable, however it must point to the *installed* path of the libc++
headers, not the libc++ headers in the source tree (which has always
been the case, but wasn't enforced before).
If LIBCXXABI_LIBCXX_INCLUDES points to the libc++ headers in the source
tree, the `__config_site` header will fail to be found.
GitOrigin-RevId: 529ac33197f6408952ae995075ac5e2dc5287e81
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f0593bc..a5d3a06 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -138,6 +138,24 @@
message(FATAL_ERROR "libc++abi must be built as either a shared or static library.")
endif()
+# TODO: This is a hack 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 the installed libc++ includes. This is only relevant for Standalone builds, where the location of the headers can't be determined automatically.")
+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)
diff --git a/test/libcxxabi/test/config.py b/test/libcxxabi/test/config.py
index e7c0196..f9e17e9 100644
--- a/test/libcxxabi/test/config.py
+++ b/test/libcxxabi/test/config.py
@@ -56,9 +56,8 @@
super(Configuration, self).configure_compile_flags()
def configure_compile_flags_header_includes(self):
- cxx_headers = self.get_lit_conf(
- 'cxx_headers',
- os.path.join(self.project_obj_root, 'include', 'c++', 'v1'))
+ cxx_headers = self.get_lit_conf('cxx_headers', None) or \
+ os.path.join(self.project_obj_root, 'include', 'c++', 'v1')
if cxx_headers == '':
self.lit_config.note('using the systems c++ headers')
else:
diff --git a/test/lit.site.cfg.in b/test/lit.site.cfg.in
index a6d43c6..87f955e 100644
--- a/test/lit.site.cfg.in
+++ b/test/lit.site.cfg.in
@@ -9,6 +9,7 @@
config.libcxxabi_obj_root = "@LIBCXXABI_BINARY_DIR@"
config.abi_library_path = "@LIBCXXABI_LIBRARY_DIR@"
config.libcxx_src_root = "@LIBCXXABI_LIBCXX_PATH@"
+config.cxx_headers = "@LIBCXXABI_LIBCXX_INCLUDES@"
config.libunwind_headers = "@LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL@"
config.cxx_library_root = "@LIBCXXABI_LIBCXX_LIBRARY_PATH@"
config.llvm_unwinder = @LIBCXXABI_USE_LLVM_UNWINDER@