commit:     e51546df7ff0b4f452c0f4291de23fa083f3fa76
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 26 16:46:27 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Oct 26 16:47:26 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e51546df

toolchain.eclass: pass -fno-control-flow-redundancy, filter flags for older 
compilers too

If we're *building* an older GCC, then these flags won't be supported later
on during the boostrap process, so filter them out.

Also, pass -fno-control-flow-redundancy given it makes the compiler unbearably
slow (on a 3950x, it went from 2.5hours for pgo+lto+checking to 6+ hours) and it
doesn't really benefit us there anyway.

Signed-off-by: Sam James <sam <AT> gentoo.org>

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

diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index 8df8b506b0b1..4fd884f5f0bc 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -1535,6 +1535,18 @@ gcc_do_filter_flags() {
                fi
        fi
 
+
+       if ver_test -lt 13.6 ; then
+               # These aren't supported by the just-built compiler either.
+               filter-flags -fharden-compares -fharden-conditional-branches \
+                       -fharden-control-flow-redundancy -fhardcfr-skip-leaf \
+                       -fhardcfr-check-exceptions 
-fhardcfr-check-returning-calls \
+                       '-fhardcfr-check-noreturn-calls=*'
+       fi
+
+       # Makes things painfully slow and no real beenfit for the compiler.
+       append-flags $(test-flags-CC -fno-harden-control-flow-redundancy)
+
        # Please use USE=lto instead (bug #906007).
        filter-lto
 

Reply via email to