Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 686018 - sys-libs/glibc-2.29-r2 should not filter out -O3 CFLAG
Summary: sys-libs/glibc-2.29-r2 should not filter out -O3 CFLAG
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-05-15 11:38 UTC by Jan Fikar
Modified: 2019-05-19 09:17 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Fikar 2019-05-15 11:38:12 UTC
glibc has always filtered out -O3 CFLAG and replaced it with -O2, relevant portion of the ebuild file:

        # Lock glibc at -O2; we want to be conservative here.
        # -fno-strict-aliasing is to work around #155906.
        filter-flags '-O?'
        append-flags -O2 -fno-strict-aliasing

On the other hand, Clear Linux is compiling glibc with -O3:

https://github.com/clearlinux-pkgs/glibc/blob/master/glibc.spec

export CFLAGS="-O3  ....


Isn't it time to relax the -O flag restriction in glibc?


The bug #155906 and its workaround -fno-strict-aliasing seems to be obsolete too. It is now 13 years old anyway.
Comment 1 Sergei Trofimovich (RETIRED) gentoo-dev 2019-05-15 18:18:08 UTC
(In reply to Jan Fikar from comment #0)
> glibc has always filtered out -O3 CFLAG and replaced it with -O2, relevant
> portion of the ebuild file:
> 
>         # Lock glibc at -O2; we want to be conservative here.
>         # -fno-strict-aliasing is to work around #155906.
>         filter-flags '-O?'
>         append-flags -O2 -fno-strict-aliasing
> 
> On the other hand, Clear Linux is compiling glibc with -O3:
> 
> https://github.com/clearlinux-pkgs/glibc/blob/master/glibc.spec
> 
> export CFLAGS="-O3  ....
> 
> 
> Isn't it time to relax the -O flag restriction in glibc?

-O? filter is mostly against -O0/-O1 which tends to break glibc.

> The bug #155906 and its workaround -fno-strict-aliasing seems to be obsolete
> too. It is now 13 years old anyway.

Yeah, probably. That flags is a big hammer and should be an upstream setting if set at all.

Can you run glibc testsuite as 'USE=test FEATURES=test emerge -v1 glibc' with and without proposed changes to see if it introduces no regressions?
Comment 2 Jan Fikar 2019-05-16 09:08:14 UTC
I have tried 'USE=test FEATURES=test emerge -v1 glibc' with the original ebuild and I'm getting some fails:

XPASS: elf/tst-protected1a
XPASS: elf/tst-protected1b
UNSUPPORTED: io/tst-getcwd-abspath
FAIL: misc/check-installed-headers-c
FAIL: misc/tst-bz21269
UNSUPPORTED: misc/tst-pkey
UNSUPPORTED: nptl/test-cond-printers
UNSUPPORTED: nptl/test-condattr-printers
UNSUPPORTED: nptl/test-mutex-printers
UNSUPPORTED: nptl/test-mutexattr-printers
UNSUPPORTED: nptl/test-rwlock-printers
UNSUPPORTED: nptl/test-rwlockattr-printers
UNSUPPORTED: nss/tst-nss-files-alias-leak
UNSUPPORTED: nss/tst-nss-files-hosts-erange
UNSUPPORTED: nss/tst-nss-files-hosts-getent
UNSUPPORTED: nss/tst-nss-test3
UNSUPPORTED: posix/tst-sysconf-empty-chroot
FAIL: resolv/tst-resolv-ai_idn
FAIL: resolv/tst-resolv-ai_idn-latin1
UNSUPPORTED: resolv/tst-resolv-threads
FAIL: stdio-common/tst-printfsz-islongdouble
UNSUPPORTED: sunrpc/tst-svc_register
UNSUPPORTED: time/tst-y2039
Summary of test results:
      5 FAIL
   5857 PASS
     16 UNSUPPORTED
     17 XFAIL
      2 XPASS

This is glibc-2.29-r2 with gcc-8.3.0-r1. I guess these fails are expected, aren't they?

So now I'll try with -O3 and see, if there are more fails or not, right?
Comment 3 Sergei Trofimovich (RETIRED) gentoo-dev 2019-05-16 18:28:06 UTC
(In reply to Jan Fikar from comment #2)
> I have tried 'USE=test FEATURES=test emerge -v1 glibc' with the original
> ebuild and I'm getting some fails:
> 
> XPASS: elf/tst-protected1a
> XPASS: elf/tst-protected1b
> UNSUPPORTED: io/tst-getcwd-abspath
> FAIL: misc/check-installed-headers-c
> FAIL: misc/tst-bz21269
> UNSUPPORTED: misc/tst-pkey
> UNSUPPORTED: nptl/test-cond-printers
> UNSUPPORTED: nptl/test-condattr-printers
> UNSUPPORTED: nptl/test-mutex-printers
> UNSUPPORTED: nptl/test-mutexattr-printers
> UNSUPPORTED: nptl/test-rwlock-printers
> UNSUPPORTED: nptl/test-rwlockattr-printers
> UNSUPPORTED: nss/tst-nss-files-alias-leak
> UNSUPPORTED: nss/tst-nss-files-hosts-erange
> UNSUPPORTED: nss/tst-nss-files-hosts-getent
> UNSUPPORTED: nss/tst-nss-test3
> UNSUPPORTED: posix/tst-sysconf-empty-chroot
> FAIL: resolv/tst-resolv-ai_idn
> FAIL: resolv/tst-resolv-ai_idn-latin1
> UNSUPPORTED: resolv/tst-resolv-threads
> FAIL: stdio-common/tst-printfsz-islongdouble
> UNSUPPORTED: sunrpc/tst-svc_register
> UNSUPPORTED: time/tst-y2039
> Summary of test results:
>       5 FAIL
>    5857 PASS
>      16 UNSUPPORTED
>      17 XFAIL
>       2 XPASS
> 
> This is glibc-2.29-r2 with gcc-8.3.0-r1. I guess these fails are expected,
> aren't they?

Yes, they look benign and probably are locale-dependent. Should be fixed separately.

> So now I'll try with -O3 and see, if there are more fails or not, right?

Correct. Please do!
Comment 4 Jan Fikar 2019-05-19 08:11:43 UTC
It seems the -O0 and -O3 flags still get converted to -O2 by 'strip-flags' (line 351). When I comment strip-flags and the other two lines 375-376 (filter-flags, append-flags) the -Ox seems to be transmitted to glibc correctly. Here are the test results:

-O0 glibc itself fails with: 'glibc cannot be compiled without optimization'

-O1 I get 3 extra failed tests when compared to baseline -O2:
FAIL: gmon/tst-gmon-gprof
FAIL: gmon/tst-gmon-pie-gprof
FAIL: gmon/tst-gmon-static-gprof
the files are smaller compared to baseline (-609,692 bytes as reported by 'equery s glibc | cat')

-O2 but without -fno-strict-aliasing produces the same test results as baseline, the files are just slightly bigger (+1846 bytes)

-O3 I get 4 extra failed tests when compared to baseline -O2:
FAIL: elf/tst-audit1
FAIL: elf/tst-audit2
FAIL: elf/tst-audit3
FAIL: elf/tst-audit8
the files are bigger compared to baseline (+1,857,314 bytes)

-Os I get 4 extra failed tests when compared to baseline -O2:
FAIL: elf/tst-execstack
FAIL: elf/tst-execstack-needed
FAIL: elf/tst-execstack-prog
FAIL: nptl/tst-execstack
the files are smaller compared to baseline (-3,001,954 bytes)

Not sure if the extra fails are important or not. Seems we do not need -fno-strict-aliasing flag any more. To stop filtering -Ox flags we need to comment line 351 (strip-flags) and lines 375-376 (filter-flags, append-flags).
Comment 5 Sergei Trofimovich (RETIRED) gentoo-dev 2019-05-19 08:29:59 UTC
(In reply to Jan Fikar from comment #4)
> It seems the -O0 and -O3 flags still get converted to -O2 by 'strip-flags'
> (line 351). When I comment strip-flags and the other two lines 375-376
> (filter-flags, append-flags) the -Ox seems to be transmitted to glibc
> correctly. Here are the test results:
> 
> -O0 glibc itself fails with: 'glibc cannot be compiled without optimization'
> 
> -O1 I get 3 extra failed tests when compared to baseline -O2:
> FAIL: gmon/tst-gmon-gprof
> FAIL: gmon/tst-gmon-pie-gprof
> FAIL: gmon/tst-gmon-static-gprof
> the files are smaller compared to baseline (-609,692 bytes as reported by
> 'equery s glibc | cat')
> 
> -O2 but without -fno-strict-aliasing produces the same test results as
> baseline, the files are just slightly bigger (+1846 bytes)
> 
> -O3 I get 4 extra failed tests when compared to baseline -O2:
> FAIL: elf/tst-audit1
> FAIL: elf/tst-audit2
> FAIL: elf/tst-audit3
> FAIL: elf/tst-audit8
> the files are bigger compared to baseline (+1,857,314 bytes)
> 
> -Os I get 4 extra failed tests when compared to baseline -O2:
> FAIL: elf/tst-execstack
> FAIL: elf/tst-execstack-needed
> FAIL: elf/tst-execstack-prog
> FAIL: nptl/tst-execstack
> the files are smaller compared to baseline (-3,001,954 bytes)
> 
> Not sure if the extra fails are important or not. Seems we do not need
> -fno-strict-aliasing flag any more. To stop filtering -Ox flags we need to
> comment line 351 (strip-flags) and lines 375-376 (filter-flags,
> append-flags).

Thank you for the extensive test! Looks reasonable. We can leave only -O0 mangling into -O1.
Comment 6 Larry the Git Cow gentoo-dev 2019-05-19 08:39:54 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5a00ffa513c9cc38af9a6c573005521fada0b6d7

commit 5a00ffa513c9cc38af9a6c573005521fada0b6d7
Author:     Sergei Trofimovich <slyfox@gentoo.org>
AuthorDate: 2019-05-19 08:33:27 +0000
Commit:     Sergei Trofimovich <slyfox@gentoo.org>
CommitDate: 2019-05-19 08:39:48 +0000

    sys-libs/glibc: drop obsolete -fno-strict-aliasing, bug #686018
    
    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@gentoo.org>

 sys-libs/glibc/glibc-9999.ebuild | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
Comment 7 Larry the Git Cow gentoo-dev 2019-05-19 09:15:23 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9ecb3b089082f39a15c4c1a315ed91b388a80ade

commit 9ecb3b089082f39a15c4c1a315ed91b388a80ade
Author:     Sergei Trofimovich <slyfox@gentoo.org>
AuthorDate: 2019-05-19 09:15:02 +0000
Commit:     Sergei Trofimovich <slyfox@gentoo.org>
CommitDate: 2019-05-19 09:15:02 +0000

    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@gentoo.org>

 sys-libs/glibc/glibc-9999.ebuild | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)
Comment 8 Sergei Trofimovich (RETIRED) gentoo-dev 2019-05-19 09:17:25 UTC
I've added USE=custom-cflags to allow bypassing 'strip-flags' and dropped -O2 forcing. That should allow you to pass more exotic flags.

Will be available in next glibc revbump.