summaryrefslogtreecommitdiff
path: root/eclass/toolchain.eclass
diff options
context:
space:
mode:
Diffstat (limited to 'eclass/toolchain.eclass')
-rw-r--r--eclass/toolchain.eclass19
1 files changed, 13 insertions, 6 deletions
diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index 32996a2f8f71..59f8660a3d90 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