From 41d8f38ef4686d1dff70fd651266ff57d56a7b06 Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Sun, 8 Nov 2020 10:56:44 +0000 Subject: [PATCH] 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 --- eclass/toolchain.eclass | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass index 32996a2f8f71e..59f8660a3d90a 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