public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: "Maciej W. Rozycki" <macro@embecosm.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 1/3] GDB: Run `pkg-config' with `--static' to pull libguile dependencies
Date: Mon, 28 Nov 2022 12:59:52 +0000 (GMT)	[thread overview]
Message-ID: <alpine.DEB.2.20.2211272338130.19931@tpp.orcam.me.uk> (raw)
In-Reply-To: <83pmdbv55m.fsf@gnu.org>

On Fri, 25 Nov 2022, Eli Zaretskii wrote:

> > In configurations using the ELF format dynamic libguile implicitly pulls 
> > indirect dependencies in the link, but to satisfy static libguile they 
> > need to be named explicitly.  These dependencies have been recorded and 
> > can be supplied by `pkg-config', but for that to happen the tool has to 
> > be invoked with the `--static' option in addition to `--libs'.  Moreover 
> > it is recommended, at least with systems using the ELF format, to have 
> > indirect dependencies included with static linker invocation even where 
> > they all are satisfied by dynamic libraries.
> 
> If only a static version of the Guile library is installed, how come
> "pkg-config --libs" doesn't produce the list of all the dependency libraries
> for static linking?  Isn't that a bug in Guile installation on that system?

 If anything, it's a bug in Guile itself, or more likely a design issue 
with pkg-config.  Looking at its .pc template I can see no provision for a 
different library arrangement depending on whether `--enable-shared' or 
`--disable-shared' is in effect with `configure':

Libs: -L${libdir} -lguile-@GUILE_EFFECTIVE_VERSION@ @BDW_GC_LIBS@
Libs.private: @LIB_CLOCK_GETTIME@ @LIBGMP@ @LIBLTDL@ @LIBFFI_LIBS@	\
  @LIBUNISTRING@ @GUILE_LIBS@ @LIBICONV@ @LIBINTL@ @LIBSOCKET@		\
  @SERVENT_LIB@ @HOSTENT_LIB@ @GETADDRINFO_LIB@ @INET_NTOP_LIB@		\
  @INET_PTON_LIB@

 I have skimmed over the very few .pc templates I could find around on my 
system and they all seem to do essentially the same.  For example have a 
look at zlib/contrib/minizip/minizip.pc.in in our very own tree.  While 
not used by us it's taken verbatim from the upstream zlib distribution and 
supplied with libminizip, which has a dependency on libz.

 But the template has just:

Libs: -L${libdir} -lminizip
Libs.private: -lz

i.e. it's all fixed with no `configure' processing whatsoever and there is 
no provision for pulling `-lz' unless `--static' has been explicitly given 
to `pkg-config'.

 But any such provision looks to me like a lot of effort for software 
writers, to take away which is the very purpose of pkg-config.  So what I 
think pkg-config should do is to provide a flag for the .pc file to be set 
by `configure' or otherwise, which would tell pkg-config that said package 
has been built with no shared libraries available, via `--disable-shared' 
or an equivalent.

 In such a case pkg-config would always include Libs.private along with 
Libs when requested by `--libs', even if no `--static' option has been 
given.  Which leads me to a conclusion it's an oversight in the pkg-config 
design that it does not provide for the static-only link scenario in a 
reasonable way.

> > Therefore fix the issue by using the `--static' option unconditionally 
> > with `pkg-config', adding the dependencies required:
> 
> I don't think I've every seen a configure script that explicitly includes
> the --static switch to pkg-config.  Did you?  If not, how do they deal with
> this issue?  Almost any external library with which GDB is linked can be
> installed as a static-only library, so do we need to use --static in all
> pkg-config tests?  I see that your proposed patch only changes the tests for
> Guile and for source-highlight libraries.

 It seems to me that distributions universally build libraries as shared 
and do not provide for installing static libraries without their shared 
counterparts.  And that people hardly ever build from sources nowadays.

 So it looks to me like this issue is not dealt with at all, and while we 
might try to fix the world outside, it could be a futile effort.  And in 
any case it'd be long until any solution lands downstream.  Then as I say 
indirect dependencies are best included in ELF links involving dynamic 
shared objects anyway, so I think using `--static' is in my opinion a 
reasonable solution.  I think it's also needed for the `CFLAGS=-static' 
case too.  Cf. <https://bugs.freedesktop.org/show_bug.cgi?id=19541>.

 I haven't looked at pieces coming from outside gdb/, and I can see now 
that the debuginfod library isn't handled at this point (I don't know if 
it has any indirect dependencies).  It's use here is a strong argument in 
favour of 3/3, so that we don't use $pkg_config and $PKG_CONFIG variables 
both at a time for the same thing in a single script (what a mess!).

 Do you find my observations a sufficient justification for my proposed 
change now?  Thank you for your insights!

  Maciej

  reply	other threads:[~2022-11-28 13:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-24 23:50 [PATCH 0/3] GDB: Fix `pkg-config' issues with configuring for Guile Maciej W. Rozycki
2022-11-24 23:51 ` [PATCH 1/3] GDB: Run `pkg-config' with `--static' to pull libguile dependencies Maciej W. Rozycki
2022-11-25  7:56   ` Eli Zaretskii
2022-11-28 12:59     ` Maciej W. Rozycki [this message]
2022-11-28 13:35       ` Eli Zaretskii
2022-11-24 23:51 ` [PATCH 2/3] GDB: Permit a lone version of Guile with `--with-guile=' Maciej W. Rozycki
2022-11-26 23:38   ` Mike Frysinger
2022-11-28 13:00     ` Maciej W. Rozycki
2022-11-24 23:51 ` [PATCH 3/3] GDB: Use standard autoconf macros for `pkg-config' Maciej W. Rozycki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.20.2211272338130.19931@tpp.orcam.me.uk \
    --to=macro@embecosm.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).