commit:     5dd1a9bebc88ac2eea8f5677cfd0909b3e6163ca
Author:     Alfredo Tupone <tupone <AT> gentoo <DOT> org>
AuthorDate: Sun Feb  1 12:14:28 2026 +0000
Commit:     Alfredo Tupone <tupone <AT> gentoo <DOT> org>
CommitDate: Sun Feb  1 12:15:07 2026 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5dd1a9be

sci-ml/caffe2: enable mimalloc USE

Closes: https://bugs.gentoo.org/969328
Signed-off-by: Alfredo Tupone <tupone <AT> gentoo.org>

 .../{caffe2-2.10.0-r1.ebuild => caffe2-2.10.0-r2.ebuild}   |  7 +++++--
 sci-ml/caffe2/files/caffe2-2.10.0-mimalloc.patch           | 14 ++++++++++++++
 sci-ml/caffe2/metadata.xml                                 |  1 +
 3 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/sci-ml/caffe2/caffe2-2.10.0-r1.ebuild 
b/sci-ml/caffe2/caffe2-2.10.0-r2.ebuild
similarity index 98%
rename from sci-ml/caffe2/caffe2-2.10.0-r1.ebuild
rename to sci-ml/caffe2/caffe2-2.10.0-r2.ebuild
index 559439f586d2..de19280d828d 100644
--- a/sci-ml/caffe2/caffe2-2.10.0-r1.ebuild
+++ b/sci-ml/caffe2/caffe2-2.10.0-r2.ebuild
@@ -44,8 +44,8 @@ S="${WORKDIR}"/${MYP}
 LICENSE="BSD"
 SLOT="0"
 KEYWORDS="~amd64 ~arm64"
-IUSE="cuda cusparselt distributed fbgemm flash gloo memefficient mkl mpi nccl 
nnpack +numpy
-       onednn openblas opencl openmp qnnpack rocm xnnpack"
+IUSE="cuda cusparselt distributed fbgemm flash gloo memefficient mimalloc mkl
+       mpi nccl nnpack +numpy onednn openblas opencl openmp qnnpack rocm 
xnnpack"
 RESTRICT="test"
 REQUIRED_USE="
        ${PYTHON_REQUIRED_USE}
@@ -81,6 +81,7 @@ RDEPEND="
        )
        fbgemm? ( sci-ml/FBGEMM )
        gloo? ( >=sci-ml/gloo-2025.06.04[cuda?,rocm?] )
+       mimalloc? ( dev-libs/mimalloc )
        mpi? ( virtual/mpi )
        nnpack? (
                sci-ml/NNPACK
@@ -163,6 +164,7 @@ PATCHES=(
        "${FILESDIR}"/${PN}-2.9.0-rocm-distributed-link.patch
        "${FILESDIR}"/${PN}-2.9.1-torch_cpu.patch
        "${FILESDIR}"/${P}-gentoo.patch
+       "${FILESDIR}"/${P}-mimalloc.patch
 )
 
 src_prepare() {
@@ -291,6 +293,7 @@ src_configure() {
                -DUSE_KLEIDIAI=OFF # TODO
                -DUSE_MAGMA=OFF # TODO: In GURU as sci-libs/magma
                -DUSE_MEM_EFF_ATTENTION=$(usex memefficient)
+               -DUSE_MIMALLOC=$(usex mimalloc)
                -DUSE_MKLDNN=$(usex onednn)
                -DUSE_MPI=$(usex mpi)
                -DUSE_NCCL=OFF

diff --git a/sci-ml/caffe2/files/caffe2-2.10.0-mimalloc.patch 
b/sci-ml/caffe2/files/caffe2-2.10.0-mimalloc.patch
new file mode 100644
index 000000000000..ed859776febe
--- /dev/null
+++ b/sci-ml/caffe2/files/caffe2-2.10.0-mimalloc.patch
@@ -0,0 +1,14 @@
+--- a/c10/CMakeLists.txt       2026-02-01 09:22:55.398151644 +0100
++++ b/c10/CMakeLists.txt       2026-02-01 09:30:46.720495230 +0100
+@@ -120,8 +120,9 @@
+   endif()
+ 
+   if(USE_MIMALLOC)
+-    target_link_libraries(c10 PRIVATE "mimalloc-static")
+-    add_dependencies(c10 mimalloc-static)
++    find_package(mimalloc REQUIRED)
++    target_link_libraries(c10 PRIVATE "mimalloc")
++    add_dependencies(c10 mimalloc)
+   endif()
+ 
+   if(LINUX)

diff --git a/sci-ml/caffe2/metadata.xml b/sci-ml/caffe2/metadata.xml
index 16e166ccaf7b..519739396a46 100644
--- a/sci-ml/caffe2/metadata.xml
+++ b/sci-ml/caffe2/metadata.xml
@@ -12,6 +12,7 @@
                <flag name="flash">Enable flash attention</flag>
                <flag name="gloo">Use <pkg>sci-ml/gloo</pkg></flag>
                <flag name="memefficient">Enable mem efficient attention</flag>
+               <flag name="mimalloc">Use <pkg>dev-libs/mimalloc</pkg> as 
replacement for system malloc</flag>
                <flag name="mkl">Use <pkg>sci-libs/mkl</pkg> for blas, lapack 
and sparse blas routines</flag>
                <flag name="nnpack">Use <pkg>sci-ml/NNPACK</pkg></flag>
                <flag name="numpy">Add support for math operations through 
numpy</flag>

Reply via email to