Gentoo Archives: gentoo-commits

From: Fabian Groffen <grobian@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-devel/gcc-apple/
Date: Thu, 25 Nov 2021 10:17:21
Message-Id: 1637835433.2f5e024709d3890cc93fa59b65985fd938730195.grobian@gentoo
1 commit: 2f5e024709d3890cc93fa59b65985fd938730195
2 Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
3 AuthorDate: Thu Nov 25 10:16:49 2021 +0000
4 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
5 CommitDate: Thu Nov 25 10:17:13 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2f5e0247
7
8 sys-devel/gcc-apple-4.2.1_p5666-r3: revbump for EAPI=7
9
10 Bug: https://bugs.gentoo.org/827155
11 Package-Manager: Portage-3.0.28, Repoman-3.0.3
12 Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
13
14 .../gcc-apple/gcc-apple-4.2.1_p5666-r3.ebuild | 371 +++++++++++++++++++++
15 1 file changed, 371 insertions(+)
16
17 diff --git a/sys-devel/gcc-apple/gcc-apple-4.2.1_p5666-r3.ebuild b/sys-devel/gcc-apple/gcc-apple-4.2.1_p5666-r3.ebuild
18 new file mode 100644
19 index 000000000000..c144abe8aca5
20 --- /dev/null
21 +++ b/sys-devel/gcc-apple/gcc-apple-4.2.1_p5666-r3.ebuild
22 @@ -0,0 +1,371 @@
23 +# Copyright 1999-2021 Gentoo Authors
24 +# Distributed under the terms of the GNU General Public License v2
25 +
26 +EAPI="7"
27 +
28 +inherit toolchain flag-o-matic autotools prefix toolchain-funcs
29 +
30 +GCC_VERS=${PV/_p*/}
31 +APPLE_VERS="${PV/*_p/}.3"
32 +DESCRIPTION="Apple branch of the GNU Compiler Collection, Developer Tools 4.0"
33 +HOMEPAGE="https://gcc.gnu.org"
34 +SRC_URI="http://www.opensource.apple.com/darwinsource/tarballs/other/gcc-${APPLE_VERS}.tar.gz
35 + http://www.opensource.apple.com/darwinsource/tarballs/other/libstdcxx-39.tar.gz
36 + fortran? (
37 + mirror://gnu/gcc/gcc-4.2.4/gcc-fortran-4.2.4.tar.bz2
38 + https://dev.gentoo.org/~grobian/distfiles/${PN}-4.2.1_p5646-gfortran.patch
39 + )"
40 +LICENSE="GPL-2 GPL-3"
41 +
42 +SLOT="42"
43 +KEYWORDS="~ppc-macos ~x64-macos"
44 +IUSE="bootstrap fortran nls +openmp objc objc++ +cxx"
45 +
46 +RDEPEND=">=sys-libs/zlib-1.1.4
47 + >=sys-libs/ncurses-5.2-r2
48 + nls? ( sys-devel/gettext )
49 + >=sys-devel/gcc-config-1.8-r1
50 + !<sys-apps/portage-2.2.14
51 + fortran? (
52 + >=dev-libs/gmp-4.2.1
53 + >=dev-libs/mpfr-2.2.0_p10
54 + )"
55 +DEPEND="${RDEPEND}
56 + >=sys-apps/texinfo-4.2-r4
57 + >=sys-devel/bison-1.875
58 + ${CATEGORY}/binutils-apple
59 + >=dev-libs/mpfr-2.2.0_p10"
60 +PDEPEND="sys-libs/csu"
61 +
62 +S=${WORKDIR}/gcc-${APPLE_VERS}
63 +
64 +# TPREFIX is the prefix of the CTARGET installation
65 +export TPREFIX=${TPREFIX:-${EPREFIX}}
66 +
67 +do_bootstrap() {
68 + is_crosscompile && return 1
69 + [[ ${CHOST} != ${CBUILD} ]] && return 1
70 + [[ ${EPREFIX} != ${TPREFIX} ]] && return 1
71 + return 0
72 +}
73 +
74 +src_unpack() {
75 + # override toolchain.eclass func
76 + unpack ${A}
77 +}
78 +
79 +src_prepare() {
80 + # Support for fortran
81 + if use fortran ; then
82 + mv "${WORKDIR}"/gcc-4.2.4/gcc/fortran gcc/ || die
83 + mv "${WORKDIR}"/gcc-4.2.4/libgfortran . || die
84 + # from: substracted from http://r.research.att.com/tools/
85 + eapply "${DISTDIR}"/${PN}-4.2.1_p5646-gfortran.patch
86 + fi
87 +
88 + mv "${WORKDIR}"/libstdcxx-39/libstdcxx/libstdc++-v3 .
89 +
90 + # pre Leopard has no dtrace, which is required by 37.11 and above
91 + # Leopard only has 32-bits version of dtrace
92 + # So back out dtrace support on those platforms using patch
93 + # thoughtfully provided by Apple.
94 + [[ ${CHOST} == x86_64-apple-darwin9 || ${CHOST##*-darwin} -le 8 ]] && \
95 + eapply -R -p0 "${WORKDIR}"/libstdcxx-39/patches-4.2.1/dtrace.patch
96 +
97 + # we use our libtool
98 + sed -i -e "s:/usr/bin/libtool:${EPREFIX}/usr/bin/${CTARGET}-libtool:" \
99 + gcc/config/darwin.h || die "sed gcc/config/darwin.h failed"
100 + # add prefixed Frameworks to default search paths (may want to change this
101 + # in a cross-compile)
102 + sed -i -e "/\"\/System\/Library\/Frameworks\"\,/i\ \ \"${EPREFIX}/Frameworks\"\, " \
103 + gcc/config/darwin-c.c || die "sed gcc/config/darwin-c.c failed"
104 +
105 + # Workaround deprecated "+Nc" syntax for GNU tail(1)
106 + sed -i -e "s:tail +16c:tail -c +16:g" \
107 + gcc/Makefile.in || die "sed gcc/Makefile.in failed."
108 +
109 + # default to AltiVec on PPC, like for older releases
110 + eapply -p0 "${FILESDIR}"/${PN}-4.0.1_p5465-default-altivec.patch
111 +
112 + # support -arch XXX if XXX is actually what the toolchain targets because
113 + # some upstreams insist on setting it
114 + eapply "${FILESDIR}"/${PN}-4.2.1-arch-option.patch
115 +
116 + # dsymutil stuff breaks on 10.4/x86, revert it
117 + [[ ${CHOST} == *86*-apple-darwin8 ]] && \
118 + eapply -p0 "${FILESDIR}"/${P}-dsymutil.patch
119 +
120 + # support OS X 10.10
121 + eapply -p0 "${FILESDIR}"/${P}-darwin14.patch
122 +
123 + # bootstrapping might fail with host provided gcc on 10.4/x86
124 + if ! is_crosscompile && ! echo "int main(){return 0;}" | $(tc-getCC) -o "${T}"/foo \
125 + -mdynamic-no-pic -x c - >/dev/null 2>&1;
126 + then
127 + einfo "-mdynamic-no-pic doesn't work - disabling..."
128 + echo "BOOT_CFLAGS=-g -O2" > config/mh-x86-darwin
129 + XD=gcc/config/i386/x-darwin
130 + awk 'BEGIN{x=1}{if ($0 ~ "use -mdynamic-no-pic to build x86")
131 + {x=1-x} else if (x) print}' $XD > t && mv t $XD \
132 + || die "Failed to rewrite $XD"
133 + fi
134 +
135 + if [[ ${CHOST} == powerpc*-darwin* ]] && \
136 + ! echo "int main(){return 0;}" | \
137 + $(tc-getCC) -o "${T}"/foo -no-cpp-precomp -x c - >/dev/null 2>&1;
138 + then
139 + einfo "-no-cpp-precomp not supported by compiler - disabling ..."
140 + sed -i -e 's/-no-cpp-precomp//' configure.in configure || die
141 + fi
142 +
143 + eapply "${FILESDIR}"/${P}-perl-5.18.patch
144 + eapply "${FILESDIR}"/${P}-darwin8.patch
145 +
146 + eapply -p0 "${FILESDIR}"/${PN}-4.2.1-prefix-search-dirs-r1.patch
147 + eprefixify "${S}"/gcc/gcc.c
148 + sed -i -e "s|@GENTOO_PORTAGE_TPREFIX@|${TPREFIX}|g" \
149 + "${S}"/gcc/config/darwin.h
150 +
151 + if use !bootstrap ; then
152 + # this only occurs with up-to-date tools from the Prefix, and actually
153 + # breaks the bootstrap since the autoconf needs a very recent automake
154 + eapply -p0 "${FILESDIR}"/${PN}-${GCC_VERS}-texinfo.patch
155 + eapply -p0 "${FILESDIR}"/${PN}-${GCC_VERS}-autoconf-m4-precious.patch
156 + cd "${S}"/gcc && eautoconf
157 + cd "${S}"/libgomp && eautoconf
158 + fi
159 +
160 + local extvers=
161 + eapply_user && extvers=" with user patches"
162 +
163 + local BRANDING_GCC_PKGVERSION="$(sed -n -e '/^#define VERSUFFIX/s/^[^"]*"\([^"]\+\)".*$/\1/p' "${S}"/gcc/version.c)"
164 + BRANDING_GCC_PKGVERSION=${BRANDING_GCC_PKGVERSION/(/(Gentoo ${PVR}${extvers}, }
165 + # ) ) } # <- to help Vim highlight this correctly
166 + einfo "patching gcc version: ${GCC_VERS}${BRANDING_GCC_PKGVERSION}"
167 +
168 + sed -i -e "s~VERSUFFIX \"[^\"]*~VERSUFFIX \"${BRANDING_GCC_PKGVERSION}~" \
169 + "${S}"/gcc/version.c || die "failed to update VERSUFFIX with Gentoo branding"
170 + sed -i -e 's~developer\.apple\.com\/bugreporter~bugs\.gentoo\.org\/~' \
171 + "${S}"/gcc/version.c || die "Failed to change the bug URL"
172 +
173 + # fix the install_names of all shared libraries for the target
174 + # NOTE: do this after any automake-ing!
175 + # Yes, patching generated files is bad. Talk to me once you've found a way to do this inside automake.
176 + sed -i -e "s|-install_name \$(slibdir)|-install_name ${TPREFIX}/usr/${CTARGET}/lib/gcc|" "${S}"/gcc/config/t-slibgcc-darwin
177 + sed -i -e "s|-rpath \$(toolexeclibdir)|-rpath ${TPREFIX}/usr/${CTARGET}/lib/gcc|" \
178 + "${S}"/{libgomp,libstdc++-v3/src,libstdc++-v3/libsupc++}/Makefile.in
179 +}
180 +
181 +src_configure() {
182 + local langs="c"
183 + use cxx && langs="${langs},c++"
184 + use objc && langs="${langs},objc"
185 + use objc++ && langs="${langs/,objc/},objc,obj-c++" # need objc with objc++
186 + use fortran && langs="${langs},fortran"
187 +
188 + LIBPATH=${EPREFIX}/usr/lib/gcc/${CTARGET}/${GCC_VERS}
189 + if is_crosscompile ; then
190 + BINPATH=${EPREFIX}/usr/${CHOST}/${CTARGET}/gcc-bin/${GCC_VERS}
191 + else
192 + BINPATH=${EPREFIX}/usr/${CTARGET}/gcc-bin/${GCC_VERS}
193 + fi
194 + STDCXX_INCDIR=${LIBPATH}/include/g++-v${GCC_VERS/\.*/}
195 +
196 + local myconf="${myconf} \
197 + --prefix=${EPREFIX}/usr \
198 + --bindir=${BINPATH} \
199 + --includedir=${LIBPATH}/include \
200 + --datadir=${EPREFIX}/usr/share/gcc-data/${CTARGET}/${GCC_VERS} \
201 + --mandir=${EPREFIX}/usr/share/gcc-data/${CTARGET}/${GCC_VERS}/man \
202 + --infodir=${EPREFIX}/usr/share/gcc-data/${CTARGET}/${GCC_VERS}/info \
203 + --with-gxx-include-dir=${STDCXX_INCDIR} \
204 + --host=${CHOST} \
205 + --enable-version-specific-runtime-libs"
206 +
207 + if is_crosscompile ; then
208 + # Straight from the GCC install doc:
209 + # "GCC has code to correctly determine the correct value for target
210 + # for nearly all native systems. Therefore, we highly recommend you
211 + # not provide a configure target when configuring a native compiler."
212 + myconf="${myconf} --target=${CTARGET}"
213 +
214 + # Tell compiler where to find what it needs
215 + myconf="${myconf} --with-sysroot=${EPREFIX}/usr/${CTARGET}"
216 +
217 + # Set this to something sane for both native and target
218 + CFLAGS="-O2 -pipe"
219 +
220 + local VAR="CFLAGS_"${CTARGET//-/_}
221 + CXXFLAGS=${!VAR}
222 + fi
223 + [[ -n ${CBUILD} ]] && myconf="${myconf} --build=${CBUILD}"
224 +
225 + # Native Language Support
226 + if use nls ; then
227 + myconf="${myconf} --enable-nls --without-included-gettext"
228 + else
229 + myconf="${myconf} --disable-nls"
230 + fi
231 +
232 + # reasonably sane globals (hopefully)
233 + myconf="${myconf} \
234 + --with-system-zlib \
235 + --disable-checking \
236 + --disable-werror"
237 +
238 + # ???
239 + myconf="${myconf} --enable-shared --enable-threads=posix"
240 +
241 + # make clear we're in an offset
242 + use prefix && myconf="${myconf} --with-local-prefix=${TPREFIX}/usr"
243 +
244 + do_bootstrap || myconf="${myconf} --disable-bootstrap"
245 +
246 + # we don't use a GNU linker, so tell GCC where to find the linker stuff we
247 + # want it to use
248 + myconf="${myconf} \
249 + --with-as=${EPREFIX}/usr/bin/${CTARGET}-as \
250 + --with-ld=${EPREFIX}/usr/bin/${CTARGET}-ld"
251 +
252 + # make sure we never do multilib stuff, for that we need a different Prefix
253 + [[ -z ${I_KNOW_WHAT_IM_DOING_I_WANT_APPLE_MULTILIB} ]] \
254 + && myconf="${myconf} --disable-multilib"
255 +
256 + myconf="${myconf} --enable-languages=${langs} $(use_enable openmp libgomp)"
257 +
258 + # The produced libgcc_s.dylib is faulty if using a bit too much
259 + # optimisation. Nail it down to something sane
260 + CFLAGS="-O2 -pipe"
261 + CXXFLAGS=${CFLAGS}
262 +
263 + # https://gcc.gnu.org/ml/gcc-patches/2006-11/msg00765.html
264 + # (won't hurt if already 64-bits, but is essential when coming from a
265 + # multilib compiler -- the default)
266 + [[ ${CTARGET} == powerpc64-* || ${CTARGET} == x86_64-* ]] && \
267 + export CC="${CC:-$(tc-getCC)} -m64"
268 +
269 + # Clang on OSX defaults to c99 mode, while GCC defaults to gnu89
270 + # (C90 + extensions). This makes Clang barf on GCC's sources, so
271 + # work around that. Bugs #491098, #574736
272 + export CC="${CC:-$(tc-getCC)} -std=gnu89"
273 +
274 + mkdir -p "${WORKDIR}"/build
275 + cd "${WORKDIR}"/build
276 + einfo "Configuring GCC with: ${myconf//--/\n\t--}"
277 + "${S}"/configure ${myconf} || die "conf failed"
278 +}
279 +
280 +src_compile() {
281 + cd "${WORKDIR}"/build || die
282 + if ! do_bootstrap; then
283 + GCC_MAKE_TARGET=${GCC_MAKE_TARGET-all}
284 + else
285 + GCC_MAKE_TARGET=${GCC_MAKE_TARGET-bootstrap}
286 + fi
287 + emake ${GCC_MAKE_TARGET}
288 +}
289 +
290 +src_install() {
291 + cd "${WORKDIR}"/build
292 + # -jX doesn't work
293 + emake -j1 DESTDIR="${D}" install
294 +
295 + # Punt some tools which are really only useful while building gcc
296 + find "${ED}" -name install-tools -prune -type d -exec rm -rf "{}" \;
297 + # This one comes with binutils
298 + find "${ED}" -name libiberty.a -exec rm -f "{}" \;
299 +
300 + # Basic sanity check
301 + if ! is_crosscompile ; then
302 + local EXEEXT
303 + eval $(grep ^EXEEXT= "${WORKDIR}"/build/gcc/config.log)
304 + [[ -r ${D}${BINPATH}/gcc${EXEEXT} ]] || die "gcc not found in ${ED}"
305 + fi
306 +
307 + # create gcc-config entry
308 + dodir /etc/env.d/gcc
309 + local gcc_envd_base="/etc/env.d/gcc/${CHOST}-${GCC_VERS}"
310 +
311 + gcc_envd_file="${ED}${gcc_envd_base}"
312 +
313 + # phase PATH/ROOTPATH out ...
314 + echo "PATH=\"${BINPATH}\"" > ${gcc_envd_file}
315 + echo "ROOTPATH=\"${BINPATH}\"" >> ${gcc_envd_file}
316 + echo "GCC_PATH=\"${BINPATH}\"" >> ${gcc_envd_file}
317 +
318 + # we don't do multilib
319 + LDPATH="${LIBPATH}"
320 + echo "LDPATH=\"${LDPATH}\"" >> ${gcc_envd_file}
321 + echo "MANPATH=\"${EPREFIX}/usr/share/gcc-data/${CHOST}/${GCC_VERS}/man\"" >> ${gcc_envd_file}
322 + echo "INFOPATH=\"${EPREFIX}/usr/share/gcc-data/${CHOST}/${GCC_VERS}/info\"" >> ${gcc_envd_file}
323 + echo "STDCXX_INCDIR=\"g++-v${GCC_VERS/\.*/}\"" >> ${gcc_envd_file}
324 + is_crosscompile && echo "CTARGET=${CTARGET}" >> ${gcc_envd_file}
325 +
326 + # Move <cxxabi.h> to compiler-specific directories
327 + [[ -f ${D}${STDCXX_INCDIR}/cxxabi.h ]] && \
328 + mv -f "${D}"${STDCXX_INCDIR}/cxxabi.h "${D}"${LIBPATH}/include/
329 +
330 + # These should be symlinks
331 + dodir /usr/bin
332 + cd "${D}"${BINPATH}
333 + for x in cpp gcc g++ c++ g77 gcj gcjh gfortran ; do
334 + # For some reason, g77 gets made instead of ${CTARGET}-g77...
335 + # this should take care of that
336 + [[ -f ${x} ]] && mv ${x} ${CTARGET}-${x}
337 +
338 + if [[ -f ${CTARGET}-${x} ]] && ! is_crosscompile ; then
339 + ln -sf ${CTARGET}-${x} ${x}
340 +
341 + # Create version-ed symlinks
342 + dosym ../${BINPATH#${EPREFIX}/usr/}/${CTARGET}-${x} \
343 + /usr/bin/${CTARGET}-${x}-${GCC_VERS}
344 + dosym ../${BINPATH#${EPREFIX}/usr/}/${CTARGET}-${x} \
345 + /usr/bin/${x}-${GCC_VERS}
346 + fi
347 +
348 + if [[ -f ${CTARGET}-${x}-${GCC_VERS} ]] ; then
349 + rm -f ${CTARGET}-${x}-${GCC_VERS}
350 + ln -sf ${CTARGET}-${x} ${CTARGET}-${x}-${GCC_VERS}
351 + fi
352 + done
353 +
354 + # I do not know if this will break gcj stuff, so I'll only do it for
355 + # objc for now; basically "ffi.h" is the correct file to include,
356 + # but it gets installed in .../GCCVER/include and yet it does
357 + # "#include <ffitarget.h>" which (correctly, as it's an "extra" file)
358 + # is installed in .../GCCVER/include/libffi; the following fixes
359 + # ffi.'s include of ffitarget.h - Armando Di Cianno <fafhrd@g.o>
360 + if [[ -d ${D}${LIBPATH}/include/libffi ]] ; then
361 + mv -i "${D}"${LIBPATH}/include/libffi/* "${D}"${LIBPATH}/include || die
362 + rm -r "${D}"${LIBPATH}/include/libffi || die
363 + fi
364 +
365 + # prune empty dirs left behind
366 + find "${ED}" -type d | xargs rmdir >& /dev/null
367 +
368 + # The gcc runtime libs have an invalid install_name; this is correct,
369 + # as they are copied to the right location by gcc-config later.
370 + QA_IGNORE_INSTALL_NAME_FILES=()
371 + pushd "${ED}/usr/lib/gcc/${CTARGET}/${GCC_VERS}" > /dev/null
372 + for file in *.dylib; do
373 + QA_IGNORE_INSTALL_NAME_FILES+=( "${file}" )
374 + done
375 + popd > /dev/null
376 +}
377 +
378 +pkg_postinst() {
379 + # only activate this compiler if nothing else is activated
380 + gcc-config -c >& /dev/null || gcc-config ${CTARGET}-${GCC_VERS}
381 +}
382 +
383 +pkg_postrm() {
384 + # clean up the cruft left behind by cross-compilers
385 + if is_crosscompile ; then
386 + if [[ -z $(ls "${EROOT}"/etc/env.d/gcc/${CTARGET}* 2>/dev/null) ]] ; then
387 + rm -f "${EROOT}"/etc/env.d/gcc/config-${CTARGET}
388 + rm -f "${EROOT}"/etc/env.d/??gcc-${CTARGET}
389 + rm -f "${EROOT}"/usr/bin/${CTARGET}-{gcc,{g,c}++}{,32,64}
390 + fi
391 + return 0
392 + fi
393 +}