commit:     ec6ccd63bb77770eeeb8eb220d66efafc91ac572
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sat Dec  7 23:21:14 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Dec  7 23:21:14 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ec6ccd63

toolchain.eclass: pass -fcf-protection=none for stage1 builds with Clang

GCC's host_detect_local_cpu returns NULL when built with Clang (see bug
for details) so pass -fcf-protection=none for stage1 (where it doesn't
really matter anyway) to avoid a failure when -march=native ends up
resolving to nothing (b/c NULL) and then erroring out as CET isn't supported
for the baseline -m32 CPU.

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

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

diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index be8bfcddfafd..565a2f359488 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -2261,6 +2261,13 @@ gcc_do_make() {
                        STAGE1_CXXFLAGS="-O2"
                fi
 
+               # Workaround -march=native not working for stage1 with
+               # non-GCC (bug #933772).
+               if ! tc-is-gcc ; then
+                       STAGE1_CFLAGS+=" $(test-flags-CC -fcf-protection=none)"
+                       STAGE1_CXXFLAGS+=" $(test-flags-CXX 
-fcf-protection=none)"
+               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}"}

Reply via email to