From 4ecdb70424a7c057bf6858027abc3a0f59454210 Mon Sep 17 00:00:00 2001 From: Petr Hosek Date: Mon, 28 Jan 2019 20:55:12 +0000 Subject: [PATCH] Revert "[libunwind] Drop the dependency on , add placement new inline" This reverts commit r352384: this broke on ARM as UnwindCursor.hpp still has some C++ library dependencies. llvm-svn: 352427 --- libunwind/CMakeLists.txt | 25 ++++++++++++++++++++++--- libunwind/src/Unwind-seh.cpp | 4 ---- libunwind/src/UnwindCursor.hpp | 1 + libunwind/src/libunwind.cpp | 8 ++++---- 4 files changed, 27 insertions(+), 11 deletions(-) diff --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt index 46e7ce146e72..b03adaa5ab0f 100644 --- a/libunwind/CMakeLists.txt +++ b/libunwind/CMakeLists.txt @@ -287,9 +287,6 @@ unwind_append_if(LIBUNWIND_CXX_FLAGS LIBUNWIND_HAS_EHSC_FLAG -EHsc) unwind_append_if(LIBUNWIND_C_FLAGS LIBUNWIND_HAS_FUNWIND_TABLES -funwind-tables) -# Ensure that we don't depend on C++ standard library. -unwind_append_if(LIBUNWIND_CXX_FLAGS LIBUNWIND_HAS_NOSTDINCXX_FLAG -nostdinc++) - # Assert string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE) if (LIBUNWIND_ENABLE_ASSERTIONS) @@ -344,6 +341,28 @@ endif() include_directories(include) +find_path( + LIBUNWIND_LIBCXX_INCLUDES_INTERNAL + __libcpp_version + PATHS ${LLVM_MAIN_SRC_DIR}/projects/libcxx/include + ${LLVM_MAIN_SRC_DIR}/runtimes/libcxx/include + ${LLVM_MAIN_SRC_DIR}/../libcxx/include + NO_DEFAULT_PATH + NO_CMAKE_FIND_ROOT_PATH + ) +if ((NOT LIBUNWIND_STANDALONE_BUILD OR HAVE_LIBCXX) AND + IS_DIRECTORY "${LIBUNWIND_LIBCXX_INCLUDES_INTERNAL}") + set(LIBUNWIND_CXX_INCLUDE_PATHS_DEFAULT "${LIBUNWIND_LIBCXX_INCLUDES_INTERNAL}") +endif() + +set(LIBUNWIND_CXX_INCLUDE_PATHS "${LIBUNWIND_CXX_INCLUDE_PATHS_DEFAULT}" CACHE PATH + "Paths to C++ header directories separated by ';'.") + +if (NOT LIBUNWIND_CXX_INCLUDE_PATHS STREQUAL "") + list(APPEND LIBUNWIND_CXX_FLAGS -nostdinc++) + include_directories("${LIBUNWIND_CXX_INCLUDE_PATHS}") +endif() + add_subdirectory(src) if (LIBUNWIND_INCLUDE_DOCS) diff --git a/libunwind/src/Unwind-seh.cpp b/libunwind/src/Unwind-seh.cpp index 26eb0ef262bb..f55d62423a61 100644 --- a/libunwind/src/Unwind-seh.cpp +++ b/libunwind/src/Unwind-seh.cpp @@ -49,10 +49,6 @@ using namespace libunwind; /// Class of foreign exceptions based on unrecognized SEH exceptions. static const uint64_t kSEHExceptionClass = 0x434C4E4753454800; // CLNGSEH\0 -// libunwind does not and should not depend on C++ library which means that we -// need our own declaration of global placement new. -void *operator new(size_t, void*); - /// Exception cleanup routine used by \c _GCC_specific_handler to /// free foreign exceptions. static void seh_exc_cleanup(_Unwind_Reason_Code urc, _Unwind_Exception *exc) { diff --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp index 62efe771babb..497ff84552de 100644 --- a/libunwind/src/UnwindCursor.hpp +++ b/libunwind/src/UnwindCursor.hpp @@ -11,6 +11,7 @@ #ifndef __UNWINDCURSOR_HPP__ #define __UNWINDCURSOR_HPP__ +#include #include #include #include diff --git a/libunwind/src/libunwind.cpp b/libunwind/src/libunwind.cpp index cfa9112a6336..a2496a06de9a 100644 --- a/libunwind/src/libunwind.cpp +++ b/libunwind/src/libunwind.cpp @@ -11,6 +11,10 @@ #include +#ifndef NDEBUG +#include // getenv +#endif + #include "libunwind_ext.h" #include "config.h" @@ -23,10 +27,6 @@ using namespace libunwind; -// libunwind does not and should not depend on C++ library which means that we -// need our own declaration of global placement new. -void *operator new(size_t, void*); - /// internal object to represent this processes address space LocalAddressSpace LocalAddressSpace::sThisAddressSpace;