Skip to content

Commit

Permalink
contrib/jemalloc: new package (5.3.0)
Browse files Browse the repository at this point in the history
  • Loading branch information
nekopsykose committed Jul 3, 2024
1 parent b0d25b6 commit 96a7a65
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 0 deletions.
1 change: 1 addition & 0 deletions contrib/jemalloc-devel
50 changes: 50 additions & 0 deletions contrib/jemalloc/patches/exceptionspec.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
Patch-Source: https://github.com/jemalloc/jemalloc/pull/2338
--
From 9cfceb398c323e56709e4a60ece405cac4546e50 Mon Sep 17 00:00:00 2001
From: Marvin Schmidt <marv@exherbo.org>
Date: Tue, 27 Sep 2022 07:03:14 +0200
Subject: [PATCH 1/2] configure: Handle *-linux-musl* hosts properly

This is the same as the `*-*-linux*` case with the two exceptions that
we don't set glibc=1 and don't define JEMALLOC_USE_CXX_THROW
---
configure.ac | 13 +++++++++++++
1 file changed, 13 insertions(+)

diff --git a/configure.ac b/configure.ac
index 0ae579eeaf..619a9cd6fc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -687,6 +687,19 @@ case "${host}" in
fi
zero_realloc_default_free="1"
;;
+ *-*-linux-musl*)
+ dnl syscall(2) and secure_getenv(3) are exposed by _GNU_SOURCE.
+ JE_APPEND_VS(CPPFLAGS, -D_GNU_SOURCE)
+ abi="elf"
+ AC_DEFINE([JEMALLOC_PURGE_MADVISE_DONTNEED_ZEROS], [ ], [ ])
+ AC_DEFINE([JEMALLOC_HAS_ALLOCA_H], [ ], [ ])
+ AC_DEFINE([JEMALLOC_PROC_SYS_VM_OVERCOMMIT_MEMORY], [ ], [ ])
+ AC_DEFINE([JEMALLOC_THREADED_INIT], [ ], [ ])
+ if test "${LG_SIZEOF_PTR}" = "3"; then
+ default_retain="1"
+ fi
+ zero_realloc_default_free="1"
+ ;;
*-*-linux*)
dnl syscall(2) and secure_getenv(3) are exposed by _GNU_SOURCE.
JE_APPEND_VS(CPPFLAGS, -D_GNU_SOURCE)
diff --git a/include/jemalloc/jemalloc_macros.h.in b/include/jemalloc/jemalloc_macros.h.in
index 2de3f27de5..05d996be28 100644
--- a/include/jemalloc/jemalloc_macros.h.in
+++ b/include/jemalloc/jemalloc_macros.h.in
@@ -142,7 +142,7 @@
# define JEMALLOC_COLD
#endif

-#if (defined(__APPLE__) || defined(__FreeBSD__)) && !defined(JEMALLOC_NO_RENAME)
+#if (defined(__APPLE__) || defined(__FreeBSD__) || (defined(__linux__) && !defined(__GLIBC__))) && !defined(JEMALLOC_NO_RENAME)
# define JEMALLOC_SYS_NOTHROW
#else
# define JEMALLOC_SYS_NOTHROW JEMALLOC_NOTHROW
21 changes: 21 additions & 0 deletions contrib/jemalloc/patches/skiptest.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
=== test/integration/aligned_alloc ===
test_alignment_errors:../test/integration/aligned_alloc.c:24: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 0
test_alignment_errors:../test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 9
test_alignment_errors:../test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 17
test_alignment_errors:../test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 33
test_alignment_errors:../test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 65
test_alignment_errors:../test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 129
test_alignment_errors:../test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 257
etc
--
--- a/Makefile.in
+++ b/Makefile.in
@@ -296,7 +296,7 @@
$(srcroot)test/unit/arena_reset_prof.c \
$(srcroot)test/unit/batch_alloc_prof.c
endif
-TESTS_INTEGRATION := $(srcroot)test/integration/aligned_alloc.c \
+TESTS_INTEGRATION := \
$(srcroot)test/integration/allocated.c \
$(srcroot)test/integration/extent.c \
$(srcroot)test/integration/malloc.c \
34 changes: 34 additions & 0 deletions contrib/jemalloc/template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
pkgname = "jemalloc"
pkgver = "5.3.0"
pkgrel = 0
build_style = "gnu_configure"
configure_args = ["--with-lg-hugepage=21"]
configure_gen = ["./autogen.sh"]
make_cmd = "gmake"
hostmakedepends = [
"automake",
"gmake",
"libtool",
"pkgconf",
]
pkgdesc = "General purpose allocator library"
maintainer = "psykose <alice@ayaya.dev>"
license = "BSD-2-Clause"
url = "https://jemalloc.net"
source = f"https://github.com/jemalloc/jemalloc/releases/download/{pkgver}/jemalloc-{pkgver}.tar.bz2"
sha256 = "2db82d1e7119df3e71b7640219b6dfe84789bc0537983c3b7ac4f7189aecfeaa"

match self.profile().arch:
case "aarch64" | "ppc64" | "ppc64le":
configure_args += ["--with-lg-page=16"]
case _:
configure_args += ["--with-lg-page=12"]


def post_install(self):
self.install_license("COPYING")


@subpackage("jemalloc-devel")
def _devel(self):
return self.default_devel()

0 comments on commit 96a7a65

Please sign in to comment.