public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-libs/gmp/
Date: Wed, 30 Nov 2022 07:48:53 +0000 (UTC)	[thread overview]
Message-ID: <1669794493.78b4d4ebbcee12f5ef4c1dfa89f80c98a582db9d.sam@gentoo> (raw)

commit:     78b4d4ebbcee12f5ef4c1dfa89f80c98a582db9d
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Wed Nov 30 07:37:50 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Nov 30 07:48:13 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=78b4d4eb

dev-libs/gmp: pass --enable-fat for x86 (includes more asm)

Vanilla (_not_ from an ebuild) gmp will probe CHOST and then
deduce its *own* tuple based on the currently used CPU, abusing
its own custom config.guess (which our econf overwrites). This
value is used to decide which accelerated asm is compiled in (MPN_PATH).

In ebuilds, we override and refresh config.guess and friends because
it's a common portability problem to have stale versions which don't
even recognise e.g. riscv as an arch. But gmp's non-standard use
of these files poses a problem for us.

We can't simply resort to just not refreshing/changing the files
because we need to be able to build binary packages on a system
without them being super specific to the machine they were built
on with no way of controlling it (we may want to look at a USE
flag for this going forward though).

For now, we can use --enable-fat which produces a generic libgmp
which can load various asm at runtime based on the CPU in use - success!

Unfortunately, --enable-fat only does anything on x86 for the time
being, so !x86 is still in the same situation as before this commit,
but this is progress at least.

Thanks goes to Nikita Zlobin <nick87720z <AT> gmail.com> for noticing
the problem originally (and being persistent with investigating it).

Temporarily unkeyworded until I can test this a bit more.

Bug: https://bugs.gentoo.org/883201
Signed-off-by: Sam James <sam <AT> gentoo.org>

 dev-libs/gmp/gmp-6.2.1-r3.ebuild | 130 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 130 insertions(+)

diff --git a/dev-libs/gmp/gmp-6.2.1-r3.ebuild b/dev-libs/gmp/gmp-6.2.1-r3.ebuild
new file mode 100644
index 000000000000..840288dd1207
--- /dev/null
+++ b/dev-libs/gmp/gmp-6.2.1-r3.ebuild
@@ -0,0 +1,130 @@
+# Copyright 1999-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit libtool multilib-minimal toolchain-funcs
+
+MY_PV=${PV/_p*}
+MY_PV=${MY_PV/_/-}
+
+MANUAL_PV=${MY_PV}
+MANUAL_PV=6.2.1
+
+MY_P=${PN}-${MY_PV}
+PLEVEL=${PV/*p}
+
+DESCRIPTION="Library for arbitrary-precision arithmetic on different type of numbers"
+HOMEPAGE="https://gmplib.org/"
+SRC_URI="ftp://ftp.gmplib.org/pub/${MY_P}/${MY_P}.tar.xz
+	mirror://gnu/${PN}/${MY_P}.tar.xz
+	doc? ( https://gmplib.org/${PN}-man-${MANUAL_PV}.pdf )"
+SRC_URI+=" https://dev.gentoo.org/~sam/distfiles/${CATEGORY}/${PN}/${P}-arm64-darwin.patch.bz2"
+S="${WORKDIR}"/${MY_P%a}
+
+LICENSE="|| ( LGPL-3+ GPL-2+ )"
+# The subslot reflects the C & C++ SONAMEs.
+SLOT="0/10.4"
+# Unkeyworded temporarily for some more testing
+#KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
+IUSE="+asm doc +cxx pic static-libs"
+
+BDEPEND="
+	app-arch/xz-utils
+	sys-devel/m4
+"
+
+DOCS=( AUTHORS ChangeLog NEWS README doc/configuration doc/isa_abi_headache )
+HTML_DOCS=( doc )
+
+MULTILIB_WRAPPED_HEADERS=( /usr/include/gmp.h )
+
+PATCHES=(
+	"${FILESDIR}"/${PN}-6.1.0-noexecstack-detect.patch
+	"${FILESDIR}"/${PN}-6.2.1-no-zarch.patch
+	"${WORKDIR}"/${P}-arm64-darwin.patch
+	"${FILESDIR}"/${P}-CVE-2021-43618.patch
+)
+
+src_prepare() {
+	default
+
+	# We cannot run autotools here as gcc depends on this package
+	elibtoolize
+
+	# bug #536894
+	if [[ ${CHOST} == *-darwin* ]] ; then
+		eapply "${FILESDIR}"/${PN}-6.1.2-gcc-apple-4.0.1.patch
+	fi
+
+	# GMP uses the "ABI" env var during configure as does Gentoo (econf).
+	# So, to avoid patching the source constantly, wrap things up.
+	mv configure configure.wrapped || die
+	cat <<-\EOF > configure
+	#!/usr/bin/env sh
+	exec env ABI="${GMPABI}" "$0.wrapped" "$@"
+	EOF
+
+	# Patches to original configure might have lost the +x bit.
+	chmod a+rx configure{,.wrapped} || die
+}
+
+multilib_src_configure() {
+	# Because of our 32-bit userland, 1.0 is the only HPPA ABI that works
+	# https://gmplib.org/manual/ABI-and-ISA.html#ABI-and-ISA (bug #344613)
+	if [[ ${CHOST} == hppa2.0-* ]] ; then
+		GMPABI="1.0"
+	fi
+
+	# ABI mappings (needs all architectures supported)
+	case ${ABI} in
+		32|x86)       GMPABI=32;;
+		64|amd64|n64) GMPABI=64;;
+		[onx]32)      GMPABI=${ABI};;
+	esac
+	export GMPABI
+
+	tc-export CC
+
+	local myeconfargs=(
+		CC_FOR_BUILD="$(tc-getBUILD_CC)"
+
+		--localstatedir="${EPREFIX}"/var/state/gmp
+		--enable-shared
+
+		# fat is needed to avoid gmp installing either purely generic
+		# or specific-to-used-CPU (which our config.guess refresh prevents at the moment).
+		# Both Fedora and opensuse use this option to tackle the issue, bug #883201.
+		#
+		# This only works for x86, so we're still getting non-performant
+		# builds on other arches until we figure something out!
+		$(use_enable asm fat)
+		$(use_enable asm assembly)
+		$(use_enable cxx)
+		$(use_enable static-libs static)
+
+		# --with-pic forces static libraries to be built as PIC
+		# and without TEXTRELs. musl does not support TEXTRELs: bug #707332
+		$(use pic && echo --with-pic)
+	)
+
+	ECONF_SOURCE="${S}" econf "${myeconfargs[@]}"
+}
+
+multilib_src_install() {
+	emake DESTDIR="${D}" install
+
+	# Should be a standalone lib
+	rm -f "${ED}"/usr/$(get_libdir)/libgmp.la
+
+	# This requires libgmp
+	local la="${ED}/usr/$(get_libdir)/libgmpxx.la"
+	if ! use static-libs ; then
+		rm -f "${la}" || die
+	fi
+}
+
+multilib_src_install_all() {
+	einstalldocs
+	use doc && cp "${DISTDIR}"/gmp-man-${MANUAL_PV}.pdf "${ED}"/usr/share/doc/${PF}/
+}


             reply	other threads:[~2022-11-30  7:49 UTC|newest]

Thread overview: 127+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-30  7:48 Sam James [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-12-06 13:10 [gentoo-commits] repo/gentoo:master commit in: dev-libs/gmp/ Sam James
2024-12-06 13:06 Sam James
2024-11-18 14:28 Sam James
2023-12-15  3:25 Sam James
2023-09-24 15:44 Arthur Zamarin
2023-09-08 23:30 Andreas K. Hüttel
2023-09-07 23:27 Sam James
2023-09-07 23:03 Sam James
2023-09-07 23:03 Sam James
2023-09-07 20:53 Sam James
2023-09-07 20:53 Sam James
2023-09-07 20:53 Sam James
2023-09-07 20:53 Sam James
2023-07-30 17:01 Sam James
2023-07-30 13:49 Sam James
2023-05-08  7:36 Sam James
2023-05-07 23:54 Sam James
2023-01-28 19:07 Arthur Zamarin
2023-01-27 10:11 Jakov Smolić
2023-01-27  6:31 Sam James
2023-01-27  6:31 Sam James
2023-01-27  6:27 Sam James
2023-01-27  6:27 Sam James
2023-01-27  6:23 Sam James
2022-12-16  7:18 Sam James
2022-12-06 10:53 Sam James
2022-11-30  8:31 Sam James
2022-11-30  7:48 Sam James
2022-01-02  9:13 David Seifert
2021-12-22  0:42 Sam James
2021-12-17 12:00 Sam James
2021-12-17 12:00 Sam James
2021-12-17  9:20 Jakov Smolić
2021-12-17  9:20 Jakov Smolić
2021-12-17  7:55 Arthur Zamarin
2021-12-17  7:33 Arthur Zamarin
2021-12-17  7:33 Arthur Zamarin
2021-10-29  8:49 Sam James
2021-04-24 12:37 Sergei Trofimovich
2021-04-11 18:41 Sergei Trofimovich
2021-04-04 21:21 Sergei Trofimovich
2021-04-02 14:14 Sam James
2021-04-02 14:14 Sam James
2021-04-02 14:10 Sam James
2021-04-02 14:09 Sam James
2021-04-02 14:08 Sam James
2021-04-02 14:07 Sam James
2020-12-25 12:17 Sergei Trofimovich
2020-12-23 13:57 Sergei Trofimovich
2020-12-22  6:29 Sam James
2020-12-21 18:01 Sam James
2020-12-21  9:41 Sergei Trofimovich
2020-12-20 20:03 Sam James
2020-12-20 16:30 Thomas Deutschmann
2020-12-20 12:56 Sergei Trofimovich
2020-12-20  6:33 Sam James
2020-12-18 14:25 Sam James
2020-11-15 10:24 Sergei Trofimovich
2020-06-10 18:22 Sergei Trofimovich
2020-05-02 17:51 Sergei Trofimovich
2020-04-05 20:06 Mart Raudsepp
2020-04-01 11:17 Jeroen Roovers
2020-03-29 20:16 Sergei Trofimovich
2020-03-29 10:13 Sergei Trofimovich
2020-03-29 10:13 Sergei Trofimovich
2020-03-26 21:47 Sergei Trofimovich
2020-03-23 23:58 Sergei Trofimovich
2020-03-23 18:23 Sergei Trofimovich
2020-03-22 14:35 Agostino Sarubbo
2020-03-22 14:30 Agostino Sarubbo
2020-03-22 11:08 Agostino Sarubbo
2020-03-22 11:07 Agostino Sarubbo
2020-03-22 10:56 Agostino Sarubbo
2020-03-22 10:55 Agostino Sarubbo
2020-03-22 10:54 Agostino Sarubbo
2020-03-22 10:53 Agostino Sarubbo
2020-01-31  7:57 Sergei Trofimovich
2020-01-30 11:23 Sergei Trofimovich
2020-01-19 12:24 Sergei Trofimovich
2019-09-21 18:09 Matt Turner
2019-09-20  6:39 Sergei Trofimovich
2019-09-16  6:52 Agostino Sarubbo
2019-09-13 18:31 Mikle Kolyada
2019-09-13  7:45 Agostino Sarubbo
2019-09-10  7:10 Agostino Sarubbo
2019-09-10  7:00 Sergei Trofimovich
2019-09-10  6:56 Sergei Trofimovich
2019-09-10  6:51 Sergei Trofimovich
2019-09-09 20:56 Aaron Bauman
2019-09-09 17:23 Agostino Sarubbo
2019-05-04 14:53 Andreas K. Hüttel
2019-02-05 22:19 Sergei Trofimovich
2019-02-05 21:37 Sergei Trofimovich
2018-06-10 16:29 Sergei Trofimovich
2018-04-15 17:52 Sergei Trofimovich
2018-01-13 23:22 Mike Frysinger
2017-11-27  7:27 Sergei Trofimovich
2017-11-27  0:20 Thomas Deutschmann
2017-11-26 19:06 Sergei Trofimovich
2017-11-26  1:30 Matt Turner
2017-11-25 20:02 Matt Turner
2017-11-25 12:10 Sergei Trofimovich
2017-05-06 22:20 David Seifert
2017-01-29 16:08 Fabian Groffen
2016-12-20 17:21 Fabian Groffen
2016-12-20 14:18 Fabian Groffen
2016-12-19 18:28 Mike Frysinger
2016-12-08 16:47 Mike Frysinger
2016-11-14 14:50 Mike Frysinger
2016-07-03 19:21 Jeroen Roovers
2016-07-03 11:03 Jeroen Roovers
2016-06-30 14:47 Tobias Klausmann
2016-06-26 18:46 Markus Meier
2016-06-21  2:17 Mike Frysinger
2016-06-21  2:17 Mike Frysinger
2015-11-08 17:38 Mike Frysinger
2015-11-05 17:20 Mike Frysinger
2015-10-29  0:49 Mike Frysinger
2015-10-24 16:18 Mike Frysinger
2015-10-24 16:14 Mike Frysinger
2015-10-24 16:08 Mike Frysinger
2015-10-10 15:34 Mikle Kolyada
2015-10-04 10:14 Agostino Sarubbo
2015-10-04  9:42 Agostino Sarubbo
2015-10-03 18:24 Anthony G. Basile
2015-10-03 18:18 Jeroen Roovers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1669794493.78b4d4ebbcee12f5ef4c1dfa89f80c98a582db9d.sam@gentoo \
    --to=sam@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox