public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: "Maciej W. Rozycki" <macro@embecosm.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 1/3] GDB: Run `pkg-config' with `--static' to pull libguile dependencies
Date: Thu, 24 Nov 2022 23:51:09 +0000 (GMT)	[thread overview]
Message-ID: <alpine.DEB.2.20.2211241907010.19931@tpp.orcam.me.uk> (raw)
In-Reply-To: <alpine.DEB.2.20.2211241701270.19931@tpp.orcam.me.uk>

Fix a configuration error:

checking whether to use guile... guile-2.2
checking for pkg-config... /usr/bin/pkg-config
checking for usable guile from /usr/bin/pkg-config... checking for scm_set_automatic_finalization_enabled... no
configure: error: in `.../gdb':
configure: error: linking guile version guile-2.2 test program failed
See `config.log' for more details
make[1]: *** [Makefile:12160: configure-gdb] Error 1

coming from link errors as recorded in `config.log' referred:

configure:19349: checking for scm_set_automatic_finalization_enabled
configure:19349: gcc -o conftest -pipe -O2      -pthread -I.../include/guile/2.2   conftest.c -lncursesw -lm -ldl  -L.../lib -lguile-2.2 -lgc >&5
/usr/bin/ld: .../lib/libguile-2.2.a(libguile_2.2_la-ports.o): in function `scm_ungetc':
(.text+0x5561): undefined reference to `u32_conv_to_encoding'
/usr/bin/ld: (.text+0x56e1): undefined reference to `u32_to_u8'

etc., etc., in a valid configuration where a static version of libguile 
has only been installed, which is a pefectly valid system configuration.  
This is due to symbols being required from libguile's dependencies that 
have not been included in the linker invocation.

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.

Therefore fix the issue by using the `--static' option unconditionally 
with `pkg-config', adding the dependencies required:

configure:19349: gcc -o conftest -pipe -O2      -pthread -I.../include/guile/2.2   conftest.c -lncursesw -lm -ldl  -L.../lib -lguile-2.2 -lgc -lgmp -lltdl -lffi -lunistring -lcrypt -lm >&5

and removing the errors quoted above.
---
 gdb/configure    |   10 +++++-----
 gdb/configure.ac |    6 +++---
 2 files changed, 8 insertions(+), 8 deletions(-)

gdb-pkgconfig-static.diff
Index: src/gdb/configure
===================================================================
--- src.orig/gdb/configure
+++ src/gdb/configure
@@ -22917,7 +22917,7 @@ $as_echo_n "checking for usable guile fr
     if test $? != 0; then
       as_fn_error $? "failure running pkg-config --cflags ${guile_version}" "$LINENO" 5
     fi
-    new_LIBS=`${pkg_config} --libs ${guile_version}`
+    new_LIBS=`${pkg_config} --static --libs ${guile_version}`
     if test $? != 0; then
       as_fn_error $? "failure running pkg-config --libs ${guile_version}" "$LINENO" 5
     fi
@@ -23001,7 +23001,7 @@ $as_echo_n "checking for usable guile fr
     if test $? != 0; then
       as_fn_error $? "failure running pkg-config --cflags ${guile_version}" "$LINENO" 5
     fi
-    new_LIBS=`${pkg_config} --libs ${guile_version}`
+    new_LIBS=`${pkg_config} --static --libs ${guile_version}`
     if test $? != 0; then
       as_fn_error $? "failure running pkg-config --libs ${guile_version}" "$LINENO" 5
     fi
@@ -23082,7 +23082,7 @@ $as_echo_n "checking for usable guile fr
     if test $? != 0; then
       as_fn_error $? "failure running pkg-config --cflags ${guile_version}" "$LINENO" 5
     fi
-    new_LIBS=`${pkg_config} --libs ${guile_version}`
+    new_LIBS=`${pkg_config} --static --libs ${guile_version}`
     if test $? != 0; then
       as_fn_error $? "failure running pkg-config --libs ${guile_version}" "$LINENO" 5
     fi
@@ -23173,7 +23173,7 @@ $as_echo_n "checking for usable guile fr
     if test $? != 0; then
       as_fn_error $? "failure running pkg-config --cflags ${guile_version}" "$LINENO" 5
     fi
-    new_LIBS=`${pkg_config} --libs ${guile_version}`
+    new_LIBS=`${pkg_config} --static --libs ${guile_version}`
     if test $? != 0; then
       as_fn_error $? "failure running pkg-config --libs ${guile_version}" "$LINENO" 5
     fi
@@ -23418,7 +23418,7 @@ $as_echo "no - pkg-config not found" >&6
       esac
 
       srchigh_pkg_cflags=`${pkg_config_prog_path} --cflags source-highlight`
-      srchigh_pkg_libs=`${pkg_config_prog_path} --libs source-highlight`
+      srchigh_pkg_libs=`${pkg_config_prog_path} --static --libs source-highlight`
 
       # Now that we have found a source-highlight library, check if we can use
       # it.  In particular, we're trying to detect the situation that the
Index: src/gdb/configure.ac
===================================================================
--- src.orig/gdb/configure.ac
+++ src/gdb/configure.ac
@@ -1020,7 +1020,7 @@ AC_DEFUN([AC_TRY_LIBGUILE],
     if test $? != 0; then
       AC_MSG_ERROR([failure running pkg-config --cflags ${guile_version}])
     fi
-    new_LIBS=`${pkg_config} --libs ${guile_version}`
+    new_LIBS=`${pkg_config} --static --libs ${guile_version}`
     if test $? != 0; then
       AC_MSG_ERROR([failure running pkg-config --libs ${guile_version}])
     fi
@@ -1082,7 +1082,7 @@ dnl        NOTE: This needn't be the "re
 dnl        It could be a shell script.  It is invoked as:
 dnl        pkg-config --exists $version
 dnl        pkg-config --cflags $version
-dnl        pkg-config --libs $version
+dnl        pkg-config --static --libs $version
 dnl        pkg-config --variable guild $version
 dnl        The script will be called with $version having each value in
 dnl        $try_guile_versions until --exists indicates success.
@@ -1212,7 +1212,7 @@ either use --disable-source-highlight or
       esac
 
       srchigh_pkg_cflags=`${pkg_config_prog_path} --cflags source-highlight`
-      srchigh_pkg_libs=`${pkg_config_prog_path} --libs source-highlight`
+      srchigh_pkg_libs=`${pkg_config_prog_path} --static --libs source-highlight`
 
       # Now that we have found a source-highlight library, check if we can use
       # it.  In particular, we're trying to detect the situation that the

  reply	other threads:[~2022-11-24 23:51 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 ` Maciej W. Rozycki [this message]
2022-11-25  7:56   ` [PATCH 1/3] GDB: Run `pkg-config' with `--static' to pull libguile dependencies Eli Zaretskii
2022-11-28 12:59     ` Maciej W. Rozycki
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.2211241907010.19931@tpp.orcam.me.uk \
    --to=macro@embecosm.com \
    --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).