Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 115203 - equery patch to query for which version of gcc has been used to compile an installed ebuild
Summary: equery patch to query for which version of gcc has been used to compile an in...
Status: RESOLVED WORKSFORME
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Third-Party Tools (show other bugs)
Hardware: All Linux
: High enhancement (vote)
Assignee: Portage Tools Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-12-11 08:48 UTC by Stefano Varesi
Modified: 2015-06-08 23:59 UTC (History)
4 users (show)

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


Attachments
equery gcc patch (gcc-query.patch,6.20 KB, patch)
2005-12-11 08:50 UTC, Stefano Varesi
Details | Diff
equery gcc patch (gcc-query.patch,7.43 KB, patch)
2005-12-11 10:18 UTC, Stefano Varesi
Details | Diff
equery gcc patch (gcc-query.patch,7.46 KB, patch)
2005-12-20 07:11 UTC, Stefano Varesi
Details | Diff
New patch for gentoolkit-0.2.3 (gentoolkit-0.2.3-equery-gcc.patch,7.87 KB, patch)
2007-02-18 13:32 UTC, Stefano Varesi
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Stefano Varesi 2005-12-11 08:48:33 UTC
With this patch you can use equery to know which version of gcc has been used to
compile a package.
Example:
# equery gcc glibc-2.3.6
[ Searching for packages matching glibc-2.3.6-r1 ... ]
* gcc version used for sys-libs/glibc-2.3.6-r1
version: 4.0.2
slot: 4.0

You can also query all /var/db/pkg and have a summary so you can know all the
packages that have been compiled with an old version of gcc. It is usefull if
you use gcc 4, but you have some packages compiled with gcc 3.3 and you don't
want to recompiled your entire system to have a full gcc 4 system.
Example:
#equery gcc --all
[ Searching for gcc used for all packages... ]
  Last installed gcc slot:                         4.0
  Packages installed:                              353
  Packages compiled with a gcc of an old slot:     1
       [SLOT]    [VERSION]
        [3.3]      [3.3.6] sys-process/dcron-2.9-r4


Reproducible: Always
Steps to Reproduce:
1.
2.
3.
Comment 1 Stefano Varesi 2005-12-11 08:50:58 UTC
Created attachment 74507 [details, diff]
equery gcc patch
Comment 2 SpanKY gentoo-dev 2005-12-11 09:13:39 UTC
ROOTPATH is not PATH, nor does the patch take into account custom CC/CXX settings
Comment 3 solar (RETIRED) gentoo-dev 2005-12-11 09:36:35 UTC
This should be taken a step further and poke directly into the ELF and display the 
.comment section. Simply knowing the gcc used to compile a pkg is not enough. You 
need to know what all the linked in objects a given executable were using.

Adding marienz to the CC: as he has a python script to pinpoint exactly 
what I'm talking about.
Comment 4 Stefano Varesi 2005-12-11 10:18:06 UTC
Created attachment 74513 [details, diff]
equery gcc patch

- Corrected ROOTPATH with PATH.
- Added chost, c flags, cxx flags
Comment 5 Stefano Varesi 2005-12-11 10:19:16 UTC
This is an example of the output:
# equery gcc glibc
[ Searching for packages matching glibc ... ]
* gcc version used for sys-libs/glibc-2.3.6-r1
          host: i686-pc-linux-gnu
    C compiler: i686-pc-linux-gnu-gcc
  C++ compiler:
       version: 4.0.2
          slot: 4.0
       C flags: -march=i686 -pipe -O2
     C++ flags: -march=i686 -pipe -O2
Comment 6 Stefano Varesi 2005-12-14 03:06:27 UTC
Ok, I've added the info about CC/CXX settings as requested by SpanKY.
Do you think this patch could be useful?
Comment 7 Stefano Varesi 2005-12-20 07:11:25 UTC
Created attachment 75204 [details, diff]
equery gcc patch

Fixed a stupid error on array manipulation, now the option --all works perfectly
Comment 8 Kevin R André 2007-02-16 22:46:53 UTC
Any chance that this new feature will ever be added to the official equery tool ?
Comment 9 Stefano Varesi 2007-02-18 13:32:25 UTC
Created attachment 110530 [details, diff]
New patch for gentoolkit-0.2.3

The patch has been rewritten to make the code cleaner, simpler and a little faster.
Now it is compatible with gentoolkit-0.2.3_pre3, but not with older versions (surely not with 0.2.2, maybe with 0.2.3_pre{1,2}, but I did't check).
This patch searches for CC, CXX, CFLAGS, CXXFLAGS and CHOST in the vbd tree of a package and, if it finds these files, shows the contents.
The purpose is to show Portage options related to the compiler at the time of the installation of a package, not to show the flags and compiler version grabbed from the generated binary.
To apply the patch, it is sufficient to add this functions to the ebuild:
src_unpack() {
    unpack ${P}.tar.gz
    cd "${WORKDIR}/${P}"
    epatch "${FILESDIR}/${P%_*}-equery-gcc.patch"
}
The sostitution in the epatch line removes the _{pre,rc,whatever}* trailing portion from the ebuild version, hoping the patch will apply to the final 0.2.3 release without change.
Comment 10 Alex Xu (Hello71) 2015-06-08 23:59:33 UTC
(In reply to Stefano Varesi from comment #9)
> Created attachment 110530 [details, diff] [details, diff]
> New patch for gentoolkit-0.2.3
> 
> The patch has been rewritten to make the code cleaner, simpler and a little
> faster.
> Now it is compatible with gentoolkit-0.2.3_pre3, but not with older versions
> (surely not with 0.2.2, maybe with 0.2.3_pre{1,2}, but I did't check).
> This patch searches for CC, CXX, CFLAGS, CXXFLAGS and CHOST in the vbd tree
> of a package and, if it finds these files, shows the contents.
> The purpose is to show Portage options related to the compiler at the time
> of the installation of a package, not to show the flags and compiler version
> grabbed from the generated binary.
> To apply the patch, it is sufficient to add this functions to the ebuild:
> src_unpack() {
>     unpack ${P}.tar.gz
>     cd "${WORKDIR}/${P}"
>     epatch "${FILESDIR}/${P%_*}-equery-gcc.patch"
> }
> The sostitution in the epatch line removes the _{pre,rc,whatever}* trailing
> portion from the ebuild version, hoping the patch will apply to the final
> 0.2.3 release without change.

I have not tested this patch, but it appears that it cannot work any more since PATH is not in environment.bz2. It further appears that there is no information that can be used to find the gcc version either in the vdb or in the binary itself. It is possible to scan the debug files, however this is no longer Portage-specific.

Furthermore, the other functions listed have been added to emerge --info sometime in the interim ("Package settings").

Therefore, I am closing this bug as WORKSFORME.