From 5d0cb6fc61a0788b9e74359aa227f2933cb2a32c Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Mon, 20 Jul 2026 11:36:19 +0200 Subject: [PATCH 1/5] GH-50428: [C++] Better mimalloc configuration on macOS --- cpp/cmake_modules/ThirdpartyToolchain.cmake | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 4eab2ab2086..46ff8206d36 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -2567,8 +2567,15 @@ if(ARROW_MIMALLOC) "-DCMAKE_C_FLAGS=${MIMALLOC_C_FLAGS}" "-DCMAKE_INSTALL_PREFIX=${MIMALLOC_PREFIX}" -DMI_INSTALL_TOPLEVEL=ON + # Don't override default malloc -DMI_OVERRIDE=OFF + -DMI_OSX_INTERPOSE=OFF + -DMI_OSX_ZONE=OFF + # Allow usage through dlopen (i.e. when libarrow.so itself is dlopen'ed) -DMI_LOCAL_DYNAMIC_TLS=ON + # GH-50428: Make sure several mimalloc instances can cohabit in the same process + # (also https://github.com/microsoft/mimalloc/issues/1327#issuecomment-4964140817) + -DMI_TLS_MODEL_THREAD_LOCAL=ON -DMI_BUILD_OBJECT=OFF -DMI_BUILD_SHARED=OFF -DMI_BUILD_TESTS=OFF From d833771a8b0506deb6f7fbfcf0d179580af58602 Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Mon, 20 Jul 2026 16:23:41 +0200 Subject: [PATCH 2/5] Fix CMake option name --- cpp/cmake_modules/ThirdpartyToolchain.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 46ff8206d36..f0697d7bf22 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -2575,7 +2575,7 @@ if(ARROW_MIMALLOC) -DMI_LOCAL_DYNAMIC_TLS=ON # GH-50428: Make sure several mimalloc instances can cohabit in the same process # (also https://github.com/microsoft/mimalloc/issues/1327#issuecomment-4964140817) - -DMI_TLS_MODEL_THREAD_LOCAL=ON + -DMI_TLS_MODEL_LOCAL=ON -DMI_BUILD_OBJECT=OFF -DMI_BUILD_SHARED=OFF -DMI_BUILD_TESTS=OFF From 0bf57cbe3aa47b22be9a9d4a3c05867807d6c467 Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Mon, 20 Jul 2026 17:09:13 +0200 Subject: [PATCH 3/5] Bump mimalloc to 3.4.1 for the CMake option to be present --- cpp/thirdparty/versions.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/thirdparty/versions.txt b/cpp/thirdparty/versions.txt index c6f4b01a717..ff05b6bbae9 100644 --- a/cpp/thirdparty/versions.txt +++ b/cpp/thirdparty/versions.txt @@ -80,8 +80,8 @@ ARROW_JEMALLOC_BUILD_VERSION=5.3.0 ARROW_JEMALLOC_BUILD_SHA256_CHECKSUM=2db82d1e7119df3e71b7640219b6dfe84789bc0537983c3b7ac4f7189aecfeaa ARROW_LZ4_BUILD_VERSION=v1.10.0 ARROW_LZ4_BUILD_SHA256_CHECKSUM=537512904744b35e232912055ccf8ec66d768639ff3abe5788d90d792ec5f48b -ARROW_MIMALLOC_BUILD_VERSION=v3.3.1 -ARROW_MIMALLOC_BUILD_SHA256_CHECKSUM=42c16914168ac6741eeb407e83b93a12b2b7ee25a7e14e6b4807fab8b577a540 +ARROW_MIMALLOC_BUILD_VERSION=v3.4.1 +ARROW_MIMALLOC_BUILD_SHA256_CHECKSUM=37107a52c16baa80c5f74861dddda7b27bb9949e41a6637691867a94c88ca446 ARROW_NLOHMANN_JSON_BUILD_VERSION=v3.12.0 ARROW_NLOHMANN_JSON_BUILD_SHA256_CHECKSUM=4b92eb0c06d10683f7447ce9406cb97cd4b453be18d7279320f7b2f025c10187 ARROW_OPENTELEMETRY_BUILD_VERSION=v1.21.0 From c5a439da9bba1e5924ac164fbeea883906f0460f Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Mon, 20 Jul 2026 17:56:57 +0200 Subject: [PATCH 4/5] Only force TLS model on Apple --- cpp/cmake_modules/ThirdpartyToolchain.cmake | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index f0697d7bf22..eb94e945334 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -2573,15 +2573,20 @@ if(ARROW_MIMALLOC) -DMI_OSX_ZONE=OFF # Allow usage through dlopen (i.e. when libarrow.so itself is dlopen'ed) -DMI_LOCAL_DYNAMIC_TLS=ON - # GH-50428: Make sure several mimalloc instances can cohabit in the same process - # (also https://github.com/microsoft/mimalloc/issues/1327#issuecomment-4964140817) - -DMI_TLS_MODEL_LOCAL=ON -DMI_BUILD_OBJECT=OFF -DMI_BUILD_SHARED=OFF -DMI_BUILD_TESTS=OFF # GH-47229: Force mimalloc to generate armv8.0 binary -DMI_NO_OPT_ARCH=ON) + if(APPLE) + set(MIMALLOC_CMAKE_ARGS + ${MIMALLOC_CMAKE_ARGS} + # GH-50428: Make sure several mimalloc instances can cohabit in the same process + # (also https://github.com/microsoft/mimalloc/issues/1327#issuecomment-4964140817) + -DMI_TLS_MODEL_LOCAL=ON) + endif() + externalproject_add(mimalloc_ep ${EP_COMMON_OPTIONS} URL ${MIMALLOC_SOURCE_URL} From f619d9746b92f4d2c5867555a5747f4afaee4d4a Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Tue, 21 Jul 2026 09:23:10 +0200 Subject: [PATCH 5/5] Use LIST APPEND --- cpp/cmake_modules/ThirdpartyToolchain.cmake | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index eb94e945334..1b5ee9a20e8 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -2580,11 +2580,11 @@ if(ARROW_MIMALLOC) -DMI_NO_OPT_ARCH=ON) if(APPLE) - set(MIMALLOC_CMAKE_ARGS - ${MIMALLOC_CMAKE_ARGS} - # GH-50428: Make sure several mimalloc instances can cohabit in the same process - # (also https://github.com/microsoft/mimalloc/issues/1327#issuecomment-4964140817) - -DMI_TLS_MODEL_LOCAL=ON) + list(APPEND + MIMALLOC_CMAKE_ARGS + # GH-50428: Make sure several mimalloc instances can cohabit in the same process + # (also https://github.com/microsoft/mimalloc/issues/1327#issuecomment-4964140817) + -DMI_TLS_MODEL_LOCAL=ON) endif() externalproject_add(mimalloc_ep