From cbac182edfa10743393cfba56ffd1ecd74006ca0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Thu, 9 Jul 2020 15:25:36 +0200 Subject: [PATCH] Add and build mimalloc at 07c6e60a5a3bd7de09e4a170cd97bafba59cfafd --- .gitmodules | 3 +++ .travis/install-debian.sh | 2 +- CMakeLists.txt | 8 ++++++++ README.md | 4 ++-- extlib/mimalloc | 1 + pkg/snap/snap/snapcraft.yaml | 2 +- src/CMakeLists.txt | 15 +++++++++++---- 7 files changed, 27 insertions(+), 8 deletions(-) create mode 160000 extlib/mimalloc diff --git a/.gitmodules b/.gitmodules index 51dd0792..51193203 100644 --- a/.gitmodules +++ b/.gitmodules @@ -26,3 +26,6 @@ [submodule "extlib/q3d"] path = extlib/q3d url = https://github.com/q3k/q3d +[submodule "extlib/mimalloc"] + path = extlib/mimalloc + url = https://github.com/microsoft/mimalloc diff --git a/.travis/install-debian.sh b/.travis/install-debian.sh index c8b7d70b..fb20fffa 100755 --- a/.travis/install-debian.sh +++ b/.travis/install-debian.sh @@ -7,4 +7,4 @@ sudo apt-get install -q -y \ libfontconfig1-dev libgtkmm-3.0-dev libpangomm-1.4-dev libgl-dev \ libgl-dev libglu-dev libspnav-dev -git submodule update --init extlib/libdxfrw extlib/flatbuffers extlib/q3d +git submodule update --init extlib/libdxfrw extlib/flatbuffers extlib/q3d extlib/mimalloc diff --git a/CMakeLists.txt b/CMakeLists.txt index 5a258f4b..c4914d63 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -175,6 +175,14 @@ message(STATUS "Using in-tree q3d") add_subdirectory(extlib/q3d) set(Q3D_INCLUDE_DIR ${CMAKE_BINARY_DIR}/extlib/q3d) +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 "") +add_subdirectory(extlib/mimalloc) +set(MIMALLOC_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/extlib/mimalloc/include) + if(WIN32 OR APPLE) # On Win32 and macOS we use vendored packages, since there is little to no benefit # to trying to find system versions. In particular, trying to link to libraries from diff --git a/README.md b/README.md index cd72564d..295f25fe 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ Before building, check out the project and the necessary submodules: git clone https://github.com/solvespace/solvespace cd solvespace - git submodule update --init extlib/libdxfrw extlib/flatbuffers extlib/q3d + git submodule update --init extlib/libdxfrw extlib/flatbuffers extlib/q3d extlib/mimalloc After that, build SolveSpace as following: @@ -185,7 +185,7 @@ Before building, check out the project and the necessary submodules: git clone https://github.com/solvespace/solvespace cd solvespace - git submodule update --init extlib/libdxfrw extlib/flatbuffers extlib/q3d + git submodule update --init extlib/libdxfrw extlib/flatbuffers extlib/q3d extlib/mimalloc After that, build SolveSpace as following: diff --git a/extlib/mimalloc b/extlib/mimalloc new file mode 160000 index 00000000..07c6e60a --- /dev/null +++ b/extlib/mimalloc @@ -0,0 +1 @@ +Subproject commit 07c6e60a5a3bd7de09e4a170cd97bafba59cfafd diff --git a/pkg/snap/snap/snapcraft.yaml b/pkg/snap/snap/snapcraft.yaml index 273f9d49..195a5086 100644 --- a/pkg/snap/snap/snapcraft.yaml +++ b/pkg/snap/snap/snapcraft.yaml @@ -45,7 +45,7 @@ parts: snapcraftctl set-version "$version" git describe --exact-match HEAD && grade="stable" || grade="devel" snapcraftctl set-grade "$grade" - git submodule update --init extlib/libdxfrw extlib/flatbuffers extlib/q3d + git submodule update --init extlib/libdxfrw extlib/flatbuffers extlib/q3d extlib/mimalloc configflags: - -DCMAKE_INSTALL_PREFIX=/usr - -DCMAKE_BUILD_TYPE=Release diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d1d9fc35..16d6e360 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -59,7 +59,11 @@ target_include_directories(slvs PUBLIC ${CMAKE_SOURCE_DIR}/include) target_link_libraries(slvs - ${util_LIBRARIES}) + ${util_LIBRARIES} + mimalloc-static) + +add_dependencies(slvs + mimalloc-static) set_target_properties(slvs PROPERTIES PUBLIC_HEADER ${CMAKE_SOURCE_DIR}/include/slvs.h @@ -81,7 +85,8 @@ include_directories( ${PNG_PNG_INCLUDE_DIR} ${FREETYPE_INCLUDE_DIRS} ${CAIRO_INCLUDE_DIRS} - ${Q3D_INCLUDE_DIR}) + ${Q3D_INCLUDE_DIR} + ${MIMALLOC_INCLUDE_DIR}) if(Backtrace_FOUND) include_directories( @@ -213,7 +218,8 @@ add_library(solvespace-core STATIC ${solvespace_core_SOURCES}) add_dependencies(solvespace-core - q3d_header) + q3d_header + mimalloc-static) target_link_libraries(solvespace-core ${OpenMP_CXX_LIBRARIES} @@ -222,7 +228,8 @@ target_link_libraries(solvespace-core ${ZLIB_LIBRARY} ${PNG_LIBRARY} ${FREETYPE_LIBRARY} - flatbuffers) + flatbuffers + mimalloc-static) if(Backtrace_FOUND) target_link_libraries(solvespace-core