1 |
commit: 78b4d4ebbcee12f5ef4c1dfa89f80c98a582db9d |
2 |
Author: Sam James <sam <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Nov 30 07:37:50 2022 +0000 |
4 |
Commit: Sam James <sam <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Nov 30 07:48:13 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=78b4d4eb |
7 |
|
8 |
dev-libs/gmp: pass --enable-fat for x86 (includes more asm) |
9 |
|
10 |
Vanilla (_not_ from an ebuild) gmp will probe CHOST and then |
11 |
deduce its *own* tuple based on the currently used CPU, abusing |
12 |
its own custom config.guess (which our econf overwrites). This |
13 |
value is used to decide which accelerated asm is compiled in (MPN_PATH). |
14 |
|
15 |
In ebuilds, we override and refresh config.guess and friends because |
16 |
it's a common portability problem to have stale versions which don't |
17 |
even recognise e.g. riscv as an arch. But gmp's non-standard use |
18 |
of these files poses a problem for us. |
19 |
|
20 |
We can't simply resort to just not refreshing/changing the files |
21 |
because we need to be able to build binary packages on a system |
22 |
without them being super specific to the machine they were built |
23 |
on with no way of controlling it (we may want to look at a USE |
24 |
flag for this going forward though). |
25 |
|
26 |
For now, we can use --enable-fat which produces a generic libgmp |
27 |
which can load various asm at runtime based on the CPU in use - success! |
28 |
|
29 |
Unfortunately, --enable-fat only does anything on x86 for the time |
30 |
being, so !x86 is still in the same situation as before this commit, |
31 |
but this is progress at least. |
32 |
|
33 |
Thanks goes to Nikita Zlobin <nick87720z <AT> gmail.com> for noticing |
34 |
the problem originally (and being persistent with investigating it). |
35 |
|
36 |
Temporarily unkeyworded until I can test this a bit more. |
37 |
|
38 |
Bug: https://bugs.gentoo.org/883201 |
39 |
Signed-off-by: Sam James <sam <AT> gentoo.org> |
40 |
|
41 |
dev-libs/gmp/gmp-6.2.1-r3.ebuild | 130 +++++++++++++++++++++++++++++++++++++++ |
42 |
1 file changed, 130 insertions(+) |
43 |
|
44 |
diff --git a/dev-libs/gmp/gmp-6.2.1-r3.ebuild b/dev-libs/gmp/gmp-6.2.1-r3.ebuild |
45 |
new file mode 100644 |
46 |
index 000000000000..840288dd1207 |
47 |
--- /dev/null |
48 |
+++ b/dev-libs/gmp/gmp-6.2.1-r3.ebuild |
49 |
@@ -0,0 +1,130 @@ |
50 |
+# Copyright 1999-2022 Gentoo Authors |
51 |
+# Distributed under the terms of the GNU General Public License v2 |
52 |
+ |
53 |
+EAPI=8 |
54 |
+ |
55 |
+inherit libtool multilib-minimal toolchain-funcs |
56 |
+ |
57 |
+MY_PV=${PV/_p*} |
58 |
+MY_PV=${MY_PV/_/-} |
59 |
+ |
60 |
+MANUAL_PV=${MY_PV} |
61 |
+MANUAL_PV=6.2.1 |
62 |
+ |
63 |
+MY_P=${PN}-${MY_PV} |
64 |
+PLEVEL=${PV/*p} |
65 |
+ |
66 |
+DESCRIPTION="Library for arbitrary-precision arithmetic on different type of numbers" |
67 |
+HOMEPAGE="https://gmplib.org/" |
68 |
+SRC_URI="ftp://ftp.gmplib.org/pub/${MY_P}/${MY_P}.tar.xz |
69 |
+ mirror://gnu/${PN}/${MY_P}.tar.xz |
70 |
+ doc? ( https://gmplib.org/${PN}-man-${MANUAL_PV}.pdf )" |
71 |
+SRC_URI+=" https://dev.gentoo.org/~sam/distfiles/${CATEGORY}/${PN}/${P}-arm64-darwin.patch.bz2" |
72 |
+S="${WORKDIR}"/${MY_P%a} |
73 |
+ |
74 |
+LICENSE="|| ( LGPL-3+ GPL-2+ )" |
75 |
+# The subslot reflects the C & C++ SONAMEs. |
76 |
+SLOT="0/10.4" |
77 |
+# Unkeyworded temporarily for some more testing |
78 |
+#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" |
79 |
+IUSE="+asm doc +cxx pic static-libs" |
80 |
+ |
81 |
+BDEPEND=" |
82 |
+ app-arch/xz-utils |
83 |
+ sys-devel/m4 |
84 |
+" |
85 |
+ |
86 |
+DOCS=( AUTHORS ChangeLog NEWS README doc/configuration doc/isa_abi_headache ) |
87 |
+HTML_DOCS=( doc ) |
88 |
+ |
89 |
+MULTILIB_WRAPPED_HEADERS=( /usr/include/gmp.h ) |
90 |
+ |
91 |
+PATCHES=( |
92 |
+ "${FILESDIR}"/${PN}-6.1.0-noexecstack-detect.patch |
93 |
+ "${FILESDIR}"/${PN}-6.2.1-no-zarch.patch |
94 |
+ "${WORKDIR}"/${P}-arm64-darwin.patch |
95 |
+ "${FILESDIR}"/${P}-CVE-2021-43618.patch |
96 |
+) |
97 |
+ |
98 |
+src_prepare() { |
99 |
+ default |
100 |
+ |
101 |
+ # We cannot run autotools here as gcc depends on this package |
102 |
+ elibtoolize |
103 |
+ |
104 |
+ # bug #536894 |
105 |
+ if [[ ${CHOST} == *-darwin* ]] ; then |
106 |
+ eapply "${FILESDIR}"/${PN}-6.1.2-gcc-apple-4.0.1.patch |
107 |
+ fi |
108 |
+ |
109 |
+ # GMP uses the "ABI" env var during configure as does Gentoo (econf). |
110 |
+ # So, to avoid patching the source constantly, wrap things up. |
111 |
+ mv configure configure.wrapped || die |
112 |
+ cat <<-\EOF > configure |
113 |
+ #!/usr/bin/env sh |
114 |
+ exec env ABI="${GMPABI}" "$0.wrapped" "$@" |
115 |
+ EOF |
116 |
+ |
117 |
+ # Patches to original configure might have lost the +x bit. |
118 |
+ chmod a+rx configure{,.wrapped} || die |
119 |
+} |
120 |
+ |
121 |
+multilib_src_configure() { |
122 |
+ # Because of our 32-bit userland, 1.0 is the only HPPA ABI that works |
123 |
+ # https://gmplib.org/manual/ABI-and-ISA.html#ABI-and-ISA (bug #344613) |
124 |
+ if [[ ${CHOST} == hppa2.0-* ]] ; then |
125 |
+ GMPABI="1.0" |
126 |
+ fi |
127 |
+ |
128 |
+ # ABI mappings (needs all architectures supported) |
129 |
+ case ${ABI} in |
130 |
+ 32|x86) GMPABI=32;; |
131 |
+ 64|amd64|n64) GMPABI=64;; |
132 |
+ [onx]32) GMPABI=${ABI};; |
133 |
+ esac |
134 |
+ export GMPABI |
135 |
+ |
136 |
+ tc-export CC |
137 |
+ |
138 |
+ local myeconfargs=( |
139 |
+ CC_FOR_BUILD="$(tc-getBUILD_CC)" |
140 |
+ |
141 |
+ --localstatedir="${EPREFIX}"/var/state/gmp |
142 |
+ --enable-shared |
143 |
+ |
144 |
+ # fat is needed to avoid gmp installing either purely generic |
145 |
+ # or specific-to-used-CPU (which our config.guess refresh prevents at the moment). |
146 |
+ # Both Fedora and opensuse use this option to tackle the issue, bug #883201. |
147 |
+ # |
148 |
+ # This only works for x86, so we're still getting non-performant |
149 |
+ # builds on other arches until we figure something out! |
150 |
+ $(use_enable asm fat) |
151 |
+ $(use_enable asm assembly) |
152 |
+ $(use_enable cxx) |
153 |
+ $(use_enable static-libs static) |
154 |
+ |
155 |
+ # --with-pic forces static libraries to be built as PIC |
156 |
+ # and without TEXTRELs. musl does not support TEXTRELs: bug #707332 |
157 |
+ $(use pic && echo --with-pic) |
158 |
+ ) |
159 |
+ |
160 |
+ ECONF_SOURCE="${S}" econf "${myeconfargs[@]}" |
161 |
+} |
162 |
+ |
163 |
+multilib_src_install() { |
164 |
+ emake DESTDIR="${D}" install |
165 |
+ |
166 |
+ # Should be a standalone lib |
167 |
+ rm -f "${ED}"/usr/$(get_libdir)/libgmp.la |
168 |
+ |
169 |
+ # This requires libgmp |
170 |
+ local la="${ED}/usr/$(get_libdir)/libgmpxx.la" |
171 |
+ if ! use static-libs ; then |
172 |
+ rm -f "${la}" || die |
173 |
+ fi |
174 |
+} |
175 |
+ |
176 |
+multilib_src_install_all() { |
177 |
+ einstalldocs |
178 |
+ use doc && cp "${DISTDIR}"/gmp-man-${MANUAL_PV}.pdf "${ED}"/usr/share/doc/${PF}/ |
179 |
+} |