gmp: upgraded package to upstream

Upgraded dev-libs/gmp to version 6.2.1-r1 on amd64, arm

BUG=chromium:1220056
TEST=FEATURES="test" emerge dev-libs/gmp

Cq-Depend: chromium:2971083
Change-Id: Iee418393ce547f109cf9ed84f9a9f1e2bf893398
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/overlays/portage-stable/+/2964179
Tested-by: Manoj Gupta <manojgupta@chromium.org>
Commit-Queue: T.J. Alumbaugh <talumbau@google.com>
Reviewed-by: Bob Brandt <brndt@google.com>
Reviewed-by: Sergey Frolov <sfrolov@google.com>
diff --git a/dev-libs/gmp/Manifest b/dev-libs/gmp/Manifest
index 173d15c..60d06ef 100644
--- a/dev-libs/gmp/Manifest
+++ b/dev-libs/gmp/Manifest
@@ -1,2 +1,2 @@
-DIST gmp-6.1.2.tar.xz 1946336 SHA256 87b565e89a9a684fe4ebeeddb8399dce2599f9c9049854ca8c0dfbdea0e21912 SHA512 9f098281c0593b76ee174b722936952671fab1dae353ce3ed436a31fe2bc9d542eca752353f6645b7077c1f395ab4fdd355c58e08e2a801368f1375690eee2c6 WHIRLPOOL 1f4be0fcb5868cc5e3f5e699e51da0d52cdb131906468f5401a40ae145dad2d48935b87330b786fff2a2f593d6f39542c4d5fb7bef5922817ae61ff57870951d
-DIST gmp-man-6.1.2.pdf 825720 SHA256 f78f18ac0b0e56920920af0209415a4b371b7b101ceaa03739a31bfe3c2888f8 SHA512 85de10b2c03f7381881c3e95aa7fc53d8e018115028496ffbb5a79ab4967106c69ed7e97a5e434e6bb39752498aade8c2caa7cf77a8942b7ffd9150368a0d9c3 WHIRLPOOL d952544d178c7d970ec3c1b080191603326a2c77523c27f03f80bc03b9a8910a0093c3f6990640aa596d45adb8fa34a7ef3c9c35abf60945c43c533499052ce0
+DIST gmp-6.2.1.tar.xz 2027316 BLAKE2B c0d85f175392a50cfa01bc6b0a312b235946ad8b4f6f84f6dabd33d7a6f2cc75c9b0e1e33057be07750bfa0145b7c4cf3b6188a5be6ca9d7271ec2276c84ebcb SHA512 c99be0950a1d05a0297d65641dd35b75b74466f7bf03c9e8a99895a3b2f9a0856cd17887738fa51cf7499781b65c049769271cbcb77d057d2e9f1ec52e07dd84
+DIST gmp-man-6.2.0.pdf 828998 BLAKE2B 0bf56bf0a6f1aac0e1fb9a5a37552f846a2d4a01bfd3f5b5c531d42a9afc48c19552e08971785805f59e3f2a5fd89e3f986f841dca2e340813596cfd76574e61 SHA512 25d129efedd329cd2d4535557c6912191f587bfd8ef028618b4ca6199ec7bf7a9ae862e7f5e5b5448c86888452a39fc7bf95cf9c18311858dd1aa9ae1c716239
diff --git a/dev-libs/gmp/files/gmp-6.1.2-gcc-apple-4.0.1.patch b/dev-libs/gmp/files/gmp-6.1.2-gcc-apple-4.0.1.patch
new file mode 100644
index 0000000..8960464
--- /dev/null
+++ b/dev-libs/gmp/files/gmp-6.1.2-gcc-apple-4.0.1.patch
@@ -0,0 +1,21 @@
+--- gmp-6.0.0/gmp-h.in.orig	2015-01-16 22:25:51.000000000 +0100
++++ gmp-6.0.0/gmp-h.in	2015-01-16 22:26:40.000000000 +0100
+@@ -360,14 +360,14 @@
+     GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99
+     inline semantics, unless -fgnu89-inline is used.  */
+ #ifdef __GNUC__
+-#if (defined __GNUC_STDC_INLINE__) || (__GNUC__ == 4 && __GNUC_MINOR__ == 2) \
+-  || (defined __GNUC_GNU_INLINE__ && defined __cplusplus)
++#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)
+ #define __GMP_EXTERN_INLINE extern __inline__ __attribute__ ((__gnu_inline__))
+-#else
++#define __GMP_INLINE_PROTOTYPES  1
++#elif !(defined __APPLE__ && defined __MACH__ && __APPLE_CC__ >= 5465 && __STDC_VERSION__ >= 199901L)
+ #define __GMP_EXTERN_INLINE      extern __inline__
+-#endif
+ #define __GMP_INLINE_PROTOTYPES  1
+ #endif
++#endif
+ 
+ /* DEC C (eg. version 5.9) supports "static __inline foo()", even in -std1
+    strict ANSI mode.  Inlining is done even when not optimizing (ie. -O0
diff --git a/dev-libs/gmp/files/gmp-6.2.1-no-zarch.patch b/dev-libs/gmp/files/gmp-6.2.1-no-zarch.patch
new file mode 100644
index 0000000..6ba7c8a
--- /dev/null
+++ b/dev-libs/gmp/files/gmp-6.2.1-no-zarch.patch
@@ -0,0 +1,20 @@
+configure.ac decides whether udiv_w_sdiv.c fallback is needed
+based on $CHOST value (without $CFLAGS). longlong.h relies
+on compiler macros (relies on $CFLAGS implicitly).
+
+That leads to use of undefined macros. The workaround makes
+udiv_w_sdiv.c a no-on for -mzarch.
+
+https://bugs.gentoo.org/761310
+--- a/mpn/generic/udiv_w_sdiv.c
++++ b/mpn/generic/udiv_w_sdiv.c
+@@ -1,3 +1,4 @@
++#if !defined(__zarch__)
+ /* mpn_udiv_w_sdiv -- implement udiv_qrnnd on machines with only signed
+    division.
+ 
+@@ -139,3 +140,4 @@ mpn_udiv_w_sdiv (mp_limb_t *rp, mp_limb_t a1, mp_limb_t a0, mp_limb_t d)
+   *rp = r;
+   return q;
+ }
++#endif
diff --git a/dev-libs/gmp/gmp-6.1.2-r3.ebuild b/dev-libs/gmp/gmp-6.1.2-r3.ebuild
deleted file mode 120000
index d6dc0a3..0000000
--- a/dev-libs/gmp/gmp-6.1.2-r3.ebuild
+++ /dev/null
@@ -1 +0,0 @@
-gmp-6.1.2.ebuild
\ No newline at end of file
diff --git a/dev-libs/gmp/gmp-6.1.2.ebuild b/dev-libs/gmp/gmp-6.2.1-r1.ebuild
similarity index 65%
rename from dev-libs/gmp/gmp-6.1.2.ebuild
rename to dev-libs/gmp/gmp-6.2.1-r1.ebuild
index 4692e0b..b234a24 100644
--- a/dev-libs/gmp/gmp-6.1.2.ebuild
+++ b/dev-libs/gmp/gmp-6.2.1-r1.ebuild
@@ -1,29 +1,30 @@
-# Copyright 1999-2018 Gentoo Foundation
+# Copyright 1999-2021 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
-EAPI="5"
+EAPI=7
 
-inherit flag-o-matic eutils libtool multilib-minimal toolchain-funcs
+inherit flag-o-matic libtool multilib-minimal toolchain-funcs
 
 MY_PV=${PV/_p*}
 MY_PV=${MY_PV/_/-}
+MANUAL_PV=$MY_PV
+MANUAL_PV=6.2.0 # 6.2.1 manual is not ready yet
 MY_P=${PN}-${MY_PV}
 PLEVEL=${PV/*p}
 DESCRIPTION="Library for arbitrary-precision arithmetic on different type of numbers"
-HOMEPAGE="http://gmplib.org/"
+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? ( http://gmplib.org/${PN}-man-${MY_PV}.pdf )"
+	doc? ( https://gmplib.org/${PN}-man-${MANUAL_PV}.pdf )"
 
 LICENSE="|| ( LGPL-3+ GPL-2+ )"
 # The subslot reflects the C & C++ SONAMEs.
 SLOT="0/10.4"
 KEYWORDS="*"
-IUSE="+asm doc cxx pgo static-libs"
+IUSE="+asm doc +cxx pic static-libs"
 
-DEPEND="sys-devel/m4
+BDEPEND="sys-devel/m4
 	app-arch/xz-utils"
-RDEPEND=""
 
 S=${WORKDIR}/${MY_P%a}
 
@@ -31,17 +32,20 @@
 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
+)
+
 src_prepare() {
-	[[ -d ${FILESDIR}/${PV} ]] && EPATCH_SUFFIX="diff" EPATCH_FORCE="yes" epatch "${FILESDIR}"/${PV}
+	default
 
 	# note: we cannot run autotools here as gcc depends on this package
 	elibtoolize
 
-	epatch "${FILESDIR}"/${PN}-6.1.0-noexecstack-detect.patch
-
 	# https://bugs.gentoo.org/536894
 	if [[ ${CHOST} == *-darwin* ]] ; then
-		epatch "${FILESDIR}"/${PN}-6.1.2-gcc-apple-4.0.1.patch
+		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).
@@ -52,12 +56,12 @@
 	exec env ABI="${GMPABI}" "$0.wrapped" "$@"
 	EOF
 	# Patches to original configure might have lost the +x bit.
-	chmod a+rx configure{,.wrapped}
+	chmod a+rx configure{,.wrapped} || die
 }
 
 multilib_src_configure() {
 	# Because of our 32-bit userland, 1.0 is the only HPPA ABI that works
-	# http://gmplib.org/manual/ABI-and-ISA.html#ABI-and-ISA (bug #344613)
+	# https://gmplib.org/manual/ABI-and-ISA.html#ABI-and-ISA (bug #344613)
 	if [[ ${CHOST} == hppa2.0-* ]] ; then
 		GMPABI="1.0"
 	fi
@@ -75,6 +79,8 @@
 		filter-flags -O?
 	fi
 
+	# --with-pic forces static libraries to be built as PIC
+	# and without TEXTRELs. musl does not support TEXTRELs: bug #707332
 	tc-export CC
 	ECONF_SOURCE="${S}" econf \
 		CC_FOR_BUILD="$(tc-getBUILD_CC)" \
@@ -82,28 +88,10 @@
 		--enable-shared \
 		$(use_enable asm assembly) \
 		$(use_enable cxx) \
+		$(use pic && echo --with-pic) \
 		$(use_enable static-libs static)
 }
 
-multilib_src_compile() {
-	emake
-
-	if use pgo ; then
-		emake -j1 -C tune tuneup
-		ebegin "Trying to generate tuned data"
-		./tune/tuneup | tee gmp.mparam.h.new
-		if eend $(( 0 + ${PIPESTATUS[*]/#/+} )) ; then
-			mv gmp.mparam.h.new gmp-mparam.h || die
-			emake clean
-			emake
-		fi
-	fi
-}
-
-multilib_src_test() {
-	emake check
-}
-
 multilib_src_install() {
 	emake DESTDIR="${D}" install
 
@@ -111,12 +99,10 @@
 	rm -f "${ED}"/usr/$(get_libdir)/libgmp.la
 	# this requires libgmp
 	local la="${ED}/usr/$(get_libdir)/libgmpxx.la"
-	use static-libs \
-		&& sed -i 's:/[^ ]*/libgmp.la:-lgmp:' "${la}" \
-		|| rm -f "${la}"
+	use static-libs || rm -f "${la}"
 }
 
 multilib_src_install_all() {
 	einstalldocs
-	use doc && cp "${DISTDIR}"/gmp-man-${MY_PV}.pdf "${ED}"/usr/share/doc/${PF}/
+	use doc && cp "${DISTDIR}"/gmp-man-${MANUAL_PV}.pdf "${ED}"/usr/share/doc/${PF}/
 }
diff --git a/dev-libs/gmp/metadata.xml b/dev-libs/gmp/metadata.xml
index 7904a0b..2b4236a 100644
--- a/dev-libs/gmp/metadata.xml
+++ b/dev-libs/gmp/metadata.xml
@@ -7,7 +7,7 @@
 </maintainer>
 <use>
 	<flag name="asm">Enable use of hand optimized assembly routines (faster execution)</flag>
-	<flag name="pgo">After building gmp, run some tests against to produce faster libraries -- this option will double the compile time</flag>
+	<flag name="pic">Force static libraries to be built as PIC to avoid TEXTRELs.</flag>
 </use>
 <upstream>
 	<remote-id type="cpe">cpe:/a:gmplib:gmp</remote-id>
diff --git a/metadata/md5-cache/dev-libs/gmp-6.1.2 b/metadata/md5-cache/dev-libs/gmp-6.1.2
deleted file mode 100644
index 05f80fc..0000000
--- a/metadata/md5-cache/dev-libs/gmp-6.1.2
+++ /dev/null
@@ -1,12 +0,0 @@
-DEFINED_PHASES=compile configure install prepare test
-DEPEND=sys-devel/m4 app-arch/xz-utils >=app-portage/elt-patches-20170815
-DESCRIPTION=Library for arbitrary-precision arithmetic on different type of numbers
-EAPI=5
-HOMEPAGE=http://gmplib.org/
-IUSE=+asm doc cxx pgo static-libs abi_x86_32 abi_x86_64 abi_x86_x32 abi_mips_n32 abi_mips_n64 abi_mips_o32 abi_ppc_32 abi_ppc_64 abi_s390_32 abi_s390_64 abi_arm_32 abi_arm_64
-KEYWORDS=*
-LICENSE=|| ( LGPL-3+ GPL-2+ )
-SLOT=0/10.4
-SRC_URI=ftp://ftp.gmplib.org/pub/gmp-6.1.2/gmp-6.1.2.tar.xz mirror://gnu/gmp/gmp-6.1.2.tar.xz doc? ( http://gmplib.org/gmp-man-6.1.2.pdf )
-_eclasses_=desktop	b1d22ac8bdd4679ab79c71aca235009d	epatch	ed88001f77c6dd0d5f09e45c1a5b480e	estack	686eaab303305a908fd57b2fd7617800	eutils	fcb2aa98e1948b835b5ae66ca52868c5	flag-o-matic	5d5921a298e95441da2f85be419894c0	libtool	f143db5a74ccd9ca28c1234deffede96	ltprune	2729691420b6deeda2a90b1f1183fb55	multibuild	40fe59465edacd730c644ec2bc197809	multilib	2477ebe553d3e4d2c606191fe6c33602	multilib-build	1979aa0ff4d356d32507ca4650d9f37d	multilib-minimal	8bddda43703ba94d8341f4e247f97566	preserve-libs	ef207dc62baddfddfd39a164d9797648	toolchain-funcs	605c126bed8d87e4378d5ff1645330cb	vcs-clean	2a0f74a496fa2b1552c4f3398258b7bf
-_md5_=3bc87485dc9f98af21d3ac7a93634e80
diff --git a/metadata/md5-cache/dev-libs/gmp-6.1.2-r3 b/metadata/md5-cache/dev-libs/gmp-6.1.2-r3
deleted file mode 100644
index 05f80fc..0000000
--- a/metadata/md5-cache/dev-libs/gmp-6.1.2-r3
+++ /dev/null
@@ -1,12 +0,0 @@
-DEFINED_PHASES=compile configure install prepare test
-DEPEND=sys-devel/m4 app-arch/xz-utils >=app-portage/elt-patches-20170815
-DESCRIPTION=Library for arbitrary-precision arithmetic on different type of numbers
-EAPI=5
-HOMEPAGE=http://gmplib.org/
-IUSE=+asm doc cxx pgo static-libs abi_x86_32 abi_x86_64 abi_x86_x32 abi_mips_n32 abi_mips_n64 abi_mips_o32 abi_ppc_32 abi_ppc_64 abi_s390_32 abi_s390_64 abi_arm_32 abi_arm_64
-KEYWORDS=*
-LICENSE=|| ( LGPL-3+ GPL-2+ )
-SLOT=0/10.4
-SRC_URI=ftp://ftp.gmplib.org/pub/gmp-6.1.2/gmp-6.1.2.tar.xz mirror://gnu/gmp/gmp-6.1.2.tar.xz doc? ( http://gmplib.org/gmp-man-6.1.2.pdf )
-_eclasses_=desktop	b1d22ac8bdd4679ab79c71aca235009d	epatch	ed88001f77c6dd0d5f09e45c1a5b480e	estack	686eaab303305a908fd57b2fd7617800	eutils	fcb2aa98e1948b835b5ae66ca52868c5	flag-o-matic	5d5921a298e95441da2f85be419894c0	libtool	f143db5a74ccd9ca28c1234deffede96	ltprune	2729691420b6deeda2a90b1f1183fb55	multibuild	40fe59465edacd730c644ec2bc197809	multilib	2477ebe553d3e4d2c606191fe6c33602	multilib-build	1979aa0ff4d356d32507ca4650d9f37d	multilib-minimal	8bddda43703ba94d8341f4e247f97566	preserve-libs	ef207dc62baddfddfd39a164d9797648	toolchain-funcs	605c126bed8d87e4378d5ff1645330cb	vcs-clean	2a0f74a496fa2b1552c4f3398258b7bf
-_md5_=3bc87485dc9f98af21d3ac7a93634e80
diff --git a/metadata/md5-cache/dev-libs/gmp-6.2.1-r1 b/metadata/md5-cache/dev-libs/gmp-6.2.1-r1
new file mode 100644
index 0000000..259798c
--- /dev/null
+++ b/metadata/md5-cache/dev-libs/gmp-6.2.1-r1
@@ -0,0 +1,12 @@
+BDEPEND=sys-devel/m4 app-arch/xz-utils >=app-portage/elt-patches-20170815
+DEFINED_PHASES=compile configure install prepare test
+DESCRIPTION=Library for arbitrary-precision arithmetic on different type of numbers
+EAPI=7
+HOMEPAGE=https://gmplib.org/
+IUSE=+asm doc +cxx pic static-libs abi_x86_32 abi_x86_64 abi_x86_x32 abi_mips_n32 abi_mips_n64 abi_mips_o32 abi_ppc_32 abi_ppc_64 abi_s390_32 abi_s390_64 abi_arm_32 abi_arm_64
+KEYWORDS=*
+LICENSE=|| ( LGPL-3+ GPL-2+ )
+SLOT=0/10.4
+SRC_URI=ftp://ftp.gmplib.org/pub/gmp-6.2.1/gmp-6.2.1.tar.xz mirror://gnu/gmp/gmp-6.2.1.tar.xz doc? ( https://gmplib.org/gmp-man-6.2.0.pdf )
+_eclasses_=eutils	fcb2aa98e1948b835b5ae66ca52868c5	flag-o-matic	5d5921a298e95441da2f85be419894c0	libtool	f143db5a74ccd9ca28c1234deffede96	multibuild	40fe59465edacd730c644ec2bc197809	multilib	2477ebe553d3e4d2c606191fe6c33602	multilib-build	1979aa0ff4d356d32507ca4650d9f37d	multilib-minimal	8bddda43703ba94d8341f4e247f97566	toolchain-funcs	605c126bed8d87e4378d5ff1645330cb
+_md5_=f2d0488ea797d583e265198c3a04f92b