Initial commit

This commit is contained in:
2026-01-23 22:15:36 +01:00
commit ca60108606
167 changed files with 5311 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
if(NOT TARGET minject)
if(CMAKE_CROSSCOMPILING)
find_program(MINJECT_EXECUTABLE
NAMES minject
PATHS ENV PATH
NO_DEFAULT_PATH
)
find_program(MINJECT32_EXECUTABLE
NAMES minject32
PATHS ENV PATH
NO_DEFAULT_PATH
)
else()
find_program(MINJECT_EXECUTABLE
NAMES minject
PATHS "${CMAKE_CURRENT_LIST_DIR}/../../bin/"
NO_DEFAULT_PATH
)
find_program(MINJECT32_EXECUTABLE
NAMES minject32
PATHS "${CMAKE_CURRENT_LIST_DIR}/../../bin/"
NO_DEFAULT_PATH
)
endif()
if(MINJECT_EXECUTABLE)
get_filename_component(MINJECT_EXECUTABLE "${MINJECT_EXECUTABLE}" ABSOLUTE)
add_executable(minject IMPORTED)
set_property(TARGET minject PROPERTY IMPORTED_LOCATION ${MINJECT_EXECUTABLE})
endif()
if(MINJECT32_EXECUTABLE)
get_filename_component(MINJECT32_EXECUTABLE "${MINJECT32_EXECUTABLE}" ABSOLUTE)
add_executable(minject32 IMPORTED)
set_property(TARGET minject32 PROPERTY IMPORTED_LOCATION ${MINJECT32_EXECUTABLE})
endif()
endif()

View File

@@ -0,0 +1,80 @@
sources:
"3.1.5":
url: "https://github.com/microsoft/mimalloc/archive/v3.1.5.tar.gz"
sha256: "1c6949032069d5ebea438ec5cedd602d06f40a92ddf0f0d9dcff0993e5f6635c"
"2.2.4":
url: "https://github.com/microsoft/mimalloc/archive/v2.2.4.tar.gz"
sha256: "754a98de5e2912fddbeaf24830f982b4540992f1bab4a0a8796ee118e0752bda"
"2.1.9":
url: "https://github.com/microsoft/mimalloc/archive/v2.1.9.tar.gz"
sha256: "dd8ff701691f19bf4e225d42ef0d3d5e6ca0e03498ee4f044a0402e4697e4a20"
"2.1.7":
url: "https://github.com/microsoft/mimalloc/archive/v2.1.7.tar.gz"
sha256: "0eed39319f139afde8515010ff59baf24de9e47ea316a315398e8027d198202d"
"2.1.2":
url: "https://github.com/microsoft/mimalloc/archive/v2.1.2.tar.gz"
sha256: "2b1bff6f717f9725c70bf8d79e4786da13de8a270059e4ba0bdd262ae7be46eb"
"2.0.9":
url: "https://github.com/microsoft/mimalloc/archive/v2.0.9.tar.gz"
sha256: "4a29edae32a914a706715e2ac8e7e4109e25353212edeed0888f4e3e15db5850"
"1.8.7":
url: "https://github.com/microsoft/mimalloc/archive/v1.8.7.tar.gz"
sha256: "347793a2c614e525edc4e286ab5cbc4c7a5efc12503e2dafca276d78394c4f07"
"1.8.2":
url: "https://github.com/microsoft/mimalloc/archive/v1.8.2.tar.gz"
sha256: "4058d53d6ceb75862f32c30a6ee686c3cbb5e965b2c324b828ca454f7fe064f9"
"1.7.9":
url: "https://github.com/microsoft/mimalloc/archive/v1.7.9.tar.gz"
sha256: "45e05be518363d32b2cdcce1a1fac3580895ea2e4524e1a3c7e71145cb58659f"
"1.7.6":
url: "https://github.com/microsoft/mimalloc/archive/v1.7.6.tar.gz"
sha256: "d74f86ada2329016068bc5a243268f1f555edd620b6a7d6ce89295e7d6cf18da"
patches:
"2.2.4":
- patch_file: "patches/2.2.4-0002-support-older-compiler.patch"
patch_description: "fix compilation errors on older compilers"
patch_type: "portability"
"2.1.9":
- patch_file: "patches/2.1.9-0002-support-older-compiler.patch"
patch_description: "fix compilation errors on older compilers"
patch_type: "portability"
"2.1.7":
- patch_file: "patches/2.1.7-0002-support-older-compiler.patch"
patch_description: "fix compilation errors on older compilers"
patch_type: "portability"
"2.1.2":
- patch_file: "patches/2.1.2-0001-change-install-paths.patch"
patch_description: "fix install paths"
patch_type: "conan"
- patch_file: "patches/2.1.2-0002-support-older-compiler.patch"
patch_description: "fix compilation errors on older compilers"
patch_type: "portability"
"2.0.9":
- patch_file: "patches/2.0.9-0001-change-install-paths.patch"
patch_description: "fix install paths"
patch_type: "conan"
- patch_file: "patches/2.0.9-0002-support-older-compiler.patch"
patch_description: "fix compilation errors on older compilers"
patch_type: "portability"
"1.8.7":
- patch_file: "patches/1.8.7-0002-support-older-compiler.patch"
patch_description: "fix compilation errors on older compilers"
patch_type: "portability"
"1.8.2":
- patch_file: "patches/1.8.2-0001-change-install-paths.patch"
patch_description: "fix install paths"
patch_type: "conan"
- patch_file: "patches/1.8.2-0002-support-older-compiler.patch"
patch_description: "fix compilation errors on older compilers"
patch_type: "portability"
"1.7.9":
- patch_file: "patches/1.7.9-0001-change-install-paths.patch"
patch_description: "fix install paths"
patch_type: "conan"
- patch_file: "patches/1.7.9-0002-support-older-compiler.patch"
patch_description: "fix compilation errors on older compilers"
patch_type: "portability"
"1.7.6":
- patch_file: "patches/1.7.5-0001-change-install-paths.patch"
patch_description: "fix install paths"
patch_type: "conan"

246
mimalloc/all/conanfile.py Normal file
View File

@@ -0,0 +1,246 @@
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy, rm, rmdir, replace_in_file, collect_libs
from conan.tools.microsoft import is_msvc, is_msvc_static_runtime, VCVars
from conan.tools.env import VirtualBuildEnv
from conan.tools.scm import Version
import os
import shutil
required_conan_version = ">=2"
class MimallocConan(ConanFile):
name = "mimalloc"
description = "mimalloc is a compact general purpose allocator with excellent performance."
license = "MIT"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/microsoft/mimalloc"
topics = ("mimalloc", "allocator", "performance", "microsoft")
package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
"secure": [True, False],
"override": [True, False],
"inject": [True, False],
"single_object": [True, False],
"guarded": [True, False],
"win_redirect": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"secure": False,
"override": False,
"inject": False,
"single_object": False,
"guarded": False,
"win_redirect": False,
}
def export_sources(self):
export_conandata_patches(self)
copy(self, os.path.join("cmake", "MinjectTargets.cmake"), self.recipe_folder, self.export_sources_folder)
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
else:
del self.options.win_redirect
# single_object and inject are options
# only when overriding on Unix-like platforms:
if is_msvc(self):
del self.options.single_object
del self.options.inject
if Version(self.version) < "2.1.9":
del self.options.guarded
def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")
# single_object is valid only for static
# override:
self.options.rm_safe("single_object")
# inject is valid only for Unix-like dynamic override:
if not self.options.shared:
self.options.rm_safe("inject")
# single_object and inject are valid only when
# overriding on Unix-like platforms:
if not self.options.override:
self.options.rm_safe("single_object")
self.options.rm_safe("inject")
def layout(self):
cmake_layout(self, src_folder="src")
def validate(self):
# Currently, mimalloc some version do not work properly with shared MD builds.
# https://github.com/conan-io/conan-center-index/pull/10333#issuecomment-1114110046
if Version(self.version) == "1.7.6" and \
self.options.shared and \
is_msvc(self) and \
not is_msvc_static_runtime(self):
raise ConanInvalidConfiguration(
f"Currently, {self.ref} doesn't work properly with shared MD builds in CCI. Contributions welcomed")
# Shared overriding requires dynamic runtime for MSVC:
if self.options.override and \
self.options.shared and \
is_msvc(self) and \
is_msvc_static_runtime(self):
raise ConanInvalidConfiguration(
"Dynamic runtime (MD/MDd) is required when using mimalloc as a shared library for override")
if self.options.get_safe("win_redirect") and not (
self.options.override and \
self.options.shared and \
is_msvc(self) and \
not is_msvc_static_runtime(self)):
raise ConanInvalidConfiguration(
"Windows redirect requires 'override', 'shared' and building against a dynamic runtime (MD/MDd)")
if self.options.override and \
self.options.get_safe("single_object") and \
self.options.get_safe("inject"):
raise ConanInvalidConfiguration("Single object is incompatible with library injection")
def build_requirements(self):
self.tool_requires("cmake/[>=3.18 <4]")
def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)
def generate(self):
tc = CMakeToolchain(self)
tc.variables["MI_BUILD_TESTS"] = "OFF"
tc.variables["MI_BUILD_SHARED"] = self.options.shared
tc.variables["MI_BUILD_STATIC"] = not self.options.shared
tc.variables["MI_BUILD_OBJECT"] = self.options.get_safe("single_object", False)
tc.variables["MI_OVERRIDE"] = "ON" if self.options.override else "OFF"
tc.variables["MI_SECURE"] = "ON" if self.options.secure else "OFF"
tc.variables["MI_WIN_REDIRECT"] = "ON" if self.options.get_safe("win_redirect") else "OFF"
tc.variables["MI_INSTALL_TOPLEVEL"] = "ON"
tc.variables["MI_GUARDED"] = self.options.get_safe("guarded", False)
if Version(self.version) <= "1.7.6":
tc.cache_variables["CMAKE_POLICY_VERSION_MINIMUM"] = "3.5" # CMake 4 support
tc.generate()
venv = VirtualBuildEnv(self)
venv.generate(scope="build")
if is_msvc(self):
vcvars = VCVars(self)
vcvars.generate()
def build(self):
apply_conandata_patches(self)
if is_msvc(self) and self.settings.arch == "x86" and self.options.shared:
replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"),
"mimalloc-redirect.lib",
"mimalloc-redirect32.lib")
cmake = CMake(self)
cmake.configure()
cmake.build()
def package(self):
copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder)
cmake = CMake(self)
cmake.install()
rmdir(self, os.path.join(self.package_folder, "cmake"))
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
if self.options.get_safe("single_object"):
rm(self, "*.a", os.path.join(self.package_folder, "lib"))
shutil.copy(os.path.join(self.package_folder, "lib", self._obj_name + ".o"),
os.path.join(self.package_folder, "lib", self._obj_name))
if self.settings.os == "Windows" and self.options.shared:
if self.settings.arch == "x86_64":
copy(self, "mimalloc-redirect.dll",
src=os.path.join(self.source_folder, "bin"),
dst=os.path.join(self.package_folder, "bin"))
copy(self, "minject.exe",
src=os.path.join(self.source_folder, "bin"),
dst=os.path.join(self.package_folder, "bin"))
elif self.settings.arch == "x86":
copy(self, "mimalloc-redirect32.dll",
src=os.path.join(self.source_folder, "bin"),
dst=os.path.join(self.package_folder, "bin"))
copy(self, "minject32.exe",
src=os.path.join(self.source_folder, "bin"),
dst=os.path.join(self.package_folder, "bin"))
rmdir(self, os.path.join(self.package_folder, "share"))
copy(self, "MinjectTargets.cmake",
src=os.path.join(self.source_folder, os.pardir, "cmake"),
dst=os.path.join(self.package_folder, self._module_path))
@property
def _obj_name(self):
name = "mimalloc"
if self.options.secure:
name += "-secure"
if self.settings.build_type not in ("Release", "RelWithDebInfo", "MinSizeRel"):
name += "-{}".format(str(self.settings.build_type).lower())
return name
@property
def _lib_name(self):
name = "mimalloc" if self.settings.os == "Windows" else "libmimalloc"
if self.settings.os == "Windows" and not self.options.shared:
name += "-static"
if self.options.secure:
name += "-secure"
if self.settings.build_type not in ("Release", "RelWithDebInfo", "MinSizeRel"):
name += "-{}".format(str(self.settings.build_type).lower())
return name
@property
def _module_path(self):
return os.path.join(self.package_folder, "lib", "cmake")
def package_info(self):
self.cpp_info.set_property("cmake_file_name", "mimalloc")
self.cpp_info.set_property("cmake_target_name", "mimalloc" if self.options.shared else "mimalloc-static")
if self.options.get_safe("inject"):
self.cpp_info.includedirs = []
self.cpp_info.libdirs = []
self.cpp_info.resdirs = []
return
if self.options.get_safe("single_object"):
obj_ext = "o"
obj_file = "{}.{}".format(self._obj_name, obj_ext)
obj_path = os.path.join(self.package_folder, "lib", obj_file)
self.cpp_info.exelinkflags = [obj_path]
self.cpp_info.sharedlinkflags = [obj_path]
self.cpp_info.libdirs = []
self.cpp_info.bindirs = []
else:
self.cpp_info.libs = collect_libs(self)
if self.settings.os == "Linux":
self.cpp_info.system_libs.append("pthread")
if not self.options.shared:
if self.settings.os == "Windows":
self.cpp_info.system_libs.extend(["psapi", "shell32", "user32", "bcrypt"])
elif self.settings.os == "Linux":
self.cpp_info.system_libs.append("rt")
if self.settings.os == "Windows" and self.options.shared:
build_modules = [
os.path.join(self._module_path, "MinjectTargets.cmake"),
]
self.cpp_info.set_property("cmake_build_modules", build_modules)

View File

@@ -0,0 +1,22 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d1207bb..feeecb6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -319,7 +319,7 @@ if(MI_BUILD_SHARED)
install(FILES "$<TARGET_FILE_DIR:mimalloc>/mimalloc-redirect${MIMALLOC_REDIRECT_SUFFIX}.dll" DESTINATION ${mi_install_libdir})
endif()
- install(TARGETS mimalloc EXPORT mimalloc DESTINATION ${mi_install_libdir} LIBRARY)
+ install(TARGETS mimalloc EXPORT mimalloc RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
install(EXPORT mimalloc DESTINATION ${mi_install_cmakedir})
endif()
@@ -343,7 +343,7 @@ if (MI_BUILD_STATIC)
set_target_properties(mimalloc-static PROPERTIES OUTPUT_NAME ${mi_basename})
endif()
- install(TARGETS mimalloc-static EXPORT mimalloc DESTINATION ${mi_install_objdir} LIBRARY)
+ install(TARGETS mimalloc-static EXPORT mimalloc RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
install(EXPORT mimalloc DESTINATION ${mi_install_cmakedir})
endif()

View File

@@ -0,0 +1,22 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0011b87..41a15a2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -383,7 +383,7 @@ if(MI_BUILD_SHARED)
install(FILES "$<TARGET_FILE_DIR:mimalloc>/mimalloc-redirect${MIMALLOC_REDIRECT_SUFFIX}.dll" DESTINATION ${mi_install_libdir})
endif()
- install(TARGETS mimalloc EXPORT mimalloc DESTINATION ${mi_install_libdir} LIBRARY)
+ install(TARGETS mimalloc EXPORT mimalloc RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
install(EXPORT mimalloc DESTINATION ${mi_install_cmakedir})
endif()
@@ -407,7 +407,7 @@ if (MI_BUILD_STATIC)
set_target_properties(mimalloc-static PROPERTIES OUTPUT_NAME ${mi_basename})
endif()
- install(TARGETS mimalloc-static EXPORT mimalloc DESTINATION ${mi_install_objdir} LIBRARY)
+ install(TARGETS mimalloc-static EXPORT mimalloc RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
install(EXPORT mimalloc DESTINATION ${mi_install_cmakedir})
endif()

View File

@@ -0,0 +1,22 @@
diff --git a/include/mimalloc.h b/include/mimalloc.h
index f590033..a4275c5 100644
--- a/include/mimalloc.h
+++ b/include/mimalloc.h
@@ -493,7 +493,7 @@ template<class T, bool destroy> struct _mi_heap_stl_allocator_common : public _m
#endif
void collect(bool force) { mi_heap_collect(this->heap.get(), force); }
- template<class U> bool is_equal(const _mi_heap_stl_allocator_common<U, destroy>& x) const { return (this->heap == x.heap); }
+ template<class U, bool b> bool is_equal(const _mi_heap_stl_allocator_common<U, b>& x) const { return (this->heap == x.heap); }
protected:
std::shared_ptr<mi_heap_t> heap;
@@ -504,7 +504,7 @@ protected:
this->heap.reset(hp, (destroy ? &heap_destroy : &heap_delete)); /* calls heap_delete/destroy when the refcount drops to zero */
}
_mi_heap_stl_allocator_common(const _mi_heap_stl_allocator_common& x) mi_attr_noexcept : heap(x.heap) { }
- template<class U> _mi_heap_stl_allocator_common(const _mi_heap_stl_allocator_common<U, destroy>& x) mi_attr_noexcept : heap(x.heap) { }
+ template<class U, bool b> _mi_heap_stl_allocator_common(const _mi_heap_stl_allocator_common<U, b>& x) mi_attr_noexcept : heap(x.heap) { }
private:
static void heap_delete(mi_heap_t* hp) { if (hp != NULL) { mi_heap_delete(hp); } }

View File

@@ -0,0 +1,22 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2bcd1ef..615cec9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -415,7 +415,7 @@ if(MI_BUILD_SHARED)
install(FILES "$<TARGET_FILE_DIR:mimalloc>/mimalloc-redirect${MIMALLOC_REDIRECT_SUFFIX}.dll" DESTINATION ${mi_install_libdir})
endif()
- install(TARGETS mimalloc EXPORT mimalloc DESTINATION ${mi_install_libdir} LIBRARY)
+ install(TARGETS mimalloc EXPORT mimalloc RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
install(EXPORT mimalloc DESTINATION ${mi_install_cmakedir})
endif()
@@ -439,7 +439,7 @@ if (MI_BUILD_STATIC)
set_target_properties(mimalloc-static PROPERTIES OUTPUT_NAME ${mi_basename})
endif()
- install(TARGETS mimalloc-static EXPORT mimalloc DESTINATION ${mi_install_objdir} LIBRARY)
+ install(TARGETS mimalloc-static EXPORT mimalloc RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
install(EXPORT mimalloc DESTINATION ${mi_install_cmakedir})
endif()

View File

@@ -0,0 +1,22 @@
diff --git a/include/mimalloc.h b/include/mimalloc.h
index 368c22c..fb19939 100644
--- a/include/mimalloc.h
+++ b/include/mimalloc.h
@@ -505,7 +505,7 @@ template<class T, bool _mi_destroy> struct _mi_heap_stl_allocator_common : publi
#endif
void collect(bool force) { mi_heap_collect(this->heap.get(), force); }
- template<class U> bool is_equal(const _mi_heap_stl_allocator_common<U, _mi_destroy>& x) const { return (this->heap == x.heap); }
+ template<class U, bool b> bool is_equal(const _mi_heap_stl_allocator_common<U, b>& x) const { return (this->heap == x.heap); }
protected:
std::shared_ptr<mi_heap_t> heap;
@@ -516,7 +516,7 @@ protected:
this->heap.reset(hp, (_mi_destroy ? &heap_destroy : &heap_delete)); /* calls heap_delete/destroy when the refcount drops to zero */
}
_mi_heap_stl_allocator_common(const _mi_heap_stl_allocator_common& x) mi_attr_noexcept : heap(x.heap) { }
- template<class U> _mi_heap_stl_allocator_common(const _mi_heap_stl_allocator_common<U, _mi_destroy>& x) mi_attr_noexcept : heap(x.heap) { }
+ template<class U, bool b> _mi_heap_stl_allocator_common(const _mi_heap_stl_allocator_common<U, b>& x) mi_attr_noexcept : heap(x.heap) { }
private:
static void heap_delete(mi_heap_t* hp) { if (hp != NULL) { mi_heap_delete(hp); } }

View File

@@ -0,0 +1,22 @@
diff --git a/include/mimalloc.h b/include/mimalloc.h
index ae6f99b..773424e 100644
--- a/include/mimalloc.h
+++ b/include/mimalloc.h
@@ -511,7 +511,7 @@ template<class T, bool _mi_destroy> struct _mi_heap_stl_allocator_common : publi
#endif
void collect(bool force) { mi_heap_collect(this->heap.get(), force); }
- template<class U> bool is_equal(const _mi_heap_stl_allocator_common<U, _mi_destroy>& x) const { return (this->heap == x.heap); }
+ template<class U, bool b> bool is_equal(const _mi_heap_stl_allocator_common<U, b>& x) const { return (this->heap == x.heap); }
protected:
std::shared_ptr<mi_heap_t> heap;
@@ -522,7 +522,7 @@ protected:
this->heap.reset(hp, (_mi_destroy ? &heap_destroy : &heap_delete)); /* calls heap_delete/destroy when the refcount drops to zero */
}
_mi_heap_stl_allocator_common(const _mi_heap_stl_allocator_common& x) mi_attr_noexcept : heap(x.heap) { }
- template<class U> _mi_heap_stl_allocator_common(const _mi_heap_stl_allocator_common<U, _mi_destroy>& x) mi_attr_noexcept : heap(x.heap) { }
+ template<class U, bool b> _mi_heap_stl_allocator_common(const _mi_heap_stl_allocator_common<U, b>& x) mi_attr_noexcept : heap(x.heap) { }
private:
static void heap_delete(mi_heap_t* hp) { if (hp != NULL) { mi_heap_delete(hp); } }

View File

@@ -0,0 +1,22 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 74c1f29..d657144 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -383,7 +383,7 @@ if(MI_BUILD_SHARED)
install(FILES "$<TARGET_FILE_DIR:mimalloc>/mimalloc-redirect${MIMALLOC_REDIRECT_SUFFIX}.dll" DESTINATION ${mi_install_libdir})
endif()
- install(TARGETS mimalloc EXPORT mimalloc DESTINATION ${mi_install_libdir} LIBRARY)
+ install(TARGETS mimalloc EXPORT mimalloc RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
install(EXPORT mimalloc DESTINATION ${mi_install_cmakedir})
endif()
@@ -407,7 +407,7 @@ if (MI_BUILD_STATIC)
set_target_properties(mimalloc-static PROPERTIES OUTPUT_NAME ${mi_basename})
endif()
- install(TARGETS mimalloc-static EXPORT mimalloc DESTINATION ${mi_install_objdir} LIBRARY)
+ install(TARGETS mimalloc-static EXPORT mimalloc RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
install(EXPORT mimalloc DESTINATION ${mi_install_cmakedir})
endif()

View File

@@ -0,0 +1,22 @@
diff --git a/include/mimalloc.h b/include/mimalloc.h
index 9b72fbf..b34362f 100644
--- a/include/mimalloc.h
+++ b/include/mimalloc.h
@@ -500,7 +500,7 @@ template<class T, bool destroy> struct _mi_heap_stl_allocator_common : public _m
#endif
void collect(bool force) { mi_heap_collect(this->heap.get(), force); }
- template<class U> bool is_equal(const _mi_heap_stl_allocator_common<U, destroy>& x) const { return (this->heap == x.heap); }
+ template<class U, bool b> bool is_equal(const _mi_heap_stl_allocator_common<U, b>& x) const { return (this->heap == x.heap); }
protected:
std::shared_ptr<mi_heap_t> heap;
@@ -511,7 +511,7 @@ protected:
this->heap.reset(hp, (destroy ? &heap_destroy : &heap_delete)); /* calls heap_delete/destroy when the refcount drops to zero */
}
_mi_heap_stl_allocator_common(const _mi_heap_stl_allocator_common& x) mi_attr_noexcept : heap(x.heap) { }
- template<class U> _mi_heap_stl_allocator_common(const _mi_heap_stl_allocator_common<U, destroy>& x) mi_attr_noexcept : heap(x.heap) { }
+ template<class U, bool b> _mi_heap_stl_allocator_common(const _mi_heap_stl_allocator_common<U, b>& x) mi_attr_noexcept : heap(x.heap) { }
private:
static void heap_delete(mi_heap_t* hp) { if (hp != NULL) { mi_heap_delete(hp); } }

View File

@@ -0,0 +1,13 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2bcd1ef..37eee49 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -415,7 +415,7 @@ if(MI_BUILD_SHARED)
install(FILES "$<TARGET_FILE_DIR:mimalloc>/mimalloc-redirect${MIMALLOC_REDIRECT_SUFFIX}.dll" DESTINATION ${mi_install_libdir})
endif()
- install(TARGETS mimalloc EXPORT mimalloc DESTINATION ${mi_install_libdir} LIBRARY)
+ install(TARGETS mimalloc EXPORT mimalloc RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
install(EXPORT mimalloc DESTINATION ${mi_install_cmakedir})
endif()

View File

@@ -0,0 +1,22 @@
diff --git a/include/mimalloc.h b/include/mimalloc.h
index f77c2ea..4c9594f 100644
--- a/include/mimalloc.h
+++ b/include/mimalloc.h
@@ -508,7 +508,7 @@ template<class T, bool _mi_destroy> struct _mi_heap_stl_allocator_common : publi
#endif
void collect(bool force) { mi_heap_collect(this->heap.get(), force); }
- template<class U> bool is_equal(const _mi_heap_stl_allocator_common<U, _mi_destroy>& x) const { return (this->heap == x.heap); }
+ template<class U, bool b> bool is_equal(const _mi_heap_stl_allocator_common<U, b>& x) const { return (this->heap == x.heap); }
protected:
std::shared_ptr<mi_heap_t> heap;
@@ -519,7 +519,7 @@ protected:
this->heap.reset(hp, (_mi_destroy ? &heap_destroy : &heap_delete)); /* calls heap_delete/destroy when the refcount drops to zero */
}
_mi_heap_stl_allocator_common(const _mi_heap_stl_allocator_common& x) mi_attr_noexcept : heap(x.heap) { }
- template<class U> _mi_heap_stl_allocator_common(const _mi_heap_stl_allocator_common<U, _mi_destroy>& x) mi_attr_noexcept : heap(x.heap) { }
+ template<class U, bool b> _mi_heap_stl_allocator_common(const _mi_heap_stl_allocator_common<U, b>& x) mi_attr_noexcept : heap(x.heap) { }
private:
static void heap_delete(mi_heap_t* hp) { if (hp != NULL) { mi_heap_delete(hp); } }

View File

@@ -0,0 +1,22 @@
diff --git a/include/mimalloc.h b/include/mimalloc.h
index c41bcc8..cc4929e 100644
--- a/include/mimalloc.h
+++ b/include/mimalloc.h
@@ -512,7 +512,7 @@ template<class T, bool _mi_destroy> struct _mi_heap_stl_allocator_common : publi
#endif
void collect(bool force) { mi_heap_collect(this->heap.get(), force); }
- template<class U> bool is_equal(const _mi_heap_stl_allocator_common<U, _mi_destroy>& x) const { return (this->heap == x.heap); }
+ template<class U, bool b> bool is_equal(const _mi_heap_stl_allocator_common<U, b>& x) const { return (this->heap == x.heap); }
protected:
std::shared_ptr<mi_heap_t> heap;
@@ -523,7 +523,7 @@ protected:
this->heap.reset(hp, (_mi_destroy ? &heap_destroy : &heap_delete)); /* calls heap_delete/destroy when the refcount drops to zero */
}
_mi_heap_stl_allocator_common(const _mi_heap_stl_allocator_common& x) mi_attr_noexcept : heap(x.heap) { }
- template<class U> _mi_heap_stl_allocator_common(const _mi_heap_stl_allocator_common<U, _mi_destroy>& x) mi_attr_noexcept : heap(x.heap) { }
+ template<class U, bool b> _mi_heap_stl_allocator_common(const _mi_heap_stl_allocator_common<U, b>& x) mi_attr_noexcept : heap(x.heap) { }
private:
static void heap_delete(mi_heap_t* hp) { if (hp != NULL) { mi_heap_delete(hp); } }

View File

@@ -0,0 +1,23 @@
diff --git a/include/mimalloc.h b/include/mimalloc.h
index bd91db4..f6aa1aa 100644
--- a/include/mimalloc.h
+++ b/include/mimalloc.h
@@ -544,7 +544,7 @@ template<class T, bool _mi_destroy> struct _mi_heap_stl_allocator_common : publi
#endif
void collect(bool force) { mi_heap_collect(this->heap.get(), force); }
- template<class U> bool is_equal(const _mi_heap_stl_allocator_common<U, _mi_destroy>& x) const { return (this->heap == x.heap); }
+ template<class U, bool b> bool is_equal(const _mi_heap_stl_allocator_common<U, b>& x) const { return (this->heap == x.heap); }
protected:
std::shared_ptr<mi_heap_t> heap;
@@ -555,7 +555,8 @@ protected:
this->heap.reset(hp, (_mi_destroy ? &heap_destroy : &heap_delete)); /* calls heap_delete/destroy when the refcount drops to zero */
}
_mi_heap_stl_allocator_common(const _mi_heap_stl_allocator_common& x) mi_attr_noexcept : heap(x.heap) { }
- template<class U> _mi_heap_stl_allocator_common(const _mi_heap_stl_allocator_common<U, _mi_destroy>& x) mi_attr_noexcept : heap(x.heap) { }
+ template<class U, bool b> _mi_heap_stl_allocator_common(const _mi_heap_stl_allocator_common<U, b>& x) mi_attr_noexcept : heap(x.heap)
+ { }
private:
static void heap_delete(mi_heap_t* hp) { if (hp != NULL) { mi_heap_delete(hp); } }

View File

@@ -0,0 +1,23 @@
diff --git a/include/mimalloc.h b/include/mimalloc.h
index bd91db4..f6aa1aa 100644
--- a/include/mimalloc.h
+++ b/include/mimalloc.h
@@ -555,7 +555,7 @@ template<class T, bool _mi_destroy> struct _mi_heap_stl_allocator_common : publi
#endif
void collect(bool force) { mi_heap_collect(this->heap.get(), force); }
- template<class U> bool is_equal(const _mi_heap_stl_allocator_common<U, _mi_destroy>& x) const { return (this->heap == x.heap); }
+ template<class U, bool b> bool is_equal(const _mi_heap_stl_allocator_common<U, b>& x) const { return (this->heap == x.heap); }
protected:
std::shared_ptr<mi_heap_t> heap;
@@ -566,7 +566,8 @@ protected:
this->heap.reset(hp, (_mi_destroy ? &heap_destroy : &heap_delete)); /* calls heap_delete/destroy when the refcount drops to zero */
}
_mi_heap_stl_allocator_common(const _mi_heap_stl_allocator_common& x) mi_attr_noexcept : heap(x.heap) { }
- template<class U> _mi_heap_stl_allocator_common(const _mi_heap_stl_allocator_common<U, _mi_destroy>& x) mi_attr_noexcept : heap(x.heap) { }
+ template<class U, bool b> _mi_heap_stl_allocator_common(const _mi_heap_stl_allocator_common<U, b>& x) mi_attr_noexcept : heap(x.heap)
+ { }
private:
static void heap_delete(mi_heap_t* hp) { if (hp != NULL) { mi_heap_delete(hp); } }

View File

@@ -0,0 +1,14 @@
cmake_minimum_required(VERSION 3.15)
project(test_package LANGUAGES C)
find_package(mimalloc REQUIRED CONFIG)
find_program(MINJECT_EXECUTABLE NAMES minject)
execute_process(COMMAND ${MINJECT_EXECUTABLE} -h)
find_program(MINJECT32_EXECUTABLE NAMES minject32)
execute_process(COMMAND ${MINJECT32_EXECUTABLE} -h)
add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} PRIVATE $<IF:$<TARGET_EXISTS:mimalloc>,mimalloc,mimalloc-static>)
target_compile_features(${PROJECT_NAME} PRIVATE c_std_99)

View File

@@ -0,0 +1,28 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import CMake, cmake_layout
import os
class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv"
def layout(self):
cmake_layout(self)
def requirements(self):
self.requires(self.tested_reference_str)
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def configure(self):
self.options["mimalloc"].shared = True
def test(self):
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindir, "test_package")
self.run(bin_path, env="conanrun")

View File

@@ -0,0 +1,14 @@
#include "mimalloc.h"
#include <stdlib.h>
#include <stdio.h>
int main() {
void *data = mi_malloc(32);
printf("mimalloc version %d\n", mi_version());
mi_free(data);
return EXIT_SUCCESS;
}

23
mimalloc/config.yml Normal file
View File

@@ -0,0 +1,23 @@
versions:
"3.1.5":
folder: all
"2.2.4":
folder: all
"2.1.9":
folder: all
"2.1.7":
folder: all
# mold requires 2.1.2
"2.1.2":
folder: all
"2.0.9":
folder: all
"1.8.7":
folder: all
"1.8.2":
folder: all
"1.7.9":
folder: all
# arrow requires 1.7.6
"1.7.6":
folder: all