commit:     a664bdd217c8f4fbb108d6c2585425383b749b3b
Author:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
AuthorDate: Fri Mar  6 18:29:12 2020 +0000
Commit:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
CommitDate: Fri Mar  6 18:35:50 2020 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a664bdd2

toolchain.eclass: always use -O2, even when no -O is passed in.

Mike noticed that CFLAGS without any optimization options
still effectively are -O0. Let's follow glibc ebuild here
and always use -O2.

Suggested-by: Mike Gilbert
Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>

 eclass/toolchain.eclass | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index d69ce9503ea..05d13189d3d 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -1494,8 +1494,12 @@ downgrade_arch_flags() {
 }
 
 gcc_do_filter_flags() {
-       replace-flags -O? -O2 # 701786 (-O3)
+       # Be conservative here:
+       # - don't allow -O3 and like to over-optimize libgcc # 701786
+       # - don't allow -O0 to generate potentially invalid startup code
        strip-flags
+       filter-flags '-O?'
+       append-flags -O2
 
        # dont want to funk ourselves
        filter-flags '-mabi*' -m31 -m32 -m64

Reply via email to