Bug 30043 - libgprofng.so.* are installed to a wrong location
Summary: libgprofng.so.* are installed to a wrong location
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: gprofng (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Vladimir Mezentsev
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-01-24 14:59 UTC by Martin Liska
Modified: 2023-02-02 08:16 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Liska 2023-01-24 14:59:16 UTC
When I configure binutils with:
../configure --prefix=/tmp/install-dir --libdir=/tmp/install-libdir --with-pic --enable-shared

libgprofng.so.* gets wrongly installed to gprofng subdirectory
/tmp/install-libdir/gprofng/

$ find /tmp/install-libdir
/tmp/install-libdir
/tmp/install-libdir/libinproctrace.so
/tmp/install-libdir/bfd-plugins
/tmp/install-libdir/bfd-plugins/libdep.so
/tmp/install-libdir/libctf-nobfd.a
/tmp/install-libdir/libctf.a
/tmp/install-libdir/libctf-nobfd.la
/tmp/install-libdir/libctf-nobfd.so
/tmp/install-libdir/libctf-nobfd.so.0
/tmp/install-libdir/libctf-nobfd.so.0.0.0
/tmp/install-libdir/libctf.la
/tmp/install-libdir/libctf.so
/tmp/install-libdir/libctf.so.0
/tmp/install-libdir/libctf.so.0.0.0
/tmp/install-libdir/gprofng
/tmp/install-libdir/gprofng/libgprofng.so
/tmp/install-libdir/gprofng/libgprofng.so.0
/tmp/install-libdir/gprofng/libgprofng.so.0.0.0
/tmp/install-libdir/gprofng/libgp-iotrace.so
/tmp/install-libdir/gprofng/libgp-sync.so
/tmp/install-libdir/gprofng/libgp-heap.so
/tmp/install-libdir/gprofng/libgp-collectorAPI.so
/tmp/install-libdir/gprofng/libgp-collector.so
/tmp/install-libdir/libopcodes.a
/tmp/install-libdir/libopcodes.la
/tmp/install-libdir/libopcodes.so
/tmp/install-libdir/libopcodes-2.40.50.20230123.so
/tmp/install-libdir/libbfd.a
/tmp/install-libdir/libbfd.la
/tmp/install-libdir/libbfd.so
/tmp/install-libdir/libbfd-2.40.50.20230123.so
/tmp/install-libdir/libsframe.a
/tmp/install-libdir/libsframe.la
/tmp/install-libdir/libsframe.so
/tmp/install-libdir/libsframe.so.0
/tmp/install-libdir/libsframe.so.0.0.0

while it should be similarly to other libs like libctf.so* be placed to libdir top-level folder.
Comment 1 Vladimir Mezentsev 2023-01-24 23:07:56 UTC
This is not a bug. Not all binutils libraries are installed in $(libdir).
See, for example, /tmp/install-libdir/bfd-plugins/ in your installation.

We install the gprofng libraries in $(pkglibdir).
See Bug 28972 - gprofng libraries should be installed under $(pkglibdir):
 
H.J. Lu 2022-03-16 17:21:03 UTC
Currently gprofng libraries are installed under $(libdir).  I
believe that they should be installed under $(pkglibdir).


Can we close this bug as RESOLVED/NOTABUG ?
Comment 2 Martin Liska 2023-01-25 08:57:01 UTC
(In reply to Vladimir Mezentsev from comment #1)
> This is not a bug. Not all binutils libraries are installed in $(libdir).
> See, for example, /tmp/install-libdir/bfd-plugins/ in your installation.

Yes, I would expect something similar for gprofng, where 

/tmp/install-libdir/gprofng/libgp-iotrace.so
/tmp/install-libdir/gprofng/libgp-sync.so
/tmp/install-libdir/gprofng/libgp-heap.so
/tmp/install-libdir/gprofng/libgp-collectorAPI.so
/tmp/install-libdir/gprofng/libgp-collector.so

are similar to bfd-plugins, while the main library should be places in $(libdir):

/tmp/install-libdir/libgprofng.so
/tmp/install-libdir/libgprofng.so.0
/tmp/install-libdir/libgprofng.so.0.0.0

similarly to e.g. libctf.so.0.0.0.

Does it make sense?
Comment 3 Michael Matz 2023-01-25 14:12:00 UTC
Proper shared libraries (those which programs link against via DT_NEEDED) have
to be placed in directories in which the dynamic linker searches for them.  You can play games with DT_RUNPATH of course but that would not be the normal action.

So, shared libraries need to be placed in $(libdir).  What you are talking about are dynamic modules: ELF DSOs intended for dlopen, i.e. to be loaded at runtime.
Usually the difference is already visual in the filenames: shared libs have major.minor.micro version files and the foobar.so file is a symlink.  Modules
have just the .so file (and are usually not named 'lib*', though that's a convention not always followed).

So the DSOs you create for modules (the collector stuff) indeed is properly placed into $(pkglibdir), but the shared library libgprofng.so.0 (which we know is one because the gprofng binary links against it) needs to be put into $(libdir).

I don't know why H.J. suggested to put it into $(pkglibdir) but it's an incorrect
advise.
Comment 4 Sourceware Commits 2023-01-26 19:05:15 UTC
The master branch has been updated by Vladimir Mezentsev <vmezents@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=2b304f501f1fe7ca0a27a6e672fd9cf8f289b4eb

commit 2b304f501f1fe7ca0a27a6e672fd9cf8f289b4eb
Author: Vladimir Mezentsev <vladimir.mezentsev@oracle.com>
Date:   Wed Jan 25 19:21:38 2023 -0800

    gprofng: PR30043 libgprofng.so.* are installed to a wrong location
    
    gprofng/ChangeLog
    2023-01-25  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>
    
            PR gprofng/30043
            PR gprofng/28972
            * src/Makefile.am: Use lib_LTLIBRARIES instead of pkglib_LTLIBRARIES.
            * src/Makefile.in: Rebuild.
Comment 5 Sourceware Commits 2023-01-26 19:57:40 UTC
The binutils-2_40-branch branch has been updated by Vladimir Mezentsev <vmezents@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=edd36b26f3506eeb259534ba2493e15c728cd280

commit edd36b26f3506eeb259534ba2493e15c728cd280
Author: Vladimir Mezentsev <vladimir.mezentsev@oracle.com>
Date:   Wed Jan 25 19:21:38 2023 -0800

    gprofng: PR30043 libgprofng.so.* are installed to a wrong location
    
    gprofng/ChangeLog
    2023-01-25  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>
    
            PR gprofng/30043
            PR gprofng/28972
            * src/Makefile.am: Use lib_LTLIBRARIES instead of pkglib_LTLIBRARIES.
            * src/Makefile.in: Rebuild.
Comment 6 Vladimir Mezentsev 2023-02-01 20:31:32 UTC
Fixed in the master and binutils-2_40-branch branches.
Comment 7 Martin Liska 2023-02-02 08:16:17 UTC
Thank you for the fix, looks fine now.