diff --git a/sys-libs/glibc/glibc-2.39-r5.ebuild b/sys-libs/glibc/glibc-2.39-r5.ebuild index 26b5a207975eb..8d816148ab465 100644 --- a/sys-libs/glibc/glibc-2.39-r5.ebuild +++ b/sys-libs/glibc/glibc-2.39-r5.ebuild @@ -447,9 +447,14 @@ setup_flags() { # 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 + + # Allow -O2 and -O3, but nothing else for now. + # TODO: Test -Os, -Oz. + if ! is-flagq '-O@(2|3)' ; then + # Lock glibc at -O2. We want to be conservative here. + filter-flags '-O?' + append-flags -O2 + fi fi strip-unsupported-flags diff --git a/sys-libs/glibc/glibc-9999.ebuild b/sys-libs/glibc/glibc-9999.ebuild index 3a053a9de7243..0cbc0a06f45ee 100644 --- a/sys-libs/glibc/glibc-9999.ebuild +++ b/sys-libs/glibc/glibc-9999.ebuild @@ -447,9 +447,14 @@ setup_flags() { # 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 + + # Allow -O2 and -O3, but nothing else for now. + # TODO: Test -Os, -Oz. + if ! is-flagq '-O@(2|3)' ; then + # Lock glibc at -O2. We want to be conservative here. + filter-flags '-O?' + append-flags -O2 + fi fi strip-unsupported-flags