diff options
author | Eric Fiselier <eric@efcs.ca> | 2017-03-02 19:35:33 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2017-03-02 19:35:33 +0000 |
commit | 3499263c360e7643b3776d71a29e18d96f5a951a (patch) | |
tree | 56c1d5c8d672dec1279c97f78ecbf9d02224675a | |
parent | 2ee1d90cb903aa1e1c3b3c559284e93188f178a8 (diff) | |
download | bcm5719-llvm-3499263c360e7643b3776d71a29e18d96f5a951a.tar.gz bcm5719-llvm-3499263c360e7643b3776d71a29e18d96f5a951a.zip |
[libc++] Add option to disable new/delete overloads when libc++abi provides them.
Summary:
Currently both libc++ and libc++abi provide definitions for operator new/delete. However I believe this is incorrect and that one or the other should offer them.
This patch adds the CMake option `-DLIBCXX_ENABLE_NEW_DELETE_DEFINITIONS` which defaults no `ON` unless `-DLIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS=ON` is specified.
Reviewers: mclow.lists, mehdi_amini, dexonsmith, danalbert, smeenai, mgorny, rmaprath
Reviewed By: mehdi_amini
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D30516
llvm-svn: 296802
-rw-r--r-- | libcxx/CMakeLists.txt | 14 | ||||
-rw-r--r-- | libcxx/src/new.cpp | 5 |
2 files changed, 17 insertions, 2 deletions
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt index 2928fc4f23d..03e0f68db9c 100644 --- a/libcxx/CMakeLists.txt +++ b/libcxx/CMakeLists.txt @@ -157,6 +157,16 @@ option(LIBCXX_ENABLE_ABI_LINKER_SCRIPT "Use and install a linker script for the given ABI library" ${ENABLE_LINKER_SCRIPT_DEFAULT_VALUE}) +set(ENABLE_NEW_DELETE_DEFAULT ON) +if (LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS) + set(ENABLE_NEW_DELETE_DEFAULT OFF) +endif() + +option(LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS + "Build libc++ with definitions for operator new/delete. This option can + be used to disable the definitions when libc++abi is expected to provide + them" ${ENABLE_NEW_DELETE_DEFAULT}) + # Build libc++abi with libunwind. We need this option to determine whether to # link with libunwind or libgcc_s while running the test cases. option(LIBCXXABI_USE_LLVM_UNWINDER "Build and use the LLVM unwinder." OFF) @@ -433,6 +443,10 @@ add_compile_flags_if_supported(-fvisibility-inlines-hidden) # library. add_definitions(-D_LIBCPP_BUILDING_LIBRARY) +if (NOT LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS) + add_definitions(-D_LIBCPP_DISABLE_NEW_DELETE_DEFINITIONS) +endif() + # Warning flags =============================================================== add_definitions(-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) add_compile_flags_if_supported( diff --git a/libcxx/src/new.cpp b/libcxx/src/new.cpp index 5a4686d259a..21b30740196 100644 --- a/libcxx/src/new.cpp +++ b/libcxx/src/new.cpp @@ -53,7 +53,8 @@ __throw_bad_alloc() } // std -#if !defined(__GLIBCXX__) && !defined(_LIBCPP_ABI_MICROSOFT) +#if !defined(__GLIBCXX__) && !defined(_LIBCPP_ABI_MICROSOFT) && \ + !defined(_LIBCPP_DISABLE_NEW_DELETE_DEFINITIONS) // Implement all new and delete operators as weak definitions // in this shared library, so that they can be overridden by programs @@ -298,4 +299,4 @@ operator delete[] (void* ptr, size_t, std::align_val_t alignment) _NOEXCEPT } #endif // !_LIBCPP_HAS_NO_ALIGNED_ALLOCATION -#endif // !__GLIBCXX__ && !_LIBCPP_ABI_MICROSOFT +#endif // !__GLIBCXX__ && !_LIBCPP_ABI_MICROSOFT && !_LIBCPP_DISABLE_NEW_DELETE_DEFINITIONS |