]> dgit.raspbian.org Git - solvespace.git/commitdiff
Add patch to build with system mimalloc (Closes: #1138822)
authorMatthias Geiger <werdahias@debian.org>
Wed, 10 Jun 2026 19:09:40 +0000 (21:09 +0200)
committerMatthias Geiger <werdahias@debian.org>
Wed, 10 Jun 2026 19:09:40 +0000 (21:09 +0200)
debian/patches/06-Build-with-system-mimalloc.patch [new file with mode: 0644]
debian/patches/series

diff --git a/debian/patches/06-Build-with-system-mimalloc.patch b/debian/patches/06-Build-with-system-mimalloc.patch
new file mode 100644 (file)
index 0000000..afbd37b
--- /dev/null
@@ -0,0 +1,67 @@
+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(
index ca5e28a5dff32a05e441ba20a5877050d2c93389..cca5e354de0ad2a0eaa9a3a29c0d38f9f46b1b9d 100644 (file)
@@ -3,3 +3,4 @@
 03_use_system_threejs.patch
 04_use_system_unifont.patch
 05-Adjust-extlib-include-path.patch
+06-Build-with-system-mimalloc.patch