summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam James <sam@gentoo.org>2021-10-27 06:31:46 +0100
committerSam James <sam@gentoo.org>2021-10-27 06:34:03 +0100
commitdd53c589c7aa7c42624b0053ec4523ac2015a7ac (patch)
tree61ec11ae8bae6f34e35202044840b5a08eba6c00 /dev-util/google-perftools
parentdev-util/git-delta: add 0.9.1 (diff)
downloadgentoo-dd53c589c7aa7c42624b0053ec4523ac2015a7ac.tar.gz
gentoo-dd53c589c7aa7c42624b0053ec4523ac2015a7ac.tar.bz2
gentoo-dd53c589c7aa7c42624b0053ec4523ac2015a7ac.zip
dev-util/google-perftools: add Fedora TLS patch for arm64
Use Fedora's TLS (thread local storage) patch to fix segfaults in consumers on e.g. arm64. We also apply the new configure option on s390 as Fedora do, but there might be other arches where this is needed. Bug: https://bugs.gentoo.org/818871 Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'dev-util/google-perftools')
-rw-r--r--dev-util/google-perftools/files/google-perftools-2.9.1-disable-generic-dynamic-tls.patch34
-rw-r--r--dev-util/google-perftools/google-perftools-2.9.1-r1.ebuild111
2 files changed, 145 insertions, 0 deletions
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
new file mode 100644
index 000000000000..8e72c6dcd0a5
--- /dev/null
+++ b/dev-util/google-perftools/files/google-perftools-2.9.1-disable-generic-dynamic-tls.patch
@@ -0,0 +1,34 @@
+Grabbed from Fedora: https://src.fedoraproject.org/rpms/gperftools/blob/rawhide/f/gperftools-2.7.90-disable-generic-dynamic-tls.patch
+
+Allows consumers to work correctly on arm64.
+--- a/configure.ac
++++ b/configure.ac
+@@ -665,6 +665,17 @@ AS_IF([test "x$enable_aggressive_decommi
+ 1,
+ [enable aggressive decommit by default])])
+
++# Enable generic dynamic TLS model by default
++default_enable_generic_dynamic_tls=yes
++AC_ARG_ENABLE([general-dynamic-tls],
++ [AS_HELP_STRING([--disable-general-dynamic-tls],
++ [Do not use the general dynamic TLS model])],
++ [],
++ [enable_generic_dynamic_tls="$default_enable_generic_dynamic_tls"])
++AS_IF([test "x$enable_generic_dynamic_tls" = xyes],
++ [AC_DEFINE([ENABLE_GENERIC_DYNAMIC_TLS], 1,
++ [Use the generic dynamic TLS model])])
++
+ # Write generated configuration file
+ AC_CONFIG_FILES([Makefile
+ src/gperftools/tcmalloc.h src/windows/gperftools/tcmalloc.h])
+--- a/src/base/basictypes.h
++++ b/src/base/basictypes.h
+@@ -200,7 +200,7 @@ struct CompileAssert {
+ # define ATTRIBUTE_UNUSED
+ #endif
+
+-#if defined(HAVE___ATTRIBUTE__) && defined(HAVE_TLS)
++#if defined(HAVE___ATTRIBUTE__) && defined(HAVE_TLS) && defined(ENABLE_GENERIC_DYNAMIC_TLS)
+ #define ATTR_INITIAL_EXEC __attribute__ ((tls_model ("initial-exec")))
+ #else
+ #define ATTR_INITIAL_EXEC
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
new file mode 100644
index 000000000000..ed4a219b335d
--- /dev/null
+++ b/dev-util/google-perftools/google-perftools-2.9.1-r1.ebuild
@@ -0,0 +1,111 @@
+# Copyright 1999-2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+MY_P="gperftools-${PV}"
+inherit toolchain-funcs flag-o-matic autotools vcs-snapshot multilib-minimal
+
+DESCRIPTION="Fast, multi-threaded malloc() and nifty performance analysis tools"
+HOMEPAGE="https://github.com/gperftools/gperftools"
+SRC_URI="https://github.com/gperftools/gperftools/archive/${MY_P}.tar.gz"
+
+LICENSE="MIT"
+SLOT="0/4"
+# contains ASM code, with support for
+# freebsd x86/amd64
+# linux amd64/arm/arm64/ppc/ppc64/riscv/x86
+# OSX ppc/amd64
+# AIX ppc/ppc64
+KEYWORDS="-* ~amd64 ~arm ~arm64 ~ppc ~ppc64 ~riscv ~x86 ~amd64-linux ~x86-linux"
+
+IUSE="largepages largepages64k +debug minimal optimisememory test static-libs"
+
+RESTRICT="!test? ( test )"
+
+# TODO: remove the riscv special case once either libunwind has begun supporting this arch
+# or this package allows using llvm-libunwind for other arches
+DEPEND="!ppc64? (
+ riscv? ( sys-libs/llvm-libunwind:= )
+ !riscv? ( sys-libs/libunwind:= )
+)"
+RDEPEND="${DEPEND}"
+
+S="${WORKDIR}/${MY_P}"
+
+PATCHES=(
+ # Please keep this if possible on bumps, check Fedora if needs rebasing
+ # Allows correct functionality on e.g. arm64, bug #818871
+ "${FILESDIR}"/${PN}-2.9.1-disable-generic-dynamic-tls.patch
+)
+
+pkg_setup() {
+ # set up the make options in here so that we can actually make use
+ # of them on both compile and install.
+
+ # Avoid building the unit testing if we're not going to execute
+ # tests; this trick here allows us to ignore the tests without
+ # touching the build system (and thus without rebuilding
+ # autotools). Keep commented as long as it's restricted.
+ use test || \
+ MAKEOPTS+=" noinst_PROGRAMS= "
+}
+
+src_prepare() {
+ default
+
+ eautoreconf
+ multilib_copy_sources
+}
+
+multilib_src_configure() {
+ use largepages && append-cppflags -DTCMALLOC_LARGE_PAGES
+ use largepages64k && append-cppflags -DTCMALLOC_LARGE_PAGES64K
+ use optimisememory && append-cppflags -DTCMALLOC_SMALL_BUT_SLOW
+ append-flags -fno-strict-aliasing -fno-omit-frame-pointer
+
+ local myconfargs=(
+ --enable-shared
+ $(use_enable static-libs static)
+ $(use_enable debug debugalloc)
+ $(if [[ ${ABI} == x32 ]]; then printf "--enable-minimal\n" else use_enable minimal; fi)
+ )
+
+ if use arm64 || use s390; then
+ # Use the same arches for disabling TLS (thread local storage)
+ # as Fedora, but we might need to expand this list if we get
+ # more odd segfaults in consumers like in bug #818871.
+ myeconfargs+=( --disable-general-dynamic-tls )
+ fi
+
+ econf "${myconfargs[@]}"
+}
+
+src_test() {
+ if has sandbox ${FEATURES}; then
+ ewarn "Unable to run tests when sandbox is enabled."
+ ewarn "See https://bugs.gentoo.org/290249"
+ return 0
+ fi
+
+ multilib-minimal_src_test
+}
+
+src_install() {
+ if ! use minimal && has x32 ${MULTILIB_ABIS}; then
+ MULTILIB_WRAPPED_HEADERS=(
+ /usr/include/gperftools/heap-checker.h
+ /usr/include/gperftools/heap-profiler.h
+ /usr/include/gperftools/stacktrace.h
+ /usr/include/gperftools/profiler.h
+ )
+ fi
+
+ multilib-minimal_src_install
+}
+
+multilib_src_install_all() {
+ einstalldocs
+
+ use static-libs || find "${ED}" -name '*.la' -delete || die
+}