[libcxxabi] Fewer assumptions about path from libcxx to libcxxabi
This is useful for projects that pull in libcxx and libcxxabi and build
them using out-of-tree build files, but don't make them sibling
directories (or don't call the sibling directories libcxx and libcxxabi
for some reason).
Fixes PR49313.
Differential Revision: https://reviews.llvm.org/D97379
GitOrigin-RevId: 72b18a86e11ebc970be96a8c2b11aa3a31c14c5d
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index ff1e457..50afdf6 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -57,6 +57,9 @@
include_directories("${LIBCXXABI_LIBCXX_INCLUDES}")
+# stdlib_stdexcept.cpp depends on libc++ internals.
+include_directories("${LIBCXXABI_LIBCXX_PATH}")
+
if (LIBCXXABI_HAS_CXA_THREAD_ATEXIT_IMPL)
add_definitions(-DHAVE___CXA_THREAD_ATEXIT_IMPL)
endif()
diff --git a/src/stdlib_stdexcept.cpp b/src/stdlib_stdexcept.cpp
index 4a464e4..0f5efe4 100644
--- a/src/stdlib_stdexcept.cpp
+++ b/src/stdlib_stdexcept.cpp
@@ -6,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-#include "../../libcxx/src/include/refstring.h"
#include "stdexcept"
#include "new"
#include <cstdlib>
@@ -14,6 +13,9 @@
#include <cstdint>
#include <cstddef>
+// This includes an implementation file from libc++.
+#include "src/include/refstring.h"
+
static_assert(sizeof(std::__libcpp_refstring) == sizeof(const char *), "");
namespace std // purposefully not using versioning namespace