1 |
commit: dd53c589c7aa7c42624b0053ec4523ac2015a7ac |
2 |
Author: Sam James <sam <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Oct 27 05:31:46 2021 +0000 |
4 |
Commit: Sam James <sam <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Oct 27 05:34:03 2021 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=dd53c589 |
7 |
|
8 |
dev-util/google-perftools: add Fedora TLS patch for arm64 |
9 |
|
10 |
Use Fedora's TLS (thread local storage) patch to fix segfaults |
11 |
in consumers on e.g. arm64. We also apply the new |
12 |
configure option on s390 as Fedora do, but there might |
13 |
be other arches where this is needed. |
14 |
|
15 |
Bug: https://bugs.gentoo.org/818871 |
16 |
Signed-off-by: Sam James <sam <AT> gentoo.org> |
17 |
|
18 |
...rftools-2.9.1-disable-generic-dynamic-tls.patch | 34 +++++++ |
19 |
.../google-perftools-2.9.1-r1.ebuild | 111 +++++++++++++++++++++ |
20 |
2 files changed, 145 insertions(+) |
21 |
|
22 |
diff --git a/dev-util/google-perftools/files/google-perftools-2.9.1-disable-generic-dynamic-tls.patch b/dev-util/google-perftools/files/google-perftools-2.9.1-disable-generic-dynamic-tls.patch |
23 |
new file mode 100644 |
24 |
index 00000000000..8e72c6dcd0a |
25 |
--- /dev/null |
26 |
+++ b/dev-util/google-perftools/files/google-perftools-2.9.1-disable-generic-dynamic-tls.patch |
27 |
@@ -0,0 +1,34 @@ |
28 |
+Grabbed from Fedora: https://src.fedoraproject.org/rpms/gperftools/blob/rawhide/f/gperftools-2.7.90-disable-generic-dynamic-tls.patch |
29 |
+ |
30 |
+Allows consumers to work correctly on arm64. |
31 |
+--- a/configure.ac |
32 |
++++ b/configure.ac |
33 |
+@@ -665,6 +665,17 @@ AS_IF([test "x$enable_aggressive_decommi |
34 |
+ 1, |
35 |
+ [enable aggressive decommit by default])]) |
36 |
+ |
37 |
++# Enable generic dynamic TLS model by default |
38 |
++default_enable_generic_dynamic_tls=yes |
39 |
++AC_ARG_ENABLE([general-dynamic-tls], |
40 |
++ [AS_HELP_STRING([--disable-general-dynamic-tls], |
41 |
++ [Do not use the general dynamic TLS model])], |
42 |
++ [], |
43 |
++ [enable_generic_dynamic_tls="$default_enable_generic_dynamic_tls"]) |
44 |
++AS_IF([test "x$enable_generic_dynamic_tls" = xyes], |
45 |
++ [AC_DEFINE([ENABLE_GENERIC_DYNAMIC_TLS], 1, |
46 |
++ [Use the generic dynamic TLS model])]) |
47 |
++ |
48 |
+ # Write generated configuration file |
49 |
+ AC_CONFIG_FILES([Makefile |
50 |
+ src/gperftools/tcmalloc.h src/windows/gperftools/tcmalloc.h]) |
51 |
+--- a/src/base/basictypes.h |
52 |
++++ b/src/base/basictypes.h |
53 |
+@@ -200,7 +200,7 @@ struct CompileAssert { |
54 |
+ # define ATTRIBUTE_UNUSED |
55 |
+ #endif |
56 |
+ |
57 |
+-#if defined(HAVE___ATTRIBUTE__) && defined(HAVE_TLS) |
58 |
++#if defined(HAVE___ATTRIBUTE__) && defined(HAVE_TLS) && defined(ENABLE_GENERIC_DYNAMIC_TLS) |
59 |
+ #define ATTR_INITIAL_EXEC __attribute__ ((tls_model ("initial-exec"))) |
60 |
+ #else |
61 |
+ #define ATTR_INITIAL_EXEC |
62 |
|
63 |
diff --git a/dev-util/google-perftools/google-perftools-2.9.1-r1.ebuild b/dev-util/google-perftools/google-perftools-2.9.1-r1.ebuild |
64 |
new file mode 100644 |
65 |
index 00000000000..ed4a219b335 |
66 |
--- /dev/null |
67 |
+++ b/dev-util/google-perftools/google-perftools-2.9.1-r1.ebuild |
68 |
@@ -0,0 +1,111 @@ |
69 |
+# Copyright 1999-2021 Gentoo Authors |
70 |
+# Distributed under the terms of the GNU General Public License v2 |
71 |
+ |
72 |
+EAPI=7 |
73 |
+ |
74 |
+MY_P="gperftools-${PV}" |
75 |
+inherit toolchain-funcs flag-o-matic autotools vcs-snapshot multilib-minimal |
76 |
+ |
77 |
+DESCRIPTION="Fast, multi-threaded malloc() and nifty performance analysis tools" |
78 |
+HOMEPAGE="https://github.com/gperftools/gperftools" |
79 |
+SRC_URI="https://github.com/gperftools/gperftools/archive/${MY_P}.tar.gz" |
80 |
+ |
81 |
+LICENSE="MIT" |
82 |
+SLOT="0/4" |
83 |
+# contains ASM code, with support for |
84 |
+# freebsd x86/amd64 |
85 |
+# linux amd64/arm/arm64/ppc/ppc64/riscv/x86 |
86 |
+# OSX ppc/amd64 |
87 |
+# AIX ppc/ppc64 |
88 |
+KEYWORDS="-* ~amd64 ~arm ~arm64 ~ppc ~ppc64 ~riscv ~x86 ~amd64-linux ~x86-linux" |
89 |
+ |
90 |
+IUSE="largepages largepages64k +debug minimal optimisememory test static-libs" |
91 |
+ |
92 |
+RESTRICT="!test? ( test )" |
93 |
+ |
94 |
+# TODO: remove the riscv special case once either libunwind has begun supporting this arch |
95 |
+# or this package allows using llvm-libunwind for other arches |
96 |
+DEPEND="!ppc64? ( |
97 |
+ riscv? ( sys-libs/llvm-libunwind:= ) |
98 |
+ !riscv? ( sys-libs/libunwind:= ) |
99 |
+)" |
100 |
+RDEPEND="${DEPEND}" |
101 |
+ |
102 |
+S="${WORKDIR}/${MY_P}" |
103 |
+ |
104 |
+PATCHES=( |
105 |
+ # Please keep this if possible on bumps, check Fedora if needs rebasing |
106 |
+ # Allows correct functionality on e.g. arm64, bug #818871 |
107 |
+ "${FILESDIR}"/${PN}-2.9.1-disable-generic-dynamic-tls.patch |
108 |
+) |
109 |
+ |
110 |
+pkg_setup() { |
111 |
+ # set up the make options in here so that we can actually make use |
112 |
+ # of them on both compile and install. |
113 |
+ |
114 |
+ # Avoid building the unit testing if we're not going to execute |
115 |
+ # tests; this trick here allows us to ignore the tests without |
116 |
+ # touching the build system (and thus without rebuilding |
117 |
+ # autotools). Keep commented as long as it's restricted. |
118 |
+ use test || \ |
119 |
+ MAKEOPTS+=" noinst_PROGRAMS= " |
120 |
+} |
121 |
+ |
122 |
+src_prepare() { |
123 |
+ default |
124 |
+ |
125 |
+ eautoreconf |
126 |
+ multilib_copy_sources |
127 |
+} |
128 |
+ |
129 |
+multilib_src_configure() { |
130 |
+ use largepages && append-cppflags -DTCMALLOC_LARGE_PAGES |
131 |
+ use largepages64k && append-cppflags -DTCMALLOC_LARGE_PAGES64K |
132 |
+ use optimisememory && append-cppflags -DTCMALLOC_SMALL_BUT_SLOW |
133 |
+ append-flags -fno-strict-aliasing -fno-omit-frame-pointer |
134 |
+ |
135 |
+ local myconfargs=( |
136 |
+ --enable-shared |
137 |
+ $(use_enable static-libs static) |
138 |
+ $(use_enable debug debugalloc) |
139 |
+ $(if [[ ${ABI} == x32 ]]; then printf "--enable-minimal\n" else use_enable minimal; fi) |
140 |
+ ) |
141 |
+ |
142 |
+ if use arm64 || use s390; then |
143 |
+ # Use the same arches for disabling TLS (thread local storage) |
144 |
+ # as Fedora, but we might need to expand this list if we get |
145 |
+ # more odd segfaults in consumers like in bug #818871. |
146 |
+ myeconfargs+=( --disable-general-dynamic-tls ) |
147 |
+ fi |
148 |
+ |
149 |
+ econf "${myconfargs[@]}" |
150 |
+} |
151 |
+ |
152 |
+src_test() { |
153 |
+ if has sandbox ${FEATURES}; then |
154 |
+ ewarn "Unable to run tests when sandbox is enabled." |
155 |
+ ewarn "See https://bugs.gentoo.org/290249" |
156 |
+ return 0 |
157 |
+ fi |
158 |
+ |
159 |
+ multilib-minimal_src_test |
160 |
+} |
161 |
+ |
162 |
+src_install() { |
163 |
+ if ! use minimal && has x32 ${MULTILIB_ABIS}; then |
164 |
+ MULTILIB_WRAPPED_HEADERS=( |
165 |
+ /usr/include/gperftools/heap-checker.h |
166 |
+ /usr/include/gperftools/heap-profiler.h |
167 |
+ /usr/include/gperftools/stacktrace.h |
168 |
+ /usr/include/gperftools/profiler.h |
169 |
+ ) |
170 |
+ fi |
171 |
+ |
172 |
+ multilib-minimal_src_install |
173 |
+} |
174 |
+ |
175 |
+multilib_src_install_all() { |
176 |
+ einstalldocs |
177 |
+ |
178 |
+ use static-libs || find "${ED}" -name '*.la' -delete || die |
179 |
+} |