commit:     9ecb3b089082f39a15c4c1a315ed91b388a80ade
Author:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
AuthorDate: Sun May 19 09:15:02 2019 +0000
Commit:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
CommitDate: Sun May 19 09:15:02 2019 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9ecb3b08

sys-libs/glibc: add USE=custom-cflags, bug #686018

Allow users to pass in more (or less) aggressive CFLAGS for
USE=custom-cflags case (disabled by default).

Reported-and-tested-by:Jan Fikar
Bug: https://bugs.gentoo.org/686018
Package-Manager: Portage-2.3.66, Repoman-2.3.12
Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>

 sys-libs/glibc/glibc-9999.ebuild | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/sys-libs/glibc/glibc-9999.ebuild b/sys-libs/glibc/glibc-9999.ebuild
index e39fd36b2f0..6d310a66d32 100644
--- a/sys-libs/glibc/glibc-9999.ebuild
+++ b/sys-libs/glibc/glibc-9999.ebuild
@@ -35,7 +35,7 @@ PATCH_VER=11
 SRC_URI+=" 
https://dev.gentoo.org/~slyfox/distfiles/${P}-patches-${PATCH_VER}.tar.xz";
 SRC_URI+=" multilib? ( 
https://dev.gentoo.org/~dilfridge/distfiles/gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}.tar.xz
 )"
 
-IUSE="audit caps cet compile-locales doc gd headers-only +multiarch multilib 
nscd profile selinux +ssp +static-libs suid systemtap test vanilla"
+IUSE="audit caps cet compile-locales custom-cflags doc gd headers-only 
+multiarch multilib nscd profile selinux +ssp +static-libs suid systemtap test 
vanilla"
 
 # Minimum kernel version that glibc requires
 MIN_KERN_VER="3.2.0"
@@ -345,11 +345,18 @@ setup_flags() {
        ASFLAGS_BASE=${ASFLAGS_BASE-${ASFLAGS}}
        ASFLAGS=${ASFLAGS_BASE}
 
-       # 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
+       # Allow users to explicitly avoid flag sanitization via
+       # USE=custom-cflags.
+       if ! use 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 glibc at -O2; we want to be conservative here.
+               filter-flags '-O?'
+               append-flags -O2
+       fi
        strip-unsupported-flags
        filter-flags -m32 -m64 '-mabi=*'
 
@@ -371,9 +378,9 @@ setup_flags() {
                CBUILD_OPT=${CTARGET_OPT}
        fi
 
-       # Lock glibc at -O2; we want to be conservative here.
-       filter-flags '-O?'
-       append-flags -O2
+       # glibc's headers disallow -O0 and fail at build time:
+       #  include/libc-symbols.h:75:3: #error "glibc cannot be compiled 
without optimization"
+       replace-flags -O0 -O1
 
        filter-flags '-fstack-protector*'
 }

Reply via email to