Gentoo Archives: gentoo-commits

From: Sam James <sam@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-libs/jemalloc/files/, dev-libs/jemalloc/
Date: Mon, 20 Mar 2023 05:36:13
Message-Id: 1679290256.466520df0a775cdc311a4642bdc4d3a309af573d.sam@gentoo
1 commit: 466520df0a775cdc311a4642bdc4d3a309af573d
2 Author: Violet Purcell <vimproved <AT> inventati <DOT> org>
3 AuthorDate: Sat Mar 18 00:02:52 2023 +0000
4 Commit: Sam James <sam <AT> gentoo <DOT> org>
5 CommitDate: Mon Mar 20 05:30:56 2023 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=466520df
7
8 dev-libs/jemalloc: backport musl fix (PR 2338)
9
10 Closes: https://bugs.gentoo.org/893142
11 Signed-off-by: Violet Purcell <vimproved <AT> inventati.org>
12 Closes: https://github.com/gentoo/gentoo/pull/30199
13 Signed-off-by: Sam James <sam <AT> gentoo.org>
14
15 .../files/jemalloc-5.3.0-backport-pr-2338.patch | 83 ++++++++++++++++++++++
16 dev-libs/jemalloc/jemalloc-5.3.0-r1.ebuild | 3 +-
17 2 files changed, 85 insertions(+), 1 deletion(-)
18
19 diff --git a/dev-libs/jemalloc/files/jemalloc-5.3.0-backport-pr-2338.patch b/dev-libs/jemalloc/files/jemalloc-5.3.0-backport-pr-2338.patch
20 new file mode 100644
21 index 000000000000..6d4d4a11f741
22 --- /dev/null
23 +++ b/dev-libs/jemalloc/files/jemalloc-5.3.0-backport-pr-2338.patch
24 @@ -0,0 +1,83 @@
25 +Backport Musl fixes from PR #2338.
26 +
27 +Upstream PR: https://github.com/jemalloc/jemalloc/pull/2338
28 +Upstream commits: https://github.com/jemalloc/jemalloc/commit/45249cf5a9cfa13c2c62e68e272a391721523b4b, https://github.com/jemalloc/jemalloc/commit/aba1645f2d65a3b5c46958d7642b46ab3c142cf3
29 +
30 +From aba1645f2d65a3b5c46958d7642b46ab3c142cf3 Mon Sep 17 00:00:00 2001
31 +From: Marvin Schmidt <marv@×××××××.org>
32 +Date: Tue, 27 Sep 2022 07:03:14 +0200
33 +Subject: [PATCH] configure: Handle *-linux-musl* hosts properly
34 +
35 +This is the same as the `*-*-linux*` case with the two exceptions that
36 +we don't set glibc=1 and don't define JEMALLOC_USE_CXX_THROW
37 +---
38 + configure.ac | 13 +++++++++++++
39 + 1 file changed, 13 insertions(+)
40 +
41 +diff --git a/configure.ac b/configure.ac
42 +index 2bbf7d54a..f38b72d64 100644
43 +--- a/configure.ac
44 ++++ b/configure.ac
45 +@@ -723,6 +723,19 @@ case "${host}" in
46 + fi
47 + zero_realloc_default_free="1"
48 + ;;
49 ++ *-*-linux-musl*)
50 ++ dnl syscall(2) and secure_getenv(3) are exposed by _GNU_SOURCE.
51 ++ JE_APPEND_VS(CPPFLAGS, -D_GNU_SOURCE)
52 ++ abi="elf"
53 ++ AC_DEFINE([JEMALLOC_PURGE_MADVISE_DONTNEED_ZEROS], [ ], [ ])
54 ++ AC_DEFINE([JEMALLOC_HAS_ALLOCA_H], [ ], [ ])
55 ++ AC_DEFINE([JEMALLOC_PROC_SYS_VM_OVERCOMMIT_MEMORY], [ ], [ ])
56 ++ AC_DEFINE([JEMALLOC_THREADED_INIT], [ ], [ ])
57 ++ if test "${LG_SIZEOF_PTR}" = "3"; then
58 ++ default_retain="1"
59 ++ fi
60 ++ zero_realloc_default_free="1"
61 ++ ;;
62 + *-*-linux*)
63 + dnl syscall(2) and secure_getenv(3) are exposed by _GNU_SOURCE.
64 + JE_APPEND_VS(CPPFLAGS, -D_GNU_SOURCE)
65 +
66 +From 45249cf5a9cfa13c2c62e68e272a391721523b4b Mon Sep 17 00:00:00 2001
67 +From: Marvin Schmidt <marv@×××××××.org>
68 +Date: Tue, 27 Sep 2022 07:00:13 +0200
69 +Subject: [PATCH] Fix exception specification error for hosts using musl libc
70 +
71 +It turns out that the previous commit did not suffice since the
72 +JEMALLOC_SYS_NOTHROW definition also causes the same exception specification
73 +errors as JEMALLOC_USE_CXX_THROW did:
74 +```
75 +x86_64-pc-linux-musl-cc -std=gnu11 -Werror=unknown-warning-option -Wall -Wextra -Wshorten-64-to-32 -Wsign-compare -Wundef -Wno-format-zero-length -Wpointer-
76 +arith -Wno-missing-braces -Wno-missing-field-initializers -pipe -g3 -fvisibility=hidden -Wimplicit-fallthrough -O3 -funroll-loops -march=native -O2 -pipe -c -march=native -O2 -pipe -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/background_thread.o src/background_thread.c
77 +In file included from src/jemalloc_cpp.cpp:9:
78 +In file included from include/jemalloc/internal/jemalloc_preamble.h:27:
79 +include/jemalloc/internal/../jemalloc.h:254:32: error: exception specification in declaration does not match previous declaration
80 + void JEMALLOC_SYS_NOTHROW *je_malloc(size_t size)
81 + ^
82 +include/jemalloc/internal/../jemalloc.h:75:21: note: expanded from macro 'je_malloc'
83 + ^
84 +/usr/x86_64-pc-linux-musl/include/stdlib.h:40:7: note: previous declaration is here
85 +void *malloc (size_t);
86 + ^
87 +```
88 +
89 +On systems using the musl C library we have to omit the exception specification
90 +on malloc function family like it's done for MacOS, FreeBSD and OpenBSD.
91 +---
92 + include/jemalloc/jemalloc_macros.h.in | 2 +-
93 + 1 file changed, 1 insertion(+), 1 deletion(-)
94 +
95 +diff --git a/include/jemalloc/jemalloc_macros.h.in b/include/jemalloc/jemalloc_macros.h.in
96 +index 2de3f27de..05d996be2 100644
97 +--- a/include/jemalloc/jemalloc_macros.h.in
98 ++++ b/include/jemalloc/jemalloc_macros.h.in
99 +@@ -142,7 +142,7 @@
100 + # define JEMALLOC_COLD
101 + #endif
102 +
103 +-#if (defined(__APPLE__) || defined(__FreeBSD__)) && !defined(JEMALLOC_NO_RENAME)
104 ++#if (defined(__APPLE__) || defined(__FreeBSD__) || (defined(__linux__) && !defined(__GLIBC__))) && !defined(JEMALLOC_NO_RENAME)
105 + # define JEMALLOC_SYS_NOTHROW
106 + #else
107 + # define JEMALLOC_SYS_NOTHROW JEMALLOC_NOTHROW
108
109 diff --git a/dev-libs/jemalloc/jemalloc-5.3.0-r1.ebuild b/dev-libs/jemalloc/jemalloc-5.3.0-r1.ebuild
110 index 36af3bb44643..341374a74d7f 100644
111 --- a/dev-libs/jemalloc/jemalloc-5.3.0-r1.ebuild
112 +++ b/dev-libs/jemalloc/jemalloc-5.3.0-r1.ebuild
113 @@ -1,4 +1,4 @@
114 -# Copyright 1999-2022 Gentoo Authors
115 +# Copyright 1999-2023 Gentoo Authors
116 # Distributed under the terms of the GNU General Public License v2
117
118 EAPI="8"
119 @@ -18,6 +18,7 @@ HTML_DOCS=( doc/jemalloc.html )
120 PATCHES=(
121 "${FILESDIR}/${PN}-5.3.0-gentoo-fixups.patch"
122 "${FILESDIR}/${PN}-5.3.0-backport-pr-2312.patch"
123 + "${FILESDIR}/${PN}-5.3.0-backport-pr-2338.patch"
124 )
125
126 MULTILIB_WRAPPED_HEADERS=( /usr/include/jemalloc/jemalloc.h )