commit: 6bb573b35fd1a692d222304b8ce6f168b0026869 Author: Sam James <sam <AT> gentoo <DOT> org> AuthorDate: Sat Oct 11 03:19:12 2025 +0000 Commit: Sam James <sam <AT> gentoo <DOT> org> CommitDate: Sat Oct 11 07:07:20 2025 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=6bb573b3
toolchain.eclass: stop building JIT separately We introduced a split for libgccjit because it needs --enable-host-shared for bug #843341, but I think this was a mistake in the end: * We don't bootstrap that first, host-shared build because otherwise the build would take even longer; * gcc PR117047 is an example where not-bootstrapping causes very-hard-to-debug problems because libgccjit may be compiled differently by a newer compiler, but you can't just rebuild GCC once to observe that. Even knowing this*, I was stumped by it for some time; * It introduces complexities into the ebuild and it's already complex enough. See bug #954077 and bug #953823; * We want to support rust_codegen_gcc (a rustc codegen backend using libgccjit) in the future. If we do that, we want a bootstrapped build for libgccjit to know it's reliable; * The test setup as-is doesn't run tests for the first build; * On slower machines, that first "wasted" build is pretty noticeable and slow. I think any possible slowdown should be mitigated by using LTO and possibly -fno-semantic-interposition for GCC, which users are free to do. Bug: https://bugs.gentoo.org/843341 Bug: https://bugs.gentoo.org/954077 Bug: https://bugs.gentoo.org/953823 Signed-off-by: Sam James <sam <AT> gentoo.org> eclass/toolchain.eclass | 112 +++++++----------------------------------------- 1 file changed, 15 insertions(+), 97 deletions(-) diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass index 5e9a6bcad9ad..c09a7da14354 100644 --- a/eclass/toolchain.eclass +++ b/eclass/toolchain.eclass @@ -1295,6 +1295,7 @@ toolchain_src_configure() { is_cobol && GCC_LANG+=",cobol" is_modula2 && GCC_LANG+=",m2" is_rust && GCC_LANG+=",rust" + is_jit && GCC_LANG+=",jit" _need_ada_bootstrap_mangling() { if [[ ${CATEGORY}/${PN} == dev-lang/gnat-gpl ]] ; then @@ -1874,6 +1875,14 @@ toolchain_src_configure() { confgcc+=( --with-gxx-libcxx-include-dir="${ESYSROOT}"/usr/include/c++/v1 ) fi + if is_jit || _tc_use_if_iuse libgdiagnostics ; then + confgcc+=( --enable-host-shared ) + fi + + if tc_version_is_at_least 15.1 ${PV} ; then + confgcc+=( $(use_enable libgdiagnostics) ) + fi + # TODO: Ignore RCs here (but TOOLCHAIN_IS_RC isn't yet an eclass var) if [[ ${PV} == *_p* && -f "${S}"/gcc/doc/gcc.info ]] ; then # Safeguard against https://gcc.gnu.org/PR106899 being fixed @@ -1924,66 +1933,6 @@ toolchain_src_configure() { gcc_shell="${BROOT}"/bin/sh fi - if is_jit || _tc_use_if_iuse libgdiagnostics ; then - einfo "Configuring shared gcc for JIT/libgdiagnostics" - - local confgcc_jit=( - "${confgcc[@]}" - - --enable-lto - --disable-analyzer - --disable-bootstrap - --disable-cet - --disable-default-pie - --disable-default-ssp - --disable-gcov - --disable-libada - --disable-libatomic - --disable-libgomp - --disable-libitm - --disable-libquadmath - --disable-libsanitizer - --disable-libssp - --disable-libstdcxx-pch - --disable-libvtv - --disable-nls - --disable-objc-gc - --disable-systemtap - - --enable-host-shared - - # Might be used for the just-built GCC. Easier to just - # respect USE=graphite here in case the user passes some - # graphite flags rather than try strip them out. - $(use_with graphite isl) - --with-system-zlib - ) - - if is_jit ; then - confgcc_jit+=( --enable-languages=jit ) - else - confgcc_jit+=( --enable-languages=c,c++ ) - fi - - if tc_has_feature zstd ; then - confgcc_jit+=( $(use_with zstd) ) - fi - - if tc_version_is_at_least 15.1 ${PV} ; then - confgcc_jit+=( $(use_enable libgdiagnostics) ) - fi - - if tc_version_is_at_least 13.1 ; then - confgcc_jit+=( --disable-fixincludes ) - fi - - mkdir -p "${WORKDIR}"/build-jit || die - pushd "${WORKDIR}"/build-jit > /dev/null || die - - CONFIG_SHELL="${gcc_shell}" edo "${gcc_shell}" "${S}"/configure "${confgcc_jit[@]}" - popd > /dev/null || die - fi - CONFIG_SHELL="${gcc_shell}" edo "${gcc_shell}" "${S}"/configure "${confgcc[@]}" # Return to whatever directory we were in before @@ -2401,12 +2350,6 @@ gcc_do_make() { ) fi - if is_jit || _tc_use_if_iuse libgdiagnostics ; then - # TODO: docs for jit? - einfo "Building JIT" - emake -C "${WORKDIR}"/build-jit "${emakeargs[@]}" - fi - einfo "Compiling ${PN} (${GCC_MAKE_TARGET})..." pushd "${WORKDIR}"/build >/dev/null || die emake "${emakeargs[@]}" ${GCC_MAKE_TARGET} @@ -2430,7 +2373,6 @@ gcc_do_make() { #---->> src_test <<---- -# TODO: add JIT testing toolchain_src_test() { # GCC's testsuite is a special case. # @@ -2609,28 +2551,6 @@ toolchain_src_install() { done < <(find gcc/include*/ -name '*.h') fi - if is_jit || _tc_use_if_iuse libgdiagnostics ; 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}" -j1 install - - # This one comes with binutils - find "${ED}" -name libiberty.a -delete || die - - # Move the libraries to the proper location - gcc_movelibs - - popd > /dev/null || die - fi - # Do the 'make install' from the build directory # # Unfortunately, we have to use -j1 for make install. Upstream @@ -2838,16 +2758,14 @@ gcc_movelibs() { # libgccjit gets installed to /usr/lib, not /usr/$(get_libdir). Probably # due to a bug in gcc build system. - if [[ ${PWD} == "${WORKDIR}"/build-jit ]] ; then - dodir "${LIBPATH#${EPREFIX}}" + dodir "${LIBPATH#${EPREFIX}}" - if is_jit ; then - mv "${ED}"/usr/lib/libgccjit* "${D}${LIBPATH}" || die - fi + if is_jit ; then + mv "${ED}"/usr/lib/libgccjit* "${D}${LIBPATH}" || die + fi - if _tc_use_if_iuse libgdiagnostics ; then - mv "${ED}"/usr/lib/libgdiagnostics* "${D}${LIBPATH}" || die - fi + if _tc_use_if_iuse libgdiagnostics ; then + mv "${ED}"/usr/lib/libgdiagnostics* "${D}${LIBPATH}" || die fi # For all the libs that are built for CTARGET, move them into the
