toolchain.eclass: always use -O2, even when no -O is passed in.
authorSergei Trofimovich <slyfox@gentoo.org>
Fri, 6 Mar 2020 18:29:12 +0000 (18:29 +0000)
committerSergei Trofimovich <slyfox@gentoo.org>
Fri, 6 Mar 2020 18:35:50 +0000 (18:35 +0000)
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@gentoo.org>
eclass/toolchain.eclass

index d69ce9503eaa93fd9b5d1f106a21c3424155ea44..05d13189d3ddd3be0c0e256eab0305c176ecec11 100644 (file)
@@ -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