commit:     394aed402f624e26ad0e422fd9ddcaeac8ec3772
Author:     Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org>
AuthorDate: Sun Mar 17 09:17:28 2024 +0000
Commit:     Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org>
CommitDate: Sun Mar 17 09:18:17 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=394aed40

toolchain.eclass: Make CET auto-apply x86-64 flags also outside hardened

Signed-off-by: Andreas K. Hüttel <dilfridge <AT> gentoo.org>

 eclass/toolchain.eclass | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index 2acfad8162ac..59d51d9c1e38 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -677,6 +677,11 @@ tc_enable_hardened_gcc() {
                hardened_gcc_flags+=" -DDEF_GENTOO_ZNOW"
        fi
 
+       if _tc_use_if_iuse cet && [[ ${CTARGET} == *x86_64*-linux-gnu* ]] ; then
+               einfo "Updating gcc to use x86-64 control flow protection by 
default ..."
+               hardened_gcc_flags+=" -DEXTRA_OPTIONS_CF"
+       fi
+
        if _tc_use_if_iuse hardened ; then
                # Will add some hardened options as default, e.g. for gcc-12
                # * -fstack-clash-protection
@@ -688,10 +693,6 @@ tc_enable_hardened_gcc() {
                # Add -D_GLIBCXX_ASSERTIONS
                hardened_gcc_flags+=" -DDEF_GENTOO_GLIBCXX_ASSERTIONS"
 
-               if _tc_use_if_iuse cet && [[ ${CTARGET} == *x86_64*-linux* ]] ; 
then
-                       hardened_gcc_flags+=" -DEXTRA_OPTIONS_CF"
-               fi
-
                # Rebrand to make bug reports easier
                BRANDING_GCC_PKGVERSION=${BRANDING_GCC_PKGVERSION/Gentoo/Gentoo 
Hardened}
        fi

Reply via email to