* [PATCH][gdb/build] Workaround pcre2_posix linking problem
@ 2021-04-06 13:16 Tom de Vries
2021-04-19 19:44 ` Tom Tromey
0 siblings, 1 reply; 2+ messages in thread
From: Tom de Vries @ 2021-04-06 13:16 UTC (permalink / raw)
To: gdb-patches
Hi,
On openSUSE Tumbleweed, the ncurses package got the --with-pcre2 configure
switch enabled, and solved the resulting dependencies using:
...
$ cat /usr/lib64/libncursesw.so
/* GNU ld script */
-INPUT(/lib64/libncursesw.so.6 AS_NEEDED(-ltinfo -ldl))
+INPUT(/lib64/libncursesw.so.6 AS_NEEDED(-ltinfo -ldl -lpcre2-posix -lpcre2-8))
...
GDB uses the regexp functions regcomp, regerror, regfree, regexec and re_search, see
gdb_regex.c. The latter is a GNU extension.
Due to the changes mentioned above, the first four functions got bound to
lpcre2-posix, while re_search still got bound to lc, resulting in all sorts of
trouble, like hangs or:
...
$ gdb -q -batch -ex "apropos apropos"
Aborted (core dumped)
...
There is a debate whether it's legal to use re_search in combination with regcomp.
Either way, the immediate problem can be fixed/worked-around by adding -lc
before @LIBS@ in the CLIBS def in Makefile.in.
This is something that works with clang++, though not with g++, which drops
-lc, see PR gcc/99896. For g++, we can work around this by using -Wl,-lc
instead.
Add -lc before @LIBS@ in CLIBS def.
Tested on x86_64-linux.
Any comments?
Thanks,
- Tom
[gdb/build] Workaround pcre2_posix linking problem
gdb/ChangeLog:
2021-04-06 Tom de Vries <tdevries@suse.de>
PR build/27681
* Makefile.in (CDEFS): Add @LIBC@ before @LIBS@.
* configure.ac: Define LIBC.
* configure: Regenerate.
---
gdb/Makefile.in | 5 +++--
gdb/configure | 11 +++++++++++
gdb/configure.ac | 8 ++++++++
3 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 3318c1a5215..8bcbd8ea620 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -631,11 +631,12 @@ INTERNAL_LDFLAGS = \
# Libraries and corresponding dependencies for compiling gdb.
# XM_CLIBS, defined in *config files, have host-dependent libs.
-# LIBIBERTY appears twice on purpose.
+# LIBIBERTY appears twice on purpose. LIBC is added before
+# LIBS to ensure that all functions in gdb_regex.c bind to libc.
CLIBS = $(SIM) $(READLINE) $(OPCODES) $(LIBCTF) $(BFD) $(ZLIB) \
$(LIBSUPPORT) $(INTL) $(LIBIBERTY) $(LIBDECNUMBER) \
$(XM_CLIBS) $(GDBTKLIBS) \
- @LIBS@ @GUILE_LIBS@ @PYTHON_LIBS@ \
+ @LIBC@ @LIBS@ @GUILE_LIBS@ @PYTHON_LIBS@ \
$(LIBEXPAT) $(LIBLZMA) $(LIBBABELTRACE) $(LIBIPT) \
$(WIN32LIBS) $(LIBGNU) $(LIBGNU_EXTRA_LIBS) $(LIBICONV) \
$(LIBMPFR) $(LIBGMP) $(SRCHIGH_LIBS) $(LIBXXHASH) $(PTHREAD_LIBS) \
diff --git a/gdb/configure b/gdb/configure
index 4c80350596c..62f852a8ec1 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -728,6 +728,7 @@ HAVE_PYTHON_TRUE
PYTHON_LIBS
PYTHON_CPPFLAGS
PYTHON_CFLAGS
+LIBC
python_prog_path
LTLIBMPFR
LIBMPFR
@@ -11350,6 +11351,16 @@ _ACEOF
fi
fi
+if test "${GCC}" = yes; then
+ # G++ drops -lc, so wrap it using -Wl. See PR gcc/99896.
+ GCC_LIBC="-Wl,-lc"
+ LIBC=$GCC_LIBC
+
+else
+ LIBC=-lc
+
+fi
+
# Check whether --with-python-libdir was given.
if test "${with_python_libdir+set}" = set; then :
diff --git a/gdb/configure.ac b/gdb/configure.ac
index 7035014484e..282bdd7fb74 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -927,6 +927,14 @@ else
fi
fi
+if test "${GCC}" = yes; then
+ # G++ drops -lc, so wrap it using -Wl. See PR gcc/99896.
+ GCC_LIBC="-Wl,-lc"
+ AC_SUBST(LIBC, $GCC_LIBC)
+else
+ AC_SUBST(LIBC, -lc)
+fi
+
dnl Use --with-python-libdir to control where GDB looks for the Python
dnl libraries.
dnl
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH][gdb/build] Workaround pcre2_posix linking problem
2021-04-06 13:16 [PATCH][gdb/build] Workaround pcre2_posix linking problem Tom de Vries
@ 2021-04-19 19:44 ` Tom Tromey
0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2021-04-19 19:44 UTC (permalink / raw)
To: Tom de Vries; +Cc: gdb-patches
>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:
Tom> On openSUSE Tumbleweed, the ncurses package got the --with-pcre2 configure
Tom> switch enabled, and solved the resulting dependencies using:
Tom> ...
Tom> $ cat /usr/lib64/libncursesw.so
Tom> /* GNU ld script */
Tom> -INPUT(/lib64/libncursesw.so.6 AS_NEEDED(-ltinfo -ldl))
Tom> +INPUT(/lib64/libncursesw.so.6 AS_NEEDED(-ltinfo -ldl -lpcre2-posix -lpcre2-8))
Tom> ...
Tom> [gdb/build] Workaround pcre2_posix linking problem
Tom> gdb/ChangeLog:
Tom> 2021-04-06 Tom de Vries <tdevries@suse.de>
Tom> PR build/27681
Tom> * Makefile.in (CDEFS): Add @LIBC@ before @LIBS@.
Tom> * configure.ac: Define LIBC.
Tom> * configure: Regenerate.
Just to be clear, I think this one is also addressed by the other patch
to simply always use the libiberty regex.
On the whole I suppose that one is preferable.
Tom
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-04-19 19:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-06 13:16 [PATCH][gdb/build] Workaround pcre2_posix linking problem Tom de Vries
2021-04-19 19:44 ` Tom Tromey
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).