[libcxxabi] Build all of libcxxabi with _LIBCPP_BUILDING_LIBRARY defined
Various definitions from libcxx need to be set in the same way
as if building libcxx itself.
Differential Revision: https://reviews.llvm.org/D90476
GitOrigin-RevId: 9c30bafd59bf1078bbe1c235c7c25bf7e278e2e9
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d9ed55a..b8cdb18 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -282,6 +282,10 @@
# library.
add_definitions(-D_LIBCXXABI_BUILDING_LIBRARY)
+# libcxxabi needs to, for various reasons, include the libcpp headers as if
+# it is being built as part of libcxx.
+add_definitions(-D_LIBCPP_BUILDING_LIBRARY)
+
# Disable DLL annotations on Windows for static builds.
if (WIN32 AND LIBCXXABI_ENABLE_STATIC AND NOT LIBCXXABI_ENABLE_SHARED)
add_definitions(-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS)
diff --git a/src/fallback_malloc.cpp b/src/fallback_malloc.cpp
index 8c0fd6c..75c01ef 100644
--- a/src/fallback_malloc.cpp
+++ b/src/fallback_malloc.cpp
@@ -6,9 +6,6 @@
//
//===----------------------------------------------------------------------===//
-// Define _LIBCPP_BUILDING_LIBRARY to ensure _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
-// is only defined when libc aligned allocation is not available.
-#define _LIBCPP_BUILDING_LIBRARY
#include "fallback_malloc.h"
#include <__threading_support>
diff --git a/src/stdlib_exception.cpp b/src/stdlib_exception.cpp
index 88d911d..b0cc431 100644
--- a/src/stdlib_exception.cpp
+++ b/src/stdlib_exception.cpp
@@ -6,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-#define _LIBCPP_BUILDING_LIBRARY
#include <new>
#include <exception>
diff --git a/src/stdlib_new_delete.cpp b/src/stdlib_new_delete.cpp
index 698c5f7..58f181e 100644
--- a/src/stdlib_new_delete.cpp
+++ b/src/stdlib_new_delete.cpp
@@ -8,7 +8,6 @@
// This file implements the new and delete operators.
//===----------------------------------------------------------------------===//
-#define _LIBCPP_BUILDING_LIBRARY
#include "__cxxabi_config.h"
#include <new>
#include <cstdlib>