[clang] [libcxx] [libcxxabi] [runtimes] Never define operator new in libc++ (PR #218989)
Louis Dionne via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 26 10:47:18 PDT 2026
https://github.com/ldionne updated https://github.com/llvm/llvm-project/pull/218989
>From 9cc57fd87e49fe39e1acaad72afd3f1767e6c4c2 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Wed, 26 Aug 2026 12:58:17 -0400
Subject: [PATCH 1/4] [runtimes] Never define operator new in libc++
Libc++ and libc++abi have allowed picking whether `operator new` is
defined inside libc++ or libc++abi for a long time. By default, the
operators are defined inside libc++abi, and most platforms use that.
The possibility of defining `operator new` in either library causes
significant complexity since we have to maintain an includable source
that must work from both libc++ and libc++abi. While working on #215813
where we must detect whether `operator new` has been overridden from a
function we'd want to define in `libc++.dylib`, it became apparent how
brittle that setup is.
This patch removes the option to define `operator new` in libc++. The
operators are either defined in libc++abi or not at all.
While this may seem like a major breakage, in reality I believe this
does not affect most platforms. Indeed, platforms that use the default
configuration are not affected. Of the platforms that explicitly put the
operators in `libc++.dylib`, it seems that most of them are also merging
libc++abi into libc++, so it does not actually matter where the operators
are coming from.
The one platform where a change would be required is FreeBSD, which uses
libcxxrt and seems to really depend on the operators being defined in
libc++.dylib.
---
clang/cmake/caches/Apple-stage1.cmake | 3 ---
clang/cmake/caches/CrossWinToARMLinux.cmake | 6 ++---
clang/cmake/caches/Fuchsia-stage2.cmake | 4 ----
.../cmake/caches/cross-linux-toolchain.cmake | 1 -
libcxx/CMakeLists.txt | 11 +++++-----
libcxx/cmake/caches/AMDGPU.cmake | 2 --
libcxx/cmake/caches/FreeBSD.cmake | 1 -
libcxx/cmake/caches/NVPTX.cmake | 2 --
libcxx/docs/ReleaseNotes/24.rst | 3 +++
libcxx/docs/VendorDocumentation.rst | 5 +++--
libcxx/lib/abi/CMakeLists.txt | 8 +------
...in.libcxxabi.v1.stable.exceptions.abilist} | 0
...23.libcxxabi.v1.stable.exceptions.abilist} | 0
...ix.libcxxabi.v1.stable.exceptions.abilist} | 0
...ix.libcxxabi.v1.stable.exceptions.abilist} | 0
...in.libcxxabi.v1.stable.exceptions.abilist} | 0
...23.libcxxabi.v1.stable.exceptions.abilist} | 0
...sd.libcxxabi.v1.stable.exceptions.abilist} | 0
...nu.libcxxabi.v1.stable.exceptions.abilist} | 0
....libcxxabi.v1.stable.noexceptions.abilist} | 0
libcxx/src/CMakeLists.txt | 22 -------------------
libcxx/src/new.cpp | 20 -----------------
libcxx/src/support/new.ipp | 2 ++
libcxxabi/CMakeLists.txt | 5 ++---
24 files changed, 19 insertions(+), 76 deletions(-)
rename libcxx/lib/abi/{arm64-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist => arm64-apple-darwin.libcxxabi.v1.stable.exceptions.abilist} (100%)
rename libcxx/lib/abi/{i686-linux-android23.libcxxabi.v1.stable.exceptions.nonew.abilist => i686-linux-android23.libcxxabi.v1.stable.exceptions.abilist} (100%)
rename libcxx/lib/abi/{powerpc-ibm-aix.libcxxabi.v1.stable.exceptions.nonew.abilist => powerpc-ibm-aix.libcxxabi.v1.stable.exceptions.abilist} (100%)
rename libcxx/lib/abi/{powerpc64-ibm-aix.libcxxabi.v1.stable.exceptions.nonew.abilist => powerpc64-ibm-aix.libcxxabi.v1.stable.exceptions.abilist} (100%)
rename libcxx/lib/abi/{x86_64-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist => x86_64-apple-darwin.libcxxabi.v1.stable.exceptions.abilist} (100%)
rename libcxx/lib/abi/{x86_64-linux-android23.libcxxabi.v1.stable.exceptions.nonew.abilist => x86_64-linux-android23.libcxxabi.v1.stable.exceptions.abilist} (100%)
rename libcxx/lib/abi/{x86_64-unknown-freebsd.libcxxabi.v1.stable.exceptions.nonew.abilist => x86_64-unknown-freebsd.libcxxabi.v1.stable.exceptions.abilist} (100%)
rename libcxx/lib/abi/{x86_64-unknown-linux-gnu.libcxxabi.v1.stable.exceptions.nonew.abilist => x86_64-unknown-linux-gnu.libcxxabi.v1.stable.exceptions.abilist} (100%)
rename libcxx/lib/abi/{x86_64-unknown-linux-gnu.libcxxabi.v1.stable.noexceptions.nonew.abilist => x86_64-unknown-linux-gnu.libcxxabi.v1.stable.noexceptions.abilist} (100%)
delete mode 100644 libcxx/src/new.cpp
diff --git a/clang/cmake/caches/Apple-stage1.cmake b/clang/cmake/caches/Apple-stage1.cmake
index 36937f6ed0b4b..ed30fcfc9cd3d 100644
--- a/clang/cmake/caches/Apple-stage1.cmake
+++ b/clang/cmake/caches/Apple-stage1.cmake
@@ -34,9 +34,6 @@ set(COMPILER_RT_ENABLE_TVOS OFF CACHE BOOL "")
set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
-set(LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS OFF CACHE BOOL "")
-set(LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS ON CACHE BOOL "")
-
set(CLANG_BOOTSTRAP_TARGETS
generate-order-file
check-all
diff --git a/clang/cmake/caches/CrossWinToARMLinux.cmake b/clang/cmake/caches/CrossWinToARMLinux.cmake
index c47c4ac3bb73e..1a63ededd867d 100644
--- a/clang/cmake/caches/CrossWinToARMLinux.cmake
+++ b/clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -21,7 +21,7 @@
# cmake -G Ninja ^
# -DTOOLCHAIN_TARGET_TRIPLE=aarch64-unknown-linux-gnu ^
# -DTOOLCHAIN_TARGET_SYSROOTFS=<path-to-develop-arm-linux-root-fs> ^
-# -DTOOLCHAIN_SHARED_LIBS=OFF ^
+# -DTOOLCHAIN_SHARED_LIBS=OFF ^
# -DCMAKE_INSTALL_PREFIX=../install ^
# -DCMAKE_CXX_FLAGS="-D__OPTIMIZE__" ^
# -DREMOTE_TEST_HOST="<hostname>" ^
@@ -205,21 +205,19 @@ set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_COMPILER_RT_CXX_LIBRARY
# The compiler-rt tests disable the clang configuration files during the execution by setting CLANG_NO_DEFAULT_CONFIG=1
# and drops out the --sysroot from there. Provide it explicity via the test flags here if target sysroot has been specified.
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_COMPILER_RT_TEST_COMPILER_CFLAGS "--stdlib=libc++ ${sysroot_flags}" CACHE STRING "")
-
+
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBUNWIND_ENABLE_SHARED ${TOOLCHAIN_SHARED_LIBS} CACHE BOOL "")
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXXABI_ENABLE_STATIC_UNWINDER ${TOOLCHAIN_USE_STATIC_LIBS} CACHE BOOL "")
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
-set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS OFF CACHE BOOL "")
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXXABI_ENABLE_SHARED ${TOOLCHAIN_SHARED_LIBS} CACHE BOOL "")
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_ENABLE_SHARED ${TOOLCHAIN_SHARED_LIBS} CACHE BOOL "")
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_ABI_VERSION ${LIBCXX_ABI_VERSION} CACHE STRING "")
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_CXX_ABI "libcxxabi" CACHE STRING "") #!!!
-set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS ON CACHE BOOL "")
# Merge libc++ and libc++abi libraries into the single libc++ library file.
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_ENABLE_STATIC_ABI_LIBRARY ${TOOLCHAIN_USE_STATIC_LIBS} CACHE BOOL "")
# Forcely disable the libc++ benchmarks on Windows build hosts
diff --git a/clang/cmake/caches/Fuchsia-stage2.cmake b/clang/cmake/caches/Fuchsia-stage2.cmake
index 9d549fe94f43c..f22c657040701 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -282,7 +282,6 @@ if(FUCHSIA_SDK)
set(RUNTIMES_${target}+asan_LLVM_BUILD_COMPILER_RT OFF CACHE BOOL "")
set(RUNTIMES_${target}+asan_LLVM_USE_SANITIZER "Address" CACHE STRING "")
set(RUNTIMES_${target}+asan_LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS OFF CACHE BOOL "")
- set(RUNTIMES_${target}+asan_LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS OFF CACHE BOOL "")
set(RUNTIMES_${target}+noexcept_LLVM_BUILD_COMPILER_RT OFF CACHE BOOL "")
set(RUNTIMES_${target}+noexcept_LIBCXXABI_ENABLE_EXCEPTIONS OFF CACHE BOOL "")
@@ -291,7 +290,6 @@ if(FUCHSIA_SDK)
set(RUNTIMES_${target}+asan+noexcept_LLVM_BUILD_COMPILER_RT OFF CACHE BOOL "")
set(RUNTIMES_${target}+asan+noexcept_LLVM_USE_SANITIZER "Address" CACHE STRING "")
set(RUNTIMES_${target}+asan+noexcept_LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS OFF CACHE BOOL "")
- set(RUNTIMES_${target}+asan+noexcept_LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS OFF CACHE BOOL "")
set(RUNTIMES_${target}+asan+noexcept_LIBCXXABI_ENABLE_EXCEPTIONS OFF CACHE BOOL "")
set(RUNTIMES_${target}+asan+noexcept_LIBCXX_ENABLE_EXCEPTIONS OFF CACHE BOOL "")
@@ -307,13 +305,11 @@ if(FUCHSIA_SDK)
set(RUNTIMES_aarch64-unknown-fuchsia+hwasan_LLVM_BUILD_COMPILER_RT OFF CACHE BOOL "")
set(RUNTIMES_aarch64-unknown-fuchsia+hwasan_LLVM_USE_SANITIZER "HWAddress" CACHE STRING "")
set(RUNTIMES_aarch64-unknown-fuchsia+hwasan_LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS OFF CACHE BOOL "")
- set(RUNTIMES_aarch64-unknown-fuchsia+hwasan_LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS OFF CACHE BOOL "")
# HWASan+noexcept
set(RUNTIMES_aarch64-unknown-fuchsia+hwasan+noexcept_LLVM_BUILD_COMPILER_RT OFF CACHE BOOL "")
set(RUNTIMES_aarch64-unknown-fuchsia+hwasan+noexcept_LLVM_USE_SANITIZER "HWAddress" CACHE STRING "")
set(RUNTIMES_aarch64-unknown-fuchsia+hwasan+noexcept_LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS OFF CACHE BOOL "")
- set(RUNTIMES_aarch64-unknown-fuchsia+hwasan+noexcept_LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS OFF CACHE BOOL "")
set(RUNTIMES_aarch64-unknown-fuchsia+hwasan+noexcept_LIBCXXABI_ENABLE_EXCEPTIONS OFF CACHE BOOL "")
set(RUNTIMES_aarch64-unknown-fuchsia+hwasan+noexcept_LIBCXX_ENABLE_EXCEPTIONS OFF CACHE BOOL "")
diff --git a/clang/cmake/caches/cross-linux-toolchain.cmake b/clang/cmake/caches/cross-linux-toolchain.cmake
index 8065961f7fcfe..fc456831a7892 100644
--- a/clang/cmake/caches/cross-linux-toolchain.cmake
+++ b/clang/cmake/caches/cross-linux-toolchain.cmake
@@ -273,7 +273,6 @@ foreach(target ${LLVM_RUNTIME_TARGETS})
set(RUNTIMES_${target}_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
set(RUNTIMES_${target}_LIBCXX_CXX_ABI "libcxxabi" CACHE STRING "") #!!!
- set(RUNTIMES_${target}_LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS ON CACHE BOOL "")
if (DEFINED TOOLCHAIN_SHARED_LIBS)
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index e28bbfaa0605d..fcd7b1e6095f3 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -296,11 +296,12 @@ option(LIBCXX_ENABLE_ABI_LINKER_SCRIPT
"Use and install a linker script for the given ABI library"
${ENABLE_LINKER_SCRIPT_DEFAULT_VALUE})
-option(LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS
- "Build libc++ with definitions for operator new/delete. These are normally
- defined in libc++abi, but this option can be used to define them in libc++
- instead. If you define them in libc++, make sure they are NOT defined in
- libc++abi. Doing otherwise is an ODR violation." OFF)
+# TODO: Remove in LLVM 25
+if (LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS)
+ message(FATAL_ERROR "LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS is not supported anymore, operator new is now either
+ provided by an ABI library like libc++abi.dylib, or not at all")
+endif()
+
# 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." ON)
diff --git a/libcxx/cmake/caches/AMDGPU.cmake b/libcxx/cmake/caches/AMDGPU.cmake
index ed6e5d78149e7..bf4ba024f7d93 100644
--- a/libcxx/cmake/caches/AMDGPU.cmake
+++ b/libcxx/cmake/caches/AMDGPU.cmake
@@ -4,7 +4,6 @@ set(LIBCXX_ENABLE_EXCEPTIONS OFF CACHE BOOL "")
set(LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "")
set(LIBCXX_ENABLE_LOCALIZATION ON CACHE BOOL "")
set(LIBCXX_ENABLE_MONOTONIC_CLOCK ON CACHE BOOL "")
-set(LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS ON CACHE BOOL "")
set(LIBCXX_ENABLE_RANDOM_DEVICE OFF CACHE BOOL "")
set(LIBCXX_ENABLE_RTTI OFF CACHE BOOL "")
set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
@@ -22,7 +21,6 @@ set(RUNTIMES_USE_LIBC "llvm-libc" CACHE STRING "")
# Configuration options for libcxxabi.
set(LIBCXXABI_BAREMETAL ON CACHE BOOL "")
set(LIBCXXABI_ENABLE_EXCEPTIONS OFF CACHE BOOL "")
-set(LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS OFF CACHE BOOL "")
set(LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
set(LIBCXXABI_ENABLE_THREADS OFF CACHE BOOL "")
set(LIBCXXABI_USE_LLVM_UNWINDER OFF CACHE BOOL "")
diff --git a/libcxx/cmake/caches/FreeBSD.cmake b/libcxx/cmake/caches/FreeBSD.cmake
index 7a7d917922b53..7ca4ae863f001 100644
--- a/libcxx/cmake/caches/FreeBSD.cmake
+++ b/libcxx/cmake/caches/FreeBSD.cmake
@@ -5,4 +5,3 @@ set(LIBCXX_ABI_VERSION "1" CACHE STRING "")
set(LIBCXX_ENABLE_STATIC ON CACHE BOOL "")
set(LIBCXX_ENABLE_SHARED ON CACHE BOOL "")
set(LIBCXX_CXX_ABI libcxxrt CACHE STRING "")
-set(LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS ON CACHE BOOL "")
diff --git a/libcxx/cmake/caches/NVPTX.cmake b/libcxx/cmake/caches/NVPTX.cmake
index 34e9cb9a1ddd1..d2733141a4297 100644
--- a/libcxx/cmake/caches/NVPTX.cmake
+++ b/libcxx/cmake/caches/NVPTX.cmake
@@ -4,7 +4,6 @@ set(LIBCXX_ENABLE_EXCEPTIONS OFF CACHE BOOL "")
set(LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "")
set(LIBCXX_ENABLE_LOCALIZATION ON CACHE BOOL "")
set(LIBCXX_ENABLE_MONOTONIC_CLOCK ON CACHE BOOL "")
-set(LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS ON CACHE BOOL "")
set(LIBCXX_ENABLE_RANDOM_DEVICE OFF CACHE BOOL "")
set(LIBCXX_ENABLE_RTTI OFF CACHE BOOL "")
set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
@@ -22,7 +21,6 @@ set(RUNTIMES_USE_LIBC "llvm-libc" CACHE STRING "")
# Configuration options for libcxxabi.
set(LIBCXXABI_BAREMETAL ON CACHE BOOL "")
set(LIBCXXABI_ENABLE_EXCEPTIONS OFF CACHE BOOL "")
-set(LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS OFF CACHE BOOL "")
set(LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
set(LIBCXXABI_ENABLE_THREADS OFF CACHE BOOL "")
set(LIBCXXABI_USE_LLVM_UNWINDER OFF CACHE BOOL "")
diff --git a/libcxx/docs/ReleaseNotes/24.rst b/libcxx/docs/ReleaseNotes/24.rst
index 9cf08b5732970..948b364741ee5 100644
--- a/libcxx/docs/ReleaseNotes/24.rst
+++ b/libcxx/docs/ReleaseNotes/24.rst
@@ -91,3 +91,6 @@ ABI Affecting Changes
Build System Changes
--------------------
+
+- The ``LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS`` option has been removed. The various ``operator new`` functions are
+ now either defined in libc++abi or not at all (which still allows for them being provided by an external library).
diff --git a/libcxx/docs/VendorDocumentation.rst b/libcxx/docs/VendorDocumentation.rst
index 38fd5ac73e222..d217250229be2 100644
--- a/libcxx/docs/VendorDocumentation.rst
+++ b/libcxx/docs/VendorDocumentation.rst
@@ -581,7 +581,9 @@ Using libcxxrt on Linux
You will need to keep the source tree of `libcxxrt`_ available
on your build machine and your copy of the libcxxrt shared library must
-be placed where your linker will find it.
+be placed where your linker will find it. You must use a recent version
+of libcxxrt since historical versions did not provide the necessary
+definitions of ``operator new``.
We can now run CMake like:
@@ -590,7 +592,6 @@ We can now run CMake like:
$ cmake -G Ninja -S runtimes -B build \
-DLLVM_ENABLE_RUNTIMES="libcxx" \
-DLIBCXX_CXX_ABI=libcxxrt \
- -DLIBCXX_ENABLE_NEW_DELETE_DEFINITIONS=ON \
-DLIBCXXABI_USE_LLVM_UNWINDER=OFF \
-DLIBCXX_CXX_ABI_INCLUDE_PATHS=path/to/libcxxrt-sources/src
$ ninja -C build install-cxx
diff --git a/libcxx/lib/abi/CMakeLists.txt b/libcxx/lib/abi/CMakeLists.txt
index 8f277aad2dcd5..d3151e1939973 100644
--- a/libcxx/lib/abi/CMakeLists.txt
+++ b/libcxx/lib/abi/CMakeLists.txt
@@ -7,7 +7,7 @@
# Right now, this is done by using the ABI identifier as the filename containing
# the list of symbols exported by libc++ for that configuration, however we could
# make it more sophisticated if the number of ABI-affecting parameters grew.
-function(cxx_abi_list_identifier result triple abi_library abi_version unstable exceptions new_delete_in_libcxx)
+function(cxx_abi_list_identifier result triple abi_library abi_version unstable exceptions)
set(abi_properties)
if ("${triple}" MATCHES "darwin")
@@ -33,11 +33,6 @@ function(cxx_abi_list_identifier result triple abi_library abi_version unstable
else()
list(APPEND abi_properties "noexceptions")
endif()
- if (${new_delete_in_libcxx})
- list(APPEND abi_properties "new")
- else()
- list(APPEND abi_properties "nonew")
- endif()
list(JOIN abi_properties "." tmp)
set(${result} "${tmp}" PARENT_SCOPE)
@@ -54,7 +49,6 @@ cxx_abi_list_identifier(abi_list_identifier
"${LIBCXX_ABI_VERSION}"
"${LIBCXX_ABI_UNSTABLE}"
"${LIBCXX_ENABLE_EXCEPTIONS}"
- "${LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS}"
)
if (TARGET cxx_shared)
diff --git a/libcxx/lib/abi/arm64-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist b/libcxx/lib/abi/arm64-apple-darwin.libcxxabi.v1.stable.exceptions.abilist
similarity index 100%
rename from libcxx/lib/abi/arm64-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist
rename to libcxx/lib/abi/arm64-apple-darwin.libcxxabi.v1.stable.exceptions.abilist
diff --git a/libcxx/lib/abi/i686-linux-android23.libcxxabi.v1.stable.exceptions.nonew.abilist b/libcxx/lib/abi/i686-linux-android23.libcxxabi.v1.stable.exceptions.abilist
similarity index 100%
rename from libcxx/lib/abi/i686-linux-android23.libcxxabi.v1.stable.exceptions.nonew.abilist
rename to libcxx/lib/abi/i686-linux-android23.libcxxabi.v1.stable.exceptions.abilist
diff --git a/libcxx/lib/abi/powerpc-ibm-aix.libcxxabi.v1.stable.exceptions.nonew.abilist b/libcxx/lib/abi/powerpc-ibm-aix.libcxxabi.v1.stable.exceptions.abilist
similarity index 100%
rename from libcxx/lib/abi/powerpc-ibm-aix.libcxxabi.v1.stable.exceptions.nonew.abilist
rename to libcxx/lib/abi/powerpc-ibm-aix.libcxxabi.v1.stable.exceptions.abilist
diff --git a/libcxx/lib/abi/powerpc64-ibm-aix.libcxxabi.v1.stable.exceptions.nonew.abilist b/libcxx/lib/abi/powerpc64-ibm-aix.libcxxabi.v1.stable.exceptions.abilist
similarity index 100%
rename from libcxx/lib/abi/powerpc64-ibm-aix.libcxxabi.v1.stable.exceptions.nonew.abilist
rename to libcxx/lib/abi/powerpc64-ibm-aix.libcxxabi.v1.stable.exceptions.abilist
diff --git a/libcxx/lib/abi/x86_64-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist b/libcxx/lib/abi/x86_64-apple-darwin.libcxxabi.v1.stable.exceptions.abilist
similarity index 100%
rename from libcxx/lib/abi/x86_64-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist
rename to libcxx/lib/abi/x86_64-apple-darwin.libcxxabi.v1.stable.exceptions.abilist
diff --git a/libcxx/lib/abi/x86_64-linux-android23.libcxxabi.v1.stable.exceptions.nonew.abilist b/libcxx/lib/abi/x86_64-linux-android23.libcxxabi.v1.stable.exceptions.abilist
similarity index 100%
rename from libcxx/lib/abi/x86_64-linux-android23.libcxxabi.v1.stable.exceptions.nonew.abilist
rename to libcxx/lib/abi/x86_64-linux-android23.libcxxabi.v1.stable.exceptions.abilist
diff --git a/libcxx/lib/abi/x86_64-unknown-freebsd.libcxxabi.v1.stable.exceptions.nonew.abilist b/libcxx/lib/abi/x86_64-unknown-freebsd.libcxxabi.v1.stable.exceptions.abilist
similarity index 100%
rename from libcxx/lib/abi/x86_64-unknown-freebsd.libcxxabi.v1.stable.exceptions.nonew.abilist
rename to libcxx/lib/abi/x86_64-unknown-freebsd.libcxxabi.v1.stable.exceptions.abilist
diff --git a/libcxx/lib/abi/x86_64-unknown-linux-gnu.libcxxabi.v1.stable.exceptions.nonew.abilist b/libcxx/lib/abi/x86_64-unknown-linux-gnu.libcxxabi.v1.stable.exceptions.abilist
similarity index 100%
rename from libcxx/lib/abi/x86_64-unknown-linux-gnu.libcxxabi.v1.stable.exceptions.nonew.abilist
rename to libcxx/lib/abi/x86_64-unknown-linux-gnu.libcxxabi.v1.stable.exceptions.abilist
diff --git a/libcxx/lib/abi/x86_64-unknown-linux-gnu.libcxxabi.v1.stable.noexceptions.nonew.abilist b/libcxx/lib/abi/x86_64-unknown-linux-gnu.libcxxabi.v1.stable.noexceptions.abilist
similarity index 100%
rename from libcxx/lib/abi/x86_64-unknown-linux-gnu.libcxxabi.v1.stable.noexceptions.nonew.abilist
rename to libcxx/lib/abi/x86_64-unknown-linux-gnu.libcxxabi.v1.stable.noexceptions.abilist
diff --git a/libcxx/src/CMakeLists.txt b/libcxx/src/CMakeLists.txt
index e029f9f29d5ea..d2354b74db7ce 100644
--- a/libcxx/src/CMakeLists.txt
+++ b/libcxx/src/CMakeLists.txt
@@ -135,12 +135,6 @@ if (LIBCXX_ENABLE_FILESYSTEM)
endif()
endif()
-if (LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS)
- list(APPEND LIBCXX_SOURCES
- new.cpp
- )
-endif()
-
if (APPLE AND LLVM_USE_SANITIZER)
if (("${LLVM_USE_SANITIZER}" STREQUAL "Address") OR
("${LLVM_USE_SANITIZER}" STREQUAL "Address;Undefined") OR
@@ -277,22 +271,6 @@ set_target_properties(cxx_static
)
cxx_add_common_build_flags(cxx_static)
-if (LIBCXX_HERMETIC_STATIC_LIBRARY)
- # If the hermetic library doesn't define the operator new/delete functions
- # then its code shouldn't declare them with hidden visibility. They might
- # actually be provided by a shared library at link time.
- if (LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS)
- append_flags_if_supported(CXX_STATIC_LIBRARY_FLAGS -fvisibility-global-new-delete=force-hidden)
- if (NOT CXX_SUPPORTS_FVISIBILITY_GLOBAL_NEW_DELETE_EQ_FORCE_HIDDEN_FLAG)
- append_flags_if_supported(CXX_STATIC_LIBRARY_FLAGS -fvisibility-global-new-delete-hidden)
- endif()
- endif()
- target_compile_options(cxx_static PRIVATE ${CXX_STATIC_LIBRARY_FLAGS})
- # _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS can be defined in __config_site
- # too. Define it in the same way here, to avoid redefinition conflicts.
- target_compile_definitions(cxx_static PRIVATE _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS=)
-endif()
-
# Attempt to merge the libc++.a archive and the ABI library archive into one.
if (LIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY)
target_link_libraries(cxx_static PRIVATE libcxx-abi-static-objects)
diff --git a/libcxx/src/new.cpp b/libcxx/src/new.cpp
deleted file mode 100644
index 618b4348f1f94..0000000000000
--- a/libcxx/src/new.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include <__assert>
-#include <new>
-
-#if !defined(__GLIBCXX__) && !defined(_LIBCPP_ABI_VCRUNTIME)
-
-inline void __throw_bad_alloc_shim() { std::__throw_bad_alloc(); }
-
-# define _LIBCPP_ASSERT_SHIM(expr, str) _LIBCPP_ASSERT(expr, str)
-
-# include "support/new.ipp"
-
-#endif // !__GLIBCXX__ && !_LIBCPP_ABI_VCRUNTIME
diff --git a/libcxx/src/support/new.ipp b/libcxx/src/support/new.ipp
index 2f3af29f99378..a745388be958b 100644
--- a/libcxx/src/support/new.ipp
+++ b/libcxx/src/support/new.ipp
@@ -6,6 +6,8 @@
//
//===----------------------------------------------------------------------===//
+// TODO: This file is now only used from libc++abi. Simplify the implementation accordingly.
+
#include <cstddef>
#include <cstdlib>
#include <new>
diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt
index 902d4247fe6f7..bc008cef2f887 100644
--- a/libcxxabi/CMakeLists.txt
+++ b/libcxxabi/CMakeLists.txt
@@ -83,9 +83,8 @@ library to try comparing the type_info names to see if they are equal \
instead." OFF)
option(LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS
- "Build libc++abi with definitions for operator new/delete. These are normally
- defined in libc++abi, but it is also possible to define them in libc++, in
- which case the definition in libc++abi should be turned off." ON)
+ "Build libc++abi with definitions for operator new/delete. It is possible to turn this off if
+ these definitions are provided by another library (e.g. sanitizers)." ON)
option(LIBCXXABI_BUILD_32_BITS "Build 32 bit multilib libc++abi. This option is not supported anymore when building the runtimes. Please specify a full triple instead." ${LLVM_BUILD_32_BITS})
if (LIBCXXABI_BUILD_32_BITS)
message(FATAL_ERROR "LIBCXXABI_BUILD_32_BITS is not supported anymore when building the runtimes, please specify a full triple instead.")
>From 6550ded8eed52e68ef673d6667fa04fe7723e240 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Wed, 26 Aug 2026 13:22:17 -0400
Subject: [PATCH 2/4] Forgotten change in cross-linux-toolchain
---
clang/cmake/caches/cross-linux-toolchain.cmake | 1 -
1 file changed, 1 deletion(-)
diff --git a/clang/cmake/caches/cross-linux-toolchain.cmake b/clang/cmake/caches/cross-linux-toolchain.cmake
index fc456831a7892..47efa9c3aaeef 100644
--- a/clang/cmake/caches/cross-linux-toolchain.cmake
+++ b/clang/cmake/caches/cross-linux-toolchain.cmake
@@ -269,7 +269,6 @@ foreach(target ${LLVM_RUNTIME_TARGETS})
set(RUNTIMES_${target}_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
set(RUNTIMES_${target}_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
- set(RUNTIMES_${target}_LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS OFF CACHE BOOL "")
set(RUNTIMES_${target}_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
set(RUNTIMES_${target}_LIBCXX_CXX_ABI "libcxxabi" CACHE STRING "") #!!!
>From 5ca4268b93b64ff4204e0a9aa2affff78e23448d Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Wed, 26 Aug 2026 13:28:16 -0400
Subject: [PATCH 3/4] update FreeBSD cache
---
libcxx/cmake/caches/FreeBSD.cmake | 1 +
1 file changed, 1 insertion(+)
diff --git a/libcxx/cmake/caches/FreeBSD.cmake b/libcxx/cmake/caches/FreeBSD.cmake
index 7ca4ae863f001..8347a22a85b17 100644
--- a/libcxx/cmake/caches/FreeBSD.cmake
+++ b/libcxx/cmake/caches/FreeBSD.cmake
@@ -5,3 +5,4 @@ set(LIBCXX_ABI_VERSION "1" CACHE STRING "")
set(LIBCXX_ENABLE_STATIC ON CACHE BOOL "")
set(LIBCXX_ENABLE_SHARED ON CACHE BOOL "")
set(LIBCXX_CXX_ABI libcxxrt CACHE STRING "")
+set(LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS OFF CACHE BOOL "") # defined in libcxxrt
>From 43e218a01e6f15ca612fee6587faac4bc2f01712 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Wed, 26 Aug 2026 13:46:54 -0400
Subject: [PATCH 4/4] Undo unintended potentially-breaking change
---
libcxx/src/CMakeLists.txt | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/libcxx/src/CMakeLists.txt b/libcxx/src/CMakeLists.txt
index d2354b74db7ce..835dd9bd641c5 100644
--- a/libcxx/src/CMakeLists.txt
+++ b/libcxx/src/CMakeLists.txt
@@ -276,6 +276,12 @@ if (LIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY)
target_link_libraries(cxx_static PRIVATE libcxx-abi-static-objects)
endif()
+if (LIBCXX_HERMETIC_STATIC_LIBRARY)
+ # _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS can be defined in __config_site
+ # too. Define it in the same way here, to avoid redefinition conflicts.
+ target_compile_definitions(cxx_static PRIVATE _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS=)
+endif()
+
# Build the experimental static library
set(LIBCXX_EXPERIMENTAL_SOURCES
experimental/keep.cpp
More information about the cfe-commits
mailing list