gdb: use libtool in GDB_AC_CHECK_BFD

The GDB_AC_CHECK_BFD macro defined in gdb/acinclude.m4 uses the
AC_LINK_IFELSE autoconf macro in order to link a simple program to
check features of libbfd.

If libbfd's link dependencies change, it was necessary to reflect them
either in the definition of the macro, or as a consequence of checking
for them with an autoconf macro resulting in an addition to LIBS.

This patch modifies the definition of the GDB_CHECK_BFD macro in order
to use libtool to perform the test link.  This makes it possible to
not have to list dependencies of libbfd (which are indirect to GDB) at
all.

After this patch:

  configure:28553: checking for ELF support in BFD
  configure:28573: ./libtool --quiet --mode=link gcc -o conftest \
                   -I../../gdb/../include -I../bfd \
                   -I../../gdb/../bfd -g -O2 \
                   -L../bfd -L../libiberty conftest.c -lbfd -liberty \
                   -lncursesw -lm -ldl  >&5
  configure:28573: $? = 0
  configure:28583: result: yes

Tests performed:

- Configure --with-system-zlib and --without-system-zlib.
- Check link dependencies of installed GDB with both --enable-shared
  and --disable-shared.
- Run installed GDB in both cases.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
This commit is contained in:
Jose E. Marchesi
2022-11-07 20:35:43 +01:00
parent 2c2316c5fd
commit 5218fa9e89
3 changed files with 1652 additions and 11 deletions
+5 -3
View File
@@ -229,14 +229,15 @@ AC_DEFUN([GDB_AC_CHECK_BFD], [
OLD_CFLAGS=$CFLAGS
OLD_LDFLAGS=$LDFLAGS
OLD_LIBS=$LIBS
OLD_CC=$CC
# Put the old CFLAGS/LDFLAGS last, in case the user's (C|LD)FLAGS
# points somewhere with bfd, with -I/foo/lib and -L/foo/lib. We
# always want our bfd.
CFLAGS="-I${srcdir}/../include -I../bfd -I${srcdir}/../bfd $CFLAGS"
ZLIBDIR=`echo $zlibdir | sed 's,\$(top_builddir)/,,g'`
LDFLAGS="-L../bfd -L../libiberty $ZLIBDIR $LDFLAGS"
LDFLAGS="-L../bfd -L../libiberty"
intl=`echo $LIBINTL | sed 's,${top_builddir}/,,g'`
LIBS="-lbfd -liberty -lz $ZSTD_LIBS $intl $LIBS"
LIBS="-lbfd -liberty $intl $LIBS"
CC="./libtool --quiet --mode=link $CC"
AC_CACHE_CHECK(
[$1],
[$2],
@@ -252,6 +253,7 @@ AC_DEFUN([GDB_AC_CHECK_BFD], [
[[$2]=no]
)]
)
CC=$OLD_CC
CFLAGS=$OLD_CFLAGS
LDFLAGS=$OLD_LDFLAGS
LIBS=$OLD_LIBS])
+1644 -8
View File
File diff suppressed because it is too large Load Diff
+3
View File
@@ -49,6 +49,9 @@ AC_ARG_PROGRAM
# We require libtool to link with the in-tree libtool libraries
# the proper way.
LT_INIT
# ... and we need it soon, since it is used by some of the
# link tests in the configure script.
LT_OUTPUT
# We require a C++11 compiler. Check if one is available, and if
# necessary, set CXX_DIALECT to some -std=xxx switch.