Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 886987 - dev-libs/nspr-4.35 overwrites user's optimization (-O*)
Summary: dev-libs/nspr-4.35 overwrites user's optimization (-O*)
Status: RESOLVED NEEDINFO
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Mozilla Gentoo Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-12-18 14:27 UTC by Agostino Sarubbo
Modified: 2022-12-20 05:56 UTC (History)
0 users

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


Attachments
build.log (build.log,158.08 KB, text/plain)
2022-12-18 14:27 UTC, Agostino Sarubbo
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Agostino Sarubbo gentoo-dev 2022-12-18 14:27:57 UTC
https://blogs.gentoo.org/ago/2020/07/04/gentoo-tinderbox/

Issue: dev-libs/nspr-4.35 overwrites user's optimization (-O*).
Discovered on: amd64 (internal ref: ci)

NOTE:
unless there are known issues with -O* configured by the user, the build system should not overwrite -O*.
Comment 1 Agostino Sarubbo gentoo-dev 2022-12-18 14:27:59 UTC
Created attachment 843407 [details]
build.log

build log and emerge --info
Comment 2 Joonas Niilola gentoo-dev 2022-12-19 13:31:31 UTC
Looks fine to me?
Comment 3 Agostino Sarubbo gentoo-dev 2022-12-19 13:44:16 UTC
(In reply to Joonas Niilola from comment #2)
> Looks fine to me?

At the first compiled file we have:

x86_64-pc-linux-gnu-gcc -o now.o -c     -O2 -pipe -pipe -march=x86-64 -frecord-gcc-switches -fno-diagnostics-color -fmessage-length=0 -Wall -pthread -O2 -fPIC  -UDEBUG -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DNDEBUG=1 -DHAVE_VISIBILITY_HIDDEN_ATTRIBUTE=1 -DHAVE_VISIBILITY_PRAGMA=1 -DXP_UNIX=1 -D_GNU_SOURCE=1 -DHAVE_FCNTL_FILE_LOCKING=1 -DHAVE_POINTER_LOCALTIME_R=1 -DLINUX=1 -DHAVE_DLADDR=1 -DHAVE_GETTID=1 -DHAVE_LCHOWN=1 -DHAVE_SETPRIORITY=1 -DHAVE_STRERROR=1 -DHAVE_SYSCALL=1 -DHAVE_SECURE_GETENV=1 -D_REENTRANT=1 -DFORCE_PR_LOG -D_PR_PTHREADS -UHAVE_CVAR_BUILT_ON_SEM   /var/tmp/portage/dev-libs/nspr-4.35/work/nspr-4.35/nspr/config/now.c

So the latter -O2 will overwrite my -O*, so if I would use -Os, it won't work
Comment 4 Joonas Niilola gentoo-dev 2022-12-19 14:33:18 UTC
# cat /var/db/pkg/dev-libs/nspr-4.35/CFLAGS 
-march=native -O3 -pipe -flto=thin
Comment 5 Agostino Sarubbo gentoo-dev 2022-12-19 14:47:22 UTC
(In reply to Joonas Niilola from comment #4)
> # cat /var/db/pkg/dev-libs/nspr-4.35/CFLAGS 
> -march=native -O3 -pipe -flto=thin

I don't think it works as you mean. These are your CFLAGS (from portage) used in the build and they are different from the flags actually used.

The latest -O (appended from the build system) overwrites the previous
Comment 6 Agostino Sarubbo gentoo-dev 2022-12-19 15:05:22 UTC
Man gcc says:

       If you use multiple -O options, with or without level numbers, the last such option is the one that is effective.


you can also do a test with:
gcc -c -Q -Os -O2 --help=optimizers > /tmp/Os
gcc -c -Q -O2 --help=optimizers > /tmp/O2
diff -ru /tmp/Os /tmp/O2

There will be no differences because in both commands -O2 is used.
Comment 7 Joonas Niilola gentoo-dev 2022-12-19 17:00:04 UTC
Hmm right this wasn't about CFLAGS not being respected. How do I enable this new QA check? Are there some QA project's notes about it somewhere?
Comment 8 Joonas Niilola gentoo-dev 2022-12-19 20:04:32 UTC
... because is there a way to disable the check like QA_CONFIGURE_OPTIONS? I do have an easy fix but it's still going to put the -O* twice, will just match the 2nd with first one. But it's useless if the tinderbox will (falsely) report it again.

And currently I don't know how to "reproduce" the issue, even though I understand where it's coming from.
Comment 9 Agostino Sarubbo gentoo-dev 2022-12-19 20:05:33 UTC
(In reply to Joonas Niilola from comment #7)
> Hmm right this wasn't about CFLAGS not being respected. How do I enable this
> new QA check? Are there some QA project's notes about it somewhere?

This is a custom check that I have enabled in the tinderbox. I didn't find a way to make it suitable for everyone. Basically you can double-check with naked-eye where you can see -O* after your CFLAGS/CXXFLAGS

Another example here: bug 886989
Comment 10 Larry the Git Cow gentoo-dev 2022-12-20 05:56:29 UTC
The bug has been referenced in the following commit(s):

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

commit da32db6eb88ac45e3e3f441e187c8cd596538f03
Author:     Joonas Niilola <juippis@gentoo.org>
AuthorDate: 2022-12-20 05:52:51 +0000
Commit:     Joonas Niilola <juippis@gentoo.org>
CommitDate: 2022-12-20 05:52:51 +0000

    dev-libs/nspr: respect user's CFLAGS optimization
    
     - ... since there's a build system configure option for it.
     - reseted KEYWORDS due to hard to anticipate issues with different
       optimization levels.
    
    Bug: https://bugs.gentoo.org/886987
    Signed-off-by: Joonas Niilola <juippis@gentoo.org>

 dev-libs/nspr/nspr-4.35-r1.ebuild | 159 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 159 insertions(+)