summaryrefslogtreecommitdiff
path: root/libcxxabi
diff options
context:
space:
mode:
authorNikolas Klauser <nikolasklauser@berlin.de>2025-01-14 22:21:03 +0100
committerGitHub <noreply@github.com>2025-01-14 16:21:03 -0500
commitef804d8f9b4ef4ff39e873d5910e94887519bdb6 (patch)
treeab685121bf25d3b255077a3d11d4567f68940ab3 /libcxxabi
parent3d24c77f14d42721226b31d7e5d08f853cfc92f1 (diff)
[libc++] Simplify when the sized global deallocations overloads are available (#114667)
There doesn't seem to be much benefit in always providing declarations for the sized deallocations from C++14 onwards if the user explicitly passed `-fno-sized-deallocation` to disable them. This patch simplifies the declarations to be available exactly when the compiler expects sized deallocation functions to be available.
Diffstat (limited to 'libcxxabi')
-rw-r--r--libcxxabi/src/CMakeLists.txt10
1 files changed, 9 insertions, 1 deletions
diff --git a/libcxxabi/src/CMakeLists.txt b/libcxxabi/src/CMakeLists.txt
index 21dda44e0997..0a6fc892a4f6 100644
--- a/libcxxabi/src/CMakeLists.txt
+++ b/libcxxabi/src/CMakeLists.txt
@@ -77,7 +77,7 @@ endif()
if (FUCHSIA)
# TODO: Use CMAKE_LINK_LIBRARY_USING_FEATURE once our minimum CMake is at least 3.24
- # https://cmake.org/cmake/help/latest/variable/CMAKE_LINK_LIBRARY_USING_FEATURE.html
+ # https://cmake.org/cmake/help/latest/variable/CMAKE_LINK_LIBRARY_USING_FEATURE.html
add_link_flags("-Wl,--push-state,--as-needed,-lzircon,--pop-state")
endif()
@@ -190,6 +190,10 @@ if (CMAKE_POSITION_INDEPENDENT_CODE OR NOT DEFINED CMAKE_POSITION_INDEPENDENT_CO
endif()
target_compile_options(cxxabi_shared_objects PRIVATE "${LIBCXXABI_ADDITIONAL_COMPILE_FLAGS}")
+# Build with -fsized-deallocation, which is default in recent versions of Clang.
+# TODO(LLVM 21): This can be dropped once we only support Clang >= 19.
+target_add_compile_flags_if_supported(cxxabi_shared_objects PRIVATE -fsized-deallocation)
+
add_library(cxxabi_shared SHARED)
set_target_properties(cxxabi_shared
PROPERTIES
@@ -281,6 +285,10 @@ set_target_properties(cxxabi_static_objects
)
target_compile_options(cxxabi_static_objects PRIVATE "${LIBCXXABI_ADDITIONAL_COMPILE_FLAGS}")
+# Build with -fsized-deallocation, which is default in recent versions of Clang.
+# TODO(LLVM 21): This can be dropped once we only support Clang >= 19.
+target_add_compile_flags_if_supported(cxxabi_static_objects PRIVATE -fsized-deallocation)
+
if(LIBCXXABI_HERMETIC_STATIC_LIBRARY)
target_add_compile_flags_if_supported(cxxabi_static_objects PRIVATE -fvisibility=hidden)
# If the hermetic library doesn't define the operator new/delete functions