commit:     ea474da34fe1f904936f0f6b6e52d91364c36c95
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Mon Sep 30 01:25:23 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Sep 30 01:51:44 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ea474da3

toolchain.eclass: unset _GLIBCXX_ASSERTIONS for stage1 with D bootstrap

When bootstrapping D for >= GCC 12 - where we enable _GLIBCXX_ASSERTIONS
by default for USE=hardened - using GCC 11, we run into trouble where
an implementation detail of _GLIBCXX_ASSERTIONS changed: see PR104807,
r12-7504-gd3a757af21ac33, and r12-7522-g4cb935cb69f120.

Workaround this by just disabling _GLIBCXX_ASSERTIONS for the stage 1
compiler (where it's not particularly important anyway) when USE=hardened
and we're building D. We could make this more conditional if needed
but I don't think it's worth it. In fact, maybe we should do this
unconditionally for a minor speed boost in building.

Bug: https://gcc.gnu.org/PR104807
Bug: https://bugs.gentoo.org/940470
Signed-off-by: Sam James <sam <AT> gentoo.org>

 eclass/toolchain.eclass | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index d6445ea3227e..b563277e90b1 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -2029,6 +2029,15 @@ gcc_do_make() {
                BOOT_LDFLAGS=${BOOT_LDFLAGS-"${abi_ldflags} ${LDFLAGS}"}
                LDFLAGS_FOR_TARGET="${LDFLAGS_FOR_TARGET:-${LDFLAGS}}"
 
+               # If we need to in future, we could really simplify this
+               # to just be unconditional for stage1. It doesn't really
+               # matter there. If we want to go in the other direction
+               # and make this more conditional, we could check if
+               # the bootstrap compiler is < GCC 12. See bug #940470.
+               if _tc_use_if_iuse d && use hardened ; then
+                       STAGE1_CXXFLAGS+=" -U_GLIBCXX_ASSERTIONS"
+               fi
+
                emakeargs+=(
                        STAGE1_CFLAGS="${STAGE1_CFLAGS}"
                        STAGE1_CXXFLAGS="${STAGE1_CXXFLAGS}"

Reply via email to