Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 887247 - flag-o-matic.eclass: Add a new function to return/change optimization level
Summary: flag-o-matic.eclass: Add a new function to return/change optimization level
Status: RESOLVED UPSTREAM
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-12-19 17:26 UTC by Joonas Niilola
Modified: 2022-12-19 17:50 UTC (History)
1 user (show)

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 Joonas Niilola gentoo-dev 2022-12-19 17:26:02 UTC
With apparently a new QA check checking for "overwrites user's optimization (-O*)" filed by ago, I believe it'd be fruitful to have a function to return/change optimization in user's current CFLAGS. I'm currently using:

src_configure() {
  local cflagsoptimization=$(echo "${CFLAGS}" | awk '/-O/ { print $2 }')
  ...
  $(use_enable !debug optimize="${cflagsoptimization}")

which, without a doubt, will have some conflicts so can you come up with something better since you know more about *FLAGS :)
Comment 1 Ionen Wolkens gentoo-dev 2022-12-19 17:45:44 UTC
These work already:

    my_o=$(get-flag '-O*')

    replace-flags '-O*' -O2

No other compiler option starts with -O, so I don't think there's worth in checking for valid -Osomething values.
Comment 2 Joonas Niilola gentoo-dev 2022-12-19 17:47:14 UTC
Pfft yeah my brains are already on holiday. Also the example I showed doesn't take into account if multiple occurrences appear, wonder if get-flag does any better though. I'll go with that, thanks!
Comment 3 Ionen Wolkens gentoo-dev 2022-12-19 17:50:47 UTC
(In reply to Joonas Niilola from comment #2)
> Pfft yeah my brains are already on holiday. Also the example I showed
> doesn't take into account if multiple occurrences appear, wonder if get-flag
> does any better though. I'll go with that, thanks!
But yeah, get-flag isn't the smartest tool in the shed, it gets the first match of the first variable which probably doesn't make much sense for any flags (could have different -O in CXXFLAGS and such too)

(In reply to Ionen Wolkens from comment #1)
> No other compiler option starts with -O, so I don't think there's worth in
> checking for valid -Osomething values.
At least gcc afaik anyway, haven't checked much.