On Mon, Jul 27, 2020 at 12:14 PM H.J. Lu <hjl.to...@gmail.com> wrote:
>
> On Mon, Jul 27, 2020 at 9:11 AM Aaron Merey <ame...@redhat.com> wrote:
> >
> > On Mon, Jul 27, 2020 at 11:32 AM H.J. Lu <hjl.to...@gmail.com> wrote:
> > >
> > > On Sat, Jul 25, 2020 at 9:01 AM H.J. Lu <hjl.to...@gmail.com> wrote:
> > > > This caused:
> > > >
> > > > https://sourceware.org/bugzilla/show_bug.cgi?id=26301
> > > >
> > >
> > > It is quite normal to have debuginfod headers without libdebuginfod on
> > > multilib OSes.  Restore AC_CHECK_LIB to check if libdebuginfod exists.
> > > And always define HAVE_LIBDEBUGINFOD to 0 or 1 for
> > >
> > > binutils/dwarf.c:#if HAVE_LIBDEBUGINFOD
> > > binutils/dwarf.c:#if HAVE_LIBDEBUGINFOD
> > > binutils/dwarf.c:#if HAVE_LIBDEBUGINFOD
> > > binutils/dwarf.h:#if HAVE_LIBDEBUGINFOD
> > > binutils/objdump.c:#if HAVE_LIBDEBUGINFOD
> > > binutils/objdump.c:#endif /* HAVE_LIBDEBUGINFOD */
> > > binutils/readelf.c:#if HAVE_LIBDEBUGINFOD
> > > binutils/readelf.c:#endif /* HAVE_LIBDEBUGINFOD */
> > > gdb/top.c:#if HAVE_LIBDEBUGINFOD
> > >
> > > OK for master?
> >
> > Thanks for spotting this. Normally PKG_CHECH_MODULES would correctly
> > detect whether the .so and header are installed and build accordingly,
> > but when cross compiling the AC_CHECK_LIB may be needed.
>
> I am not cross compiling.  I am simply using "gcc -m32".   The problem
> is PKG_CHECK_MODULES which doesn't check if $pkg_cv_[]$1[]_LIBS
> actually works.   Here is the updated patch to fix PKG_CHECK_MODULES.
> Any comments or objections?
>
>

HAVE_LIBDEBUGINFOD is a separate issue.  Here is the updated patch
which only adds AC_TRY_LINK to PKG_CHECK_MODULES to check if
$pkg_cv_[]$1[]_LIBS works.

-- 
H.J.
From 44682ce298a8ce2b795303d4054ec532847bfcae Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.to...@gmail.com>
Date: Mon, 27 Jul 2020 08:24:15 -0700
Subject: [PATCH] PKG_CHECK_MODULES: Check if $pkg_cv_[]$1[]_LIBS works

It is quite normal to have headers without library on multilib OSes.
Add AC_TRY_LINK to PKG_CHECK_MODULES to check if $pkg_cv_[]$1[]_LIBS
works.

config/

	PR binutils/26301
	* pkg.m4 (PKG_CHECK_MODULES): Add AC_TRY_LINK to check if
	$pkg_cv_[]$1[]_LIBS works.

binutils/

	PR binutils/26301
	* configure: Regenerated.

gdb/

	PR binutils/26301
	* configure: Regenerated.
---
 binutils/configure | 22 ++++++++++++++++++++++
 config/pkg.m4      |  6 ++++++
 gdb/configure      | 22 ++++++++++++++++++++++
 3 files changed, 50 insertions(+)

diff --git a/binutils/configure b/binutils/configure
index c9fc5108e0..4620a6b105 100755
--- a/binutils/configure
+++ b/binutils/configure
@@ -12439,6 +12439,28 @@ fi
     pkg_failed=untried
 fi
 
+pkg_save_LDFLAGS="$LDFLAGS"
+LDFLAGS="$LDFLAGS $pkg_cv_DEBUGINFOD_LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  pkg_failed=no
+else
+  pkg_failed=yes
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LDFLAGS=$pkg_save_LDFLAGS
+
 
 
 if test $pkg_failed = yes; then
diff --git a/config/pkg.m4 b/config/pkg.m4
index 13a8890178..45587e97c8 100644
--- a/config/pkg.m4
+++ b/config/pkg.m4
@@ -147,6 +147,12 @@ AC_MSG_CHECKING([for $2])
 _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
 _PKG_CONFIG([$1][_LIBS], [libs], [$2])
 
+dnl Check whether $pkg_cv_[]$1[]_LIBS works.
+pkg_save_LDFLAGS="$LDFLAGS"
+LDFLAGS="$LDFLAGS $pkg_cv_[]$1[]_LIBS"
+AC_TRY_LINK([],[return 0;], [pkg_failed=no], [pkg_failed=yes])
+LDFLAGS=$pkg_save_LDFLAGS
+
 m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
 and $1[]_LIBS to avoid the need to call pkg-config.
 See the pkg-config man page for more details.])
diff --git a/gdb/configure b/gdb/configure
index adcfa49c63..eb38aaacfc 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -7037,6 +7037,28 @@ fi
     pkg_failed=untried
 fi
 
+pkg_save_LDFLAGS="$LDFLAGS"
+LDFLAGS="$LDFLAGS $pkg_cv_DEBUGINFOD_LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  pkg_failed=no
+else
+  pkg_failed=yes
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LDFLAGS=$pkg_save_LDFLAGS
+
 
 
 if test $pkg_failed = yes; then
-- 
2.26.2

Reply via email to