From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id BB69F158089 for ; Sat, 30 Sep 2023 09:38:59 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id C49D52BC041; Sat, 30 Sep 2023 09:38:58 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id A80EE2BC041 for ; Sat, 30 Sep 2023 09:38:58 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 97372335D3C for ; Sat, 30 Sep 2023 09:38:57 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id A47BE1146 for ; Sat, 30 Sep 2023 09:38:55 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1696066720.bb2d045c02a6ca647ef3280f4987cbc0d14e5a7e.sam@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/ X-VCS-Repository: repo/gentoo X-VCS-Files: eclass/toolchain.eclass X-VCS-Directories: eclass/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: bb2d045c02a6ca647ef3280f4987cbc0d14e5a7e X-VCS-Branch: master Date: Sat, 30 Sep 2023 09:38:55 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 228db094-0bf8-4cbf-a2e6-32ff16588755 X-Archives-Hash: 0638a5fdad9cc4987b8269b4f4cc6071 commit: bb2d045c02a6ca647ef3280f4987cbc0d14e5a7e Author: Sam James gentoo org> AuthorDate: Thu Sep 28 23:27:06 2023 +0000 Commit: Sam James gentoo org> CommitDate: Sat Sep 30 09:38:40 2023 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=bb2d045c toolchain.eclass: rework bootstrapping logic * Build stage1 compiler with user's CFLAGS. This consistently ends up saving at least 15 minutes for me on a fast amd64 machine and should save more on slower machines and architectures. There's only any risk here if the host compiler is ancient/very buggy and even then, you get a failed bootstrap later on. The GCC developers, per the linked bug, end up using STAGE1_CFLAGS="-O2" anyway to speed up the process so it's not like this is untested at all. mattst88 actually brought this up.. 10 years ago (bug #477548). Let's try make that right now. * Respect LDFLAGS for target libraries for native builds. Not touching this for cross builds, at least for now, as it's a bit more delicate. (Unfortunately, we have to put a hack in here for now until we can fix multilib.eclass - see bug #914881). Bug: https://gcc.gnu.org/PR111619 Bug: https://bugs.gentoo.org/914881 Closes: https://bugs.gentoo.org/477548 Closes: https://bugs.gentoo.org/831423 Closes: https://bugs.gentoo.org/840392 Apologies-to: Matt Turner gentoo.org> Signed-off-by: Sam James gentoo.org> eclass/toolchain.eclass | 52 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass index d93068619cf9..a145e74d5521 100644 --- a/eclass/toolchain.eclass +++ b/eclass/toolchain.eclass @@ -1647,19 +1647,48 @@ gcc_do_make() { fi fi - if [[ ${GCC_MAKE_TARGET} == "all" ]] ; then - STAGE1_CFLAGS=${STAGE1_CFLAGS-"${CFLAGS}"} - fi + local emakeargs=( + LDFLAGS="${LDFLAGS}" + LIBPATH="${LIBPATH}" + ) if is_crosscompile; then # In 3.4, BOOT_CFLAGS is never used on a crosscompile... # but I'll leave this in anyways as someone might have had # some reason for putting it in here... --eradicator BOOT_CFLAGS=${BOOT_CFLAGS-"-O2"} + emakeargs+=( BOOT_CFLAGS="${BOOT_CFLAGS}" ) else - # we only want to use the system's CFLAGS if not building a + # XXX: Hack for bug #914881, clean this up when fixed and go back + # to just calling get_abi_LDFLAGS as before. + local abi_ldflags="$(get_abi_LDFLAGS ${TARGET_DEFAULT_ABI})" + printf -v abi_ldflags -- "-Wl,%s " ${abi_ldflags} + + # If the host compiler is too old, let's use -O0 per the upstream + # default to be safe (to avoid a bootstrap comparison failure later). + # + # The last known issues are with < GCC 4.9 or so, but it's easier + # to keep this bound somewhat fresh just to avoid problems. Ultimately, + # using not-O0 is just a build-time speed improvement anyway. + if tc-is-gcc && ver_test $(gcc-fullversion) -lt 10 ; then + STAGE1_CFLAGS="-O0" + fi + + # We only want to use the system's CFLAGS if not building a # cross-compiler. + STAGE1_CFLAGS=${STAGE1_CFLAGS-"$(get_abi_CFLAGS ${TARGET_DEFAULT_ABI}) ${CFLAGS}"} + STAGE1_LDFLAGS=${STAGE1_LDFLAGS-"${abi_ldflags} ${LDFLAGS}"} BOOT_CFLAGS=${BOOT_CFLAGS-"$(get_abi_CFLAGS ${TARGET_DEFAULT_ABI}) ${CFLAGS}"} + BOOT_LDFLAGS=${BOOT_LDFLAGS-"${abi_ldflags} ${LDFLAGS}"} + LDFLAGS_FOR_TARGET="${LDFLAGS_FOR_TARGET:-${LDFLAGS}}" + + emakeargs+=( + STAGE1_CFLAGS="${STAGE1_CFLAGS}" + STAGE1_LDFLAGS="${STAGE1_LDFLAGS}" + BOOT_CFLAGS="${BOOT_CFLAGS}" + BOOT_LDFLAGS="${BOOT_LDFLAGS}" + LDFLAGS_FOR_TARGET="${LDFLAGS_FOR_TARGET}" + ) fi if is_jit ; then @@ -1667,24 +1696,13 @@ gcc_do_make() { pushd "${WORKDIR}"/build-jit > /dev/null || die einfo "Building JIT" - emake \ - LDFLAGS="${LDFLAGS}" \ - STAGE1_CFLAGS="${STAGE1_CFLAGS}" \ - LIBPATH="${LIBPATH}" \ - BOOT_CFLAGS="${BOOT_CFLAGS}" + emake "${emakeargs[@]}" popd > /dev/null || die fi einfo "Compiling ${PN} (${GCC_MAKE_TARGET})..." - pushd "${WORKDIR}"/build >/dev/null || die - - emake \ - LDFLAGS="${LDFLAGS}" \ - STAGE1_CFLAGS="${STAGE1_CFLAGS}" \ - LIBPATH="${LIBPATH}" \ - BOOT_CFLAGS="${BOOT_CFLAGS}" \ - ${GCC_MAKE_TARGET} + emake "${emakeargs[@]}" ${GCC_MAKE_TARGET} if is_ada; then # Without these links, it is not getting the good compiler