From fd5ab9f1f384d60c153a12a693872e9d8ed0608a Mon Sep 17 00:00:00 2001 From: Eduard Voronkin Date: Wed, 6 Nov 2024 12:02:22 -0800 Subject: [PATCH] fix new/delete overrides apparently, even if MI_USE_CXX is OFF, mimalloc still provides mangled definitions of new/delete operators. It causes inability to statically link mimaloc in our scenario, since we want to have our own overrides of new/delete functions. --- src/alloc-override.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/alloc-override.c b/src/alloc-override.c index 82a98b80..0ba92af7 100644 --- a/src/alloc-override.c +++ b/src/alloc-override.c @@ -189,9 +189,8 @@ typedef void* mi_nothrow_t; void* operator new[]( std::size_t n, std::align_val_t al) noexcept(false) { return mi_new_aligned(n, static_cast(al)); } void* operator new (std::size_t n, std::align_val_t al, const std::nothrow_t&) noexcept { return mi_new_aligned_nothrow(n, static_cast(al)); } void* operator new[](std::size_t n, std::align_val_t al, const std::nothrow_t&) noexcept { return mi_new_aligned_nothrow(n, static_cast(al)); } - #endif -#elif (defined(__GNUC__) || defined(__clang__)) + #elif (defined(__GNUC__) || defined(__clang__)) // ------------------------------------------------------ // Override by defining the mangled C++ names of the operators (as // used by GCC and CLang). @@ -234,6 +233,7 @@ typedef void* mi_nothrow_t; #else #error "define overloads for new/delete for this platform (just for performance, can be skipped)" #endif + #endif #endif // __cplusplus // ------------------------------------------------------