Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[Solved]Find installed packages where filter-lto was applied
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
costel78
Guru
Guru


Joined: 20 Apr 2007
Posts: 407

PostPosted: Fri Jul 12, 2024 4:01 pm    Post subject: [Solved]Find installed packages where filter-lto was applied Reply with quote

Hello,
I want to find out all packages installed on my system on which filter-lto was applied in ebuild. So far, came with this:

Code:
for f in `emerge -pe world | grep 'ebuild\|binary' | gawk '{print $4;}'` ; do
  n=`emerge --info =$f | grep -E '\bCFLAGS' --count` ;
  if [[ $n -gt 1 ]]; then
    m=`emerge --info =$f | tail -n 5 | grep CFLAGS | grep lto --count`
    if [[ $m -eq 0 ]]; then
      printf '%-65s: %s\t%s\n' "$f" "$n" "$m"
    fi
  fi
done


Instead of emerge -pe world | grep 'ebuild\|binary' | gawk '{print $4;} qlist -I could be use, but I needed exact version/slot.
Is there a better/faster way to archive this ?
Thank you!
_________________
Sorry for my English. I'm still learning this language.


Last edited by costel78 on Fri Jul 12, 2024 5:06 pm; edited 1 time in total
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 22211

PostPosted: Fri Jul 12, 2024 4:10 pm    Post subject: Reply with quote

What about grep --files-without-match -e lto /var/db/pkg/*/*/CFLAGS? The resulting path will have the version embedded in it.
Back to top
View user's profile Send private message
grknight
Retired Dev
Retired Dev


Joined: 20 Feb 2015
Posts: 1809

PostPosted: Fri Jul 12, 2024 4:18 pm    Post subject: Reply with quote

costel78 wrote:
qlist -I could be use, but I needed exact version/slot.

Not withstanding Hu's answer, FWIW, if you need a version from qlist, add -v as it means version and not verbose.
e.g. qlist -Iv or qlist -IvS (for slot and version)
Back to top
View user's profile Send private message
Goverp
Advocate
Advocate


Joined: 07 Mar 2007
Posts: 2074

PostPosted: Fri Jul 12, 2024 4:59 pm    Post subject: Reply with quote

Code:
grep -Rl filter-lto /var/db/pkg

You get a spurious /var/db/pkg on the front, and foo.ebuild on the back, both of which can be trimmed in various ways (exercise left to the reader).

Strictly, it's a list of ebuilds containing filter-lto, and if it's applied conditionally, it will still count even if not actually in effect.
It's faster if you have ripgrep:
Code:
rg -g '*.ebuild' -l filter-lto /var/db/pkg

_________________
Greybeard
Back to top
View user's profile Send private message
costel78
Guru
Guru


Joined: 20 Apr 2007
Posts: 407

PostPosted: Fri Jul 12, 2024 5:05 pm    Post subject: Reply with quote

Hu wrote:
What about grep --files-without-match -e lto /var/db/pkg/*/*/CFLAGS? The resulting path will have the version embedded in it.

Using flto instead of just lto is the faster way.

Thank everyone for support!
_________________
Sorry for my English. I'm still learning this language.
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 22211

PostPosted: Fri Jul 12, 2024 5:22 pm    Post subject: Reply with quote

Goverp wrote:
Code:
grep -Rl filter-lto /var/db/pkg
You get a spurious /var/db/pkg on the front, and foo.ebuild on the back, both of which can be trimmed in various ways (exercise left to the reader).

Strictly, it's a list of ebuilds containing filter-lto, and if it's applied conditionally, it will still count even if not actually in effect.
I think this will also miss packages where the filter-lto runs in an eclass. I see that the eclasses for meson, qt5-build, qt6-build, and toolchain all have the ability to filter-lto, without the corresponding ebuild containing that string. The meson one appears to be removing it as a side effect of telling Meson to enable LTO in some other way, so missing it is fine there.
Back to top
View user's profile Send private message
logrusx
Advocate
Advocate


Joined: 22 Feb 2018
Posts: 2032

PostPosted: Fri Jul 12, 2024 6:54 pm    Post subject: Reply with quote

Hu wrote:
What about grep --files-without-match -e lto /var/db/pkg/*/*/CFLAGS? The resulting path will have the version embedded in it.


man grep wrote:
-L, --files-without-match
Suppress normal output; instead print the name of each input file from which no output would normally have been printed.


This would rather match files that do not contain the search string. OP wants to find packages that contain it. Or am I misunderstanding both of you?

It matched all packages of my install and that's expected since I don't have anything related to lto.

Best Regards,
Georgi
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 22211

PostPosted: Fri Jul 12, 2024 7:18 pm    Post subject: Reply with quote

OP wants to find installed packages which used filter-lto. I took it as unstated that he set CFLAGS="-flto" (and presumably other, not relevant here, options). Therefore, every package which uses filter-lto should fail to have -flto in CFLAGS, because it was filtered; and every package which does not use filter-lto will have -flto in CFLAGS (because OP put it in make.conf, and without a call to filter-lto, it will be passed through the environment). Printing every package which fails to match lto in CFLAGS should find exactly those that actively removed it, which is the set the OP requested.
Back to top
View user's profile Send private message
logrusx
Advocate
Advocate


Joined: 22 Feb 2018
Posts: 2032

PostPosted: Sat Jul 13, 2024 7:43 pm    Post subject: Reply with quote

Hu wrote:
OP wants to find installed packages which used filter-lto. I took it as unstated that he set CFLAGS="-flto" (and presumably other, not relevant here, options). Therefore, every package which uses filter-lto should fail to have -flto in CFLAGS, because it was filtered; and every package which does not use filter-lto will have -flto in CFLAGS (because OP put it in make.conf, and without a call to filter-lto, it will be passed through the environment). Printing every package which fails to match lto in CFLAGS should find exactly those that actively removed it, which is the set the OP requested.


Thanks for the explanation!

Best Regards,
Georgi
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum