diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 9dcb426f079fe..d84a07e610742 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -200,6 +200,8 @@ macro(build_dependency DEPENDENCY_NAME) build_jemalloc() elseif("${DEPENDENCY_NAME}" STREQUAL "lz4") build_lz4() + elseif("${DEPENDENCY_NAME}" STREQUAL "mimalloc") + build_mimalloc() elseif("${DEPENDENCY_NAME}" STREQUAL "nlohmann_json") build_nlohmann_json() elseif("${DEPENDENCY_NAME}" STREQUAL "opentelemetry-cpp") @@ -2194,7 +2196,7 @@ endif() # ---------------------------------------------------------------------- # mimalloc - Cross-platform high-performance allocator, from Microsoft -if(ARROW_MIMALLOC) +macro(build_mimalloc) if(NOT ARROW_ENABLE_THREADING) message(FATAL_ERROR "Can't use mimalloc with ARROW_ENABLE_THREADING=OFF") endif() @@ -2234,20 +2236,24 @@ if(ARROW_MIMALLOC) file(MAKE_DIRECTORY ${MIMALLOC_INCLUDE_DIR}) - add_library(mimalloc::mimalloc STATIC IMPORTED) - set_target_properties(mimalloc::mimalloc PROPERTIES IMPORTED_LOCATION + add_library(mimalloc STATIC IMPORTED) + set_target_properties(mimalloc PROPERTIES IMPORTED_LOCATION "${MIMALLOC_STATIC_LIB}") - target_include_directories(mimalloc::mimalloc BEFORE + target_include_directories(mimalloc BEFORE INTERFACE "${MIMALLOC_INCLUDE_DIR}") - target_link_libraries(mimalloc::mimalloc INTERFACE Threads::Threads) + target_link_libraries(mimalloc INTERFACE Threads::Threads) if(WIN32) - target_link_libraries(mimalloc::mimalloc INTERFACE "bcrypt.lib" "psapi.lib") + target_link_libraries(mimalloc INTERFACE "bcrypt.lib" "psapi.lib") endif() - add_dependencies(mimalloc::mimalloc mimalloc_ep) + add_dependencies(mimalloc mimalloc_ep) - list(APPEND ARROW_BUNDLED_STATIC_LIBS mimalloc::mimalloc) + list(APPEND ARROW_BUNDLED_STATIC_LIBS mimalloc) set(mimalloc_VENDORED TRUE) +endmacro() + +if(ARROW_MIMALLOC) + resolve_dependency(mimalloc) endif() # ---------------------------------------------------------------------- diff --git a/cpp/src/arrow/CMakeLists.txt b/cpp/src/arrow/CMakeLists.txt index 6dc8358f502f5..5c105effec20a 100644 --- a/cpp/src/arrow/CMakeLists.txt +++ b/cpp/src/arrow/CMakeLists.txt @@ -449,7 +449,7 @@ if(ARROW_JEMALLOC) endif() if(ARROW_MIMALLOC) foreach(ARROW_MEMORY_POOL_TARGET ${ARROW_MEMORY_POOL_TARGETS}) - target_link_libraries(${ARROW_MEMORY_POOL_TARGET} PRIVATE mimalloc::mimalloc) + target_link_libraries(${ARROW_MEMORY_POOL_TARGET} PRIVATE mimalloc) endforeach() endif() diff --git a/dev/tasks/linux-packages/apache-arrow/apt/ubuntu-jammy/Dockerfile b/dev/tasks/linux-packages/apache-arrow/apt/ubuntu-jammy/Dockerfile index e6718e59b0aba..17246793151c2 100644 --- a/dev/tasks/linux-packages/apache-arrow/apt/ubuntu-jammy/Dockerfile +++ b/dev/tasks/linux-packages/apache-arrow/apt/ubuntu-jammy/Dockerfile @@ -51,6 +51,7 @@ RUN \ libgrpc++-dev \ libgtest-dev \ liblz4-dev \ + libmimalloc-dev \ libprotobuf-dev \ libprotoc-dev \ libre2-dev \ diff --git a/dev/tasks/linux-packages/apache-arrow/apt/ubuntu-noble/Dockerfile b/dev/tasks/linux-packages/apache-arrow/apt/ubuntu-noble/Dockerfile index 87ea2402456b0..e5663fa045cfd 100644 --- a/dev/tasks/linux-packages/apache-arrow/apt/ubuntu-noble/Dockerfile +++ b/dev/tasks/linux-packages/apache-arrow/apt/ubuntu-noble/Dockerfile @@ -52,6 +52,7 @@ RUN \ libgrpc++-dev \ libgtest-dev \ liblz4-dev \ + libmimalloc-dev \ libmlir-15-dev \ libprotobuf-dev \ libprotoc-dev \ diff --git a/dev/tasks/linux-packages/apache-arrow/yum/almalinux-8/Dockerfile b/dev/tasks/linux-packages/apache-arrow/yum/almalinux-8/Dockerfile index d846915ab21de..a689682217622 100644 --- a/dev/tasks/linux-packages/apache-arrow/yum/almalinux-8/Dockerfile +++ b/dev/tasks/linux-packages/apache-arrow/yum/almalinux-8/Dockerfile @@ -46,6 +46,7 @@ RUN \ llvm-static \ lz4-devel \ make \ + mimalloc-devel \ ncurses-devel \ ninja-build \ openssl-devel \ diff --git a/dev/tasks/linux-packages/apache-arrow/yum/almalinux-9/Dockerfile b/dev/tasks/linux-packages/apache-arrow/yum/almalinux-9/Dockerfile index 222ab1b58d34d..38823677c6fa2 100644 --- a/dev/tasks/linux-packages/apache-arrow/yum/almalinux-9/Dockerfile +++ b/dev/tasks/linux-packages/apache-arrow/yum/almalinux-9/Dockerfile @@ -48,6 +48,7 @@ RUN \ llvm-static \ lz4-devel \ make \ + mimalloc-devel \ ncurses-devel \ ninja-build \ openssl-devel \ diff --git a/dev/tasks/linux-packages/apache-arrow/yum/centos-9-stream/Dockerfile b/dev/tasks/linux-packages/apache-arrow/yum/centos-9-stream/Dockerfile index 9522d999af5b7..4a54ed2aa421f 100644 --- a/dev/tasks/linux-packages/apache-arrow/yum/centos-9-stream/Dockerfile +++ b/dev/tasks/linux-packages/apache-arrow/yum/centos-9-stream/Dockerfile @@ -44,6 +44,7 @@ RUN \ llvm-devel \ lz4-devel \ make \ + mimalloc-devel \ ncurses-devel \ ninja-build \ openssl-devel \