--- /dev/null
+From: Matthias Geiger <werdahias@debian.org>
+Date: Wed, 10 Jun 2026 21:06:54 +0200
+Subject: Build with system mimalloc
+
+---
+ CMakeLists.txt | 20 +-------------------
+ src/CMakeLists.txt | 2 +-
+ src/slvs/CMakeLists.txt | 2 +-
+ 3 files changed, 3 insertions(+), 21 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index c299dc0..9ded6f1 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -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)
+diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
+index 3af2075..9451ec6 100644
+--- a/src/CMakeLists.txt
++++ b/src/CMakeLists.txt
+@@ -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})
+diff --git a/src/slvs/CMakeLists.txt b/src/slvs/CMakeLists.txt
+index d931f8f..7f5e9e4 100644
+--- a/src/slvs/CMakeLists.txt
++++ b/src/slvs/CMakeLists.txt
+@@ -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(