Build with system mimalloc
authorMatthias Geiger <werdahias@debian.org>
Wed, 10 Jun 2026 19:06:54 +0000 (21:06 +0200)
committerMatthias Geiger <werdahias@debian.org>
Sun, 14 Jun 2026 21:35:42 +0000 (23:35 +0200)
Gbp-Pq: Name 06-Build-with-system-mimalloc.patch

CMakeLists.txt
src/CMakeLists.txt
src/slvs/CMakeLists.txt

index c299dc08faf079d78ee1e93d8e20c5da95912939..9ded6f1dce5f347a2f1870ccd0575951b056e109 100644 (file)
@@ -216,25 +216,7 @@ if(ENABLE_GUI OR ENABLE_CLI)
     add_subdirectory(libdxfrw)
 endif()
 
-message(STATUS "Using in-tree mimalloc")
-set(MI_OVERRIDE OFF CACHE BOOL "")
-set(MI_BUILD_SHARED OFF CACHE BOOL "")
-set(MI_BUILD_OBJECT OFF CACHE BOOL "")
-set(MI_BUILD_TESTS OFF CACHE BOOL "")
-if(EMSCRIPTEN)
-    # HACK: We only use mimalloc for the temporary heap, not as a general purpose
-    # allocator. However, the Emscripten port of mimalloc assumes that it is used
-    # as the system allocator, and depends on the slow emmalloc allocator.
-    # We do not want to enable emmalloc, as that would slow down allocations all
-    # over the place, so we must either use mimalloc as the system allocator as
-    # well, or override its definitions to just use the existing system allocator.
-    # The latter option is the least intrusive change from a stability standpoint,
-    # so for now that's what we do here. We can try to convert to mimalloc wholsale
-    # and remove this hack if we find the need to do so in the future.
-    set(MI_EXTRA_CPPDEFS "emmalloc_free=free;emmalloc_memalign=memalign" CACHE INTERNAL "")
-endif()
-add_subdirectory(extlib/mimalloc EXCLUDE_FROM_ALL)
-set(MIMALLOC_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/extlib/mimalloc/include)
+find_package(mimalloc CONFIG)
 
 if(NOT FORCE_VENDORED_Eigen3)
     find_package(Eigen3 CONFIG)
index 3af20759907b1f9fd895201413649b99ac1bcad8..9451ec6267e559123e630f27fa64a2a69eae3a95 100644 (file)
@@ -36,7 +36,7 @@ target_link_libraries(slvs_deps INTERFACE
     ${ZLIB_LIBRARY}
     ${PNG_LIBRARY}
     ${FREETYPE_LIBRARY}
-    mimalloc-static)
+    mimalloc)
 
 if(NOT USE_QT_GUI OR ENABLE_CLI)
     target_include_directories(slvs_deps SYSTEM INTERFACE ${CAIRO_INCLUDE_DIRS})
index d931f8fa167647cae71a4c45168032e68eb361fe..7f5e9e46dc4f4115792809ba4d19637c98b2cda8 100644 (file)
@@ -5,7 +5,7 @@ add_library(slvs-interface INTERFACE)
 target_sources(slvs-interface INTERFACE lib.cpp)
 target_compile_definitions(slvs-interface INTERFACE -DLIBRARY)
 target_include_directories(slvs-interface INTERFACE ${CMAKE_SOURCE_DIR}/include)
-target_link_libraries(slvs-interface INTERFACE slvs-solver mimalloc-static)
+target_link_libraries(slvs-interface INTERFACE slvs-solver mimalloc)
 
 if(ENABLE_PYTHON_LIB)
     add_custom_command(