commit: 41d8f38ef4686d1dff70fd651266ff57d56a7b06
Author: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
AuthorDate: Sun Nov 8 10:56:44 2020 +0000
Commit: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
CommitDate: Sun Nov 8 11:40:32 2020 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=41d8f38e
toolchain.eclass: add USE=custom-cflags for gcc-11
Sometimes it's useful to build gcc quickly with CFLAGS=-O0
as a smoke test for sanity. CFLAGS=-O3 should also generally
work as a code generation stres test. But not in general case.
Some options like -flto would probably not work as is.
Let's allow users to experiment with gcc flags if they really
want to.
Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>
eclass/toolchain.eclass | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index 32996a2f8f7..59f8660a3d9 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -181,6 +181,7 @@ if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then
tc_version_is_at_least 9.1 && IUSE+=" lto"
tc_version_is_at_least 10 && IUSE+=" zstd" TC_FEATURES+=(zstd)
tc_version_is_at_least 11 && IUSE+=" valgrind" TC_FEATURES+=(valgrind)
+ tc_version_is_at_least 11 && IUSE+=" custom-cflags"
fi
if tc_version_is_at_least 10; then
@@ -1391,12 +1392,18 @@ downgrade_arch_flags() {
}
gcc_do_filter_flags() {
- # 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
+ # Allow users to explicitly avoid flag sanitization via
+ # USE=custom-cflags.
+ if ! _tc_use_if_iuse custom-cflags; then
+ # Over-zealous CFLAGS can often cause problems. What may work
for one
+ # person may not work for another. To avoid a large influx of
bugs
+ # relating to failed builds, we strip most CFLAGS out to ensure
as few
+ # problems as possible.
+ strip-flags
+ # Lock gcc at -O2; we want to be conservative here.
+ filter-flags '-O?'
+ append-flags -O2
+ fi
# dont want to funk ourselves
filter-flags '-mabi*' -m31 -m32 -m64