On Tue, Jan 27, 2026 at 08:26:43AM +0000, Sam James wrote: > Eli Schwartz <[email protected]> writes: > > > Existing use implies a desire to: > > - treat leading "-" as optional > > - query the value of a "flag" > > - query the entire arg of a "-flag" or "-flag=" or really anything other > > than "flag" where CFLAGS has "-flag=*" > > > > But unfortunately we also do odd things like match `get-flag -g` to > > retrieve -grecord-gcc-switches or -fno-gnu-keywords etc. It's a rough > > substring match and really we want to match flag *names*. It is also a > > bit awkward to do "-flag=" and then trim off the flag name by hand. > > > > Update the algorithm to allow for this. Given it's a big change to > > usability, require users to opt in to the new algorithm by migrating > > their ebuilds to EAPI 9 and testing there. They could have been relying > > on what I called a bug. > > > > Some things that will definitely break, but I cannot conceive of why one > > would do it: > > > > - FLAGS="-fno-gnu-keywords"; get-flag -g > > Gross misuse. > > > > - FLAGS="-flto-incremental=/path"; get-flag "-flto-inc*=" > > omitting the = works fine, what is the goal here??? > > Could you add tests too please? > > The change LGTM but give parona a chance to comment on it as he'd > mentioned it to me as well. Ionen may or may not have comments too > as he suffered with this before in ffmpeg, I think.
Changes sound fine to me too, didn't even know it could match
substrings and it sounds ridiculous.
As for what happened with ffmpeg...
Someone before me had used the "omit the -" behaviour which I did
not really know about (doesn't help that the flag-o-matic eclass
docs do not document it and it's instead in some comment inside
the get-flag() function). Then when I changed things around with
wrong assumptions it broke things for some flags and I overlooked
it while focused on other changes.
Then I thought about using that feature properly, but..
-flto=thin -> $(get-flag flto) -> thin
(that's fine, I can pass --enable-lto=thin now)
-flto -> $(get-flag flto) -> -flto
(err, --enable-lto=-flto? I asked for an argument, blank?)
In the end I gave up on that special behaviour, and used
$(get-flag -flto) then --enable-lto${var#-flto} to get consistent
results.
Things could probably be improved here (or at least just docs), but
did not pursue this further.
>
> >
> > Signed-off-by: Eli Schwartz <[email protected]>
> > ---
> > eclass/flag-o-matic.eclass | 23 +++++++++++++++++++----
> > 1 file changed, 19 insertions(+), 4 deletions(-)
> >
> > diff --git a/eclass/flag-o-matic.eclass b/eclass/flag-o-matic.eclass
> > index 1c9abe1280b6..f512702d0800 100644
> > --- a/eclass/flag-o-matic.eclass
> > +++ b/eclass/flag-o-matic.eclass
> > @@ -1,4 +1,4 @@
> > -# Copyright 1999-2025 Gentoo Authors
> > +# Copyright 1999-2026 Gentoo Authors
> > # Distributed under the terms of the GNU General Public License v2
> >
> > # @ECLASS: flag-o-matic.eclass
> > @@ -853,9 +853,24 @@ get-flag() {
> > # `get-flag march` == "i686"
> > for var in $(all-flag-vars) ; do
> > for f in ${!var} ; do
> > - if [ "${f/${findflag}}" != "${f}" ] ; then
> > - printf "%s\n" "${f/-${findflag}=}"
> > - return 0
> > + if [[ ${EAPI} = [78] ]]; then
> > + if [[ "${f/${findflag}}" != "${f}" ]] ; then
> > + printf "%s\n" "${f/-${findflag}=}"
> > + return 0
> > + fi
> > + else
> > + # Print RHS for "flag" (no leading "-")
> > + if [[ "${f#-${findflag}=}" != "${f}" ]] ; then
> > + printf "%s\n" "${f#-${findflag}=}"
> > + return 0
> > + fi
> > + # Print full match for any of:
> > + # "-flag" with leading "-"
> > + # "flag" without leading "-" that has no
> > unmatched succeeding =value
> > + if [[ ${f} = -${findflag#-} || ${f%=*} =
> > ${findflag} ]] ; then
> > + printf "%s\n" "${f}"
> > + return 0
> > + fi
> > fi
> > done
> > done
--
ionen
signature.asc
Description: PGP signature
