[libcxxabi] r296801 - [libc++abi] Add option to enable definitions for the new/delete overloads.

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 2 11:34:35 PST 2017


Author: ericwf
Date: Thu Mar  2 13:34:35 2017
New Revision: 296801

URL: http://llvm.org/viewvc/llvm-project?rev=296801&view=rev
Log:
[libc++abi] Add option to enable definitions for the new/delete overloads.

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 `-DLIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS` which defaults to `OFF` unless otherwise specified. This means that by default
only libc++ provides the new/delete definitions.



Reviewers: mclow.lists, mehdi_amini, dexonsmith, beanz, jroelofs, danalbert, smeenai, rmaprath, mgorny

Reviewed By: mehdi_amini

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D30517

Modified:
    libcxxabi/trunk/CMakeLists.txt
    libcxxabi/trunk/src/CMakeLists.txt

Modified: libcxxabi/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=296801&r1=296800&r2=296801&view=diff
==============================================================================
--- libcxxabi/trunk/CMakeLists.txt (original)
+++ libcxxabi/trunk/CMakeLists.txt Thu Mar  2 13:34:35 2017
@@ -141,6 +141,9 @@ option(LIBCXXABI_HAS_EXTERNAL_THREAD_API
 option(LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY
   "Build libc++abi with an externalized threading library.
    This option may only be set to ON when LIBCXXABI_ENABLE_THREADS=ON" OFF)
+option(LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS
+    "Build libc++abi with definitions for operator new/delete. Normally libc++
+    provides these definitions" OFF)
 option(LIBCXXABI_BUILD_32_BITS "Build 32 bit libc++abi." ${LLVM_BUILD_32_BITS})
 option(LIBCXXABI_INCLUDE_TESTS "Generate build targets for the libc++abi unit tests." ${LLVM_INCLUDE_TESTS})
 set(LIBCXXABI_TARGET_TRIPLE "" CACHE STRING "Target triple for cross compiling.")
@@ -409,7 +412,10 @@ if (LIBCXXABI_HAS_EXTERNAL_THREAD_API)
   endif()
 endif()
 
-if (LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY AND LIBCXXABI_ENABLE_SHARED)
+set(LIBCXXABI_HAS_UNDEFINED_SYMBOLS ((NOT LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS)
+    OR (LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY AND LIBCXXABI_ENABLE_SHARED)))
+
+if (LIBCXXABI_HAS_UNDEFINED_SYMBOLS)
   # Need to allow unresolved symbols if this is to work with shared library builds
   if (APPLE)
     add_link_flags("-undefined dynamic_lookup")

Modified: libcxxabi/trunk/src/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/CMakeLists.txt?rev=296801&r1=296800&r2=296801&view=diff
==============================================================================
--- libcxxabi/trunk/src/CMakeLists.txt (original)
+++ libcxxabi/trunk/src/CMakeLists.txt Thu Mar  2 13:34:35 2017
@@ -20,10 +20,9 @@ set(LIBCXXABI_SOURCES
   private_typeinfo.cpp
 )
 
-# FIXME: This file should only be compiled in special configurations such
-#  as building the Apple system dylib where libc++abi is expected to provide
-#  the new/delete definitions instead of libc++.
-list(APPEND LIBCXXABI_SOURCES stdlib_new_delete.cpp)
+if (LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS)
+  list(APPEND LIBCXXABI_SOURCES stdlib_new_delete.cpp)
+endif()
 
 if (LIBCXXABI_ENABLE_EXCEPTIONS)
   list(APPEND LIBCXXABI_SOURCES cxa_exception.cpp)




More information about the cfe-commits mailing list