summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam James <sam@gentoo.org>2022-05-27 05:31:52 +0100
committerSam James <sam@gentoo.org>2022-05-29 00:32:15 +0100
commit3910f2d8719d8cb8fbb19572cb524b0472429c81 (patch)
tree806a0c2c70dc14fe9a5cad88fa5cc3507a4bae25 /eclass/toolchain.eclass
parentsys-devel/gcc: add 12.1.1_p20220528; patch set 6 (diff)
downloadgentoo-3910f2d8719d8cb8fbb19572cb524b0472429c81.tar.gz
gentoo-3910f2d8719d8cb8fbb19572cb524b0472429c81.tar.bz2
gentoo-3910f2d8719d8cb8fbb19572cb524b0472429c81.zip
toolchain.eclass: build JIT variant separately to avoid slowdown
It's what GCC upstream recommend to avoid slowing down the main GCC binaries which need to be built w/ -fPIC for JIT. We build twice but do an extremely minimal build for the JIT part which is rather quick. Install the JIT version first, then the main GCC variant, so the overlapping binaries come from the main build => more featureful, correct build options/needed ones for a full GCC build, etc. Closes: https://bugs.gentoo.org/843341 Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'eclass/toolchain.eclass')
-rw-r--r--eclass/toolchain.eclass79
1 files changed, 65 insertions, 14 deletions
diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index 69d674f46b64..cc601995f1f9 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -19,7 +19,7 @@ _TOOLCHAIN_ECLASS=1
DESCRIPTION="The GNU Compiler Collection"
HOMEPAGE="https://gcc.gnu.org/"
-inherit flag-o-matic gnuconfig libtool multilib pax-utils toolchain-funcs prefix
+inherit edo flag-o-matic gnuconfig libtool multilib pax-utils toolchain-funcs prefix
tc_is_live() {
[[ ${PV} == *9999* ]]
@@ -851,7 +851,6 @@ toolchain_src_configure() {
is_d && GCC_LANG+=",d"
is_gcj && GCC_LANG+=",java"
is_go && GCC_LANG+=",go"
- is_jit && GCC_LANG+=",jit"
if is_objc || is_objcxx ; then
GCC_LANG+=",objc"
use objc-gc && confgcc+=( --enable-objc-gc )
@@ -922,10 +921,6 @@ toolchain_src_configure() {
confgcc+=( --disable-libstdcxx-pch )
fi
- # The JIT support requires this.
- # But see bug #843341.
- is_jit && confgcc+=( --enable-host-shared )
-
# build-id was disabled for file collisions: bug #526144
#
# # Turn on the -Wl,--build-id flag by default for ELF targets. bug #525942
@@ -1337,17 +1332,35 @@ toolchain_src_configure() {
echo
# Build in a separate build tree
- mkdir -p "${WORKDIR}"/build
+ mkdir -p "${WORKDIR}"/build || die
pushd "${WORKDIR}"/build > /dev/null
# ...and now to do the actual configuration
addwrite /dev/zero
- echo "${S}"/configure "${confgcc[@]}"
+ if is_jit ; then
+ einfo "Configuring JIT gcc"
+
+ mkdir -p "${WORKDIR}"/build-jit || die
+ pushd "${WORKDIR}"/build-jit > /dev/null || die
+ CONFIG_SHELL="${BROOT}"/bin/bash edo "${S}"/configure \
+ "${confgcc[@]}" \
+ --disable-libada \
+ --disable-libsanitizer \
+ --disable-libvtv \
+ --disable-libgomp \
+ --disable-libquadmath \
+ --disable-libatomic \
+ --disable-lto \
+ --disable-bootstrap \
+ --enable-host-shared \
+ --enable-languages=jit
+ popd > /dev/null || die
+ fi
+
# Older gcc versions did not detect bash and re-exec itself, so force the
# use of bash. Newer ones will auto-detect, but this is not harmful.
- CONFIG_SHELL="${BROOT}/bin/bash" \
- "${BROOT}"/bin/bash "${S}"/configure "${confgcc[@]}" || die "failed to run configure"
+ CONFIG_SHELL="${BROOT}"/bin/bash edo "${S}"/configure "${confgcc[@]}"
# Return to whatever directory we were in before
popd > /dev/null
@@ -1640,8 +1653,8 @@ gcc_do_make() {
# default target
if is_crosscompile || tc-is-cross-compiler ; then
- # 3 stage bootstrapping doesnt quite work when you cant run the
- # resulting binaries natively ^^;
+ # 3 stage bootstrapping doesn't quite work when you can't run the
+ # resulting binaries natively
GCC_MAKE_TARGET=${GCC_MAKE_TARGET-all}
else
if _tc_use_if_iuse pgo; then
@@ -1719,6 +1732,19 @@ gcc_do_make() {
fi
fi
+ if is_jit ; then
+ # TODO: docs for jit?
+ pushd "${WORKDIR}"/build-jit > /dev/null || die
+
+ einfo "Building JIT"
+ emake \
+ LDFLAGS="${LDFLAGS}" \
+ STAGE1_CFLAGS="${STAGE1_CFLAGS}" \
+ LIBPATH="${LIBPATH}" \
+ BOOT_CFLAGS="${BOOT_CFLAGS}"
+ popd > /dev/null || die
+ fi
+
popd >/dev/null
}
@@ -1762,8 +1788,32 @@ toolchain_src_install() {
&& rm -f "${x}"
done < <(find gcc/include*/ -name '*.h')
+ if is_jit ; then
+ # See https://gcc.gnu.org/onlinedocs/gcc-11.3.0/jit/internals/index.html#packaging-notes
+ # and bug #843341.
+ #
+ # Both of the non-JIT and JIT builds are configured to install to $(DESTDIR)
+ # Install the configuration with --enable-host-shared first
+ # *then* the one without, so that the faster build
+ # of "cc1" et al overwrites the slower build.
+ #
+ # Do the 'make install' from the build directory
+ pushd "${WORKDIR}"/build-jit > /dev/null || die
+ S="${WORKDIR}"/build-jit emake DESTDIR="${D}" install
+
+ # Punt some tools which are really only useful while building gcc
+ find "${ED}" -name install-tools -prune -type d -exec rm -rf "{}" \;
+ # This one comes with binutils
+ find "${ED}" -name libiberty.a -delete
+
+ # Move the libraries to the proper location
+ gcc_movelibs
+
+ popd > /dev/null || die
+ fi
+
# Do the 'make install' from the build directory
- S="${WORKDIR}"/build emake DESTDIR="${D}" install || die
+ S="${WORKDIR}"/build emake DESTDIR="${D}" install
# Punt some tools which are really only useful while building gcc
find "${ED}" -name install-tools -prune -type d -exec rm -rf "{}" \;
@@ -1956,9 +2006,10 @@ gcc_movelibs() {
dodir "${HOSTLIBPATH#${EPREFIX}}"
mv "${ED}"/usr/$(get_libdir)/libcc1* "${D}${HOSTLIBPATH}" || die
fi
+
# libgccjit gets installed to /usr/lib, not /usr/$(get_libdir). Probably
# due to a bug in gcc build system.
- if is_jit ; then
+ if [[ ${PWD} == "${WORKDIR}"/build-jit ]] && is_jit ; then
dodir "${LIBPATH#${EPREFIX}}"
mv "${ED}"/usr/lib/libgccjit* "${D}${LIBPATH}" || die
fi