[PATCH] config/debuginfod.m4: Restore AC_CHECK_LIB check

H.J. Lu
2020-07-27T15:32:32Z

[-- Attachment #1: Type: text/plain, Size: 1701 bytes --]

On Sat, Jul 25, 2020 at 9:01 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Fri, Jul 24, 2020 at 1:04 PM Aaron Merey via Gcc-patches
> <gcc-patches@gcc.gnu.org> wrote:
> >
> > On Tue, Jul 21, 2020 at 2:11 PM Aaron Merey <amerey@redhat.com> wrote:
> > >
> > > On Tue, Jul 21, 2020 at 11:20 AM Tom Tromey <tom@tromey.com> wrote:
> > > >
> > > > Simon> Since it's debuginfo.m4 that is using PKG_CHECK_MODULES, can you put the include
> > > > Simon> of pkg.m4 in debuginfo.m4, instead of in {binutils,gdb}/configure.ac?
> > > >
> > > > Simon> Otherwise, from GDB's point of view I think it looks good, unless
> > > > Simon> Tom has some things to add.
> > > >
> > > > I'm happy with it. Thanks for persevering.
> > >
> > > Great. I can push to binutils-gdb but not gcc. Should I just push to
> > > binutils-gdb for now or wait until the patch can be applied to both
> > > repos at once?
> >
> > I'm going to go ahead and push to binutils-gdb. Since these changes
> > should not affect gcc there shouldn't be any conflicts.
> >
>
> 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?

--
H.J.

[-- Attachment #2: 0001-config-debuginfod.m4-Restore-AC_CHECK_LIB-check.patch --]
[-- Type: text/x-patch, Size: 12084 bytes --]

From 975f68898817f2db13c5d7061fb6e6a9147b06aa Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Mon, 27 Jul 2020 08:24:15 -0700
Subject: [PATCH] config/debuginfod.m4: Restore AC_CHECK_LIB check

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

config/

PR binutils/26301
* debuginfod.m4 (AC_DEBUGINFOD): Restore AC_CHECK_LIB to check if
libdebuginfod exists.

binutils/

PR binutils/26301
* configure: Regenerated.

gdb/

PR binutils/26301
* configure: Regenerated.
---
binutils/configure | 88 +++++++++++++++++++++++++++++++++++++-------
config/debuginfod.m4 | 14 +++++--
gdb/configure | 88 +++++++++++++++++++++++++++++++++++++-------
3 files changed, 161 insertions(+), 29 deletions(-)

diff --git a/binutils/configure b/binutils/configure
index c9fc5108e0..02d33cb5ed 100755
--- a/binutils/configure
+++ b/binutils/configure
@@ -12398,6 +12398,7 @@ $as_echo_n "checking whether to use debuginfod... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_debuginfod" >&5
$as_echo "$with_debuginfod" >&6; }

+have_libdebuginfod=0
if test "x$with_debuginfod" != xno; then

pkg_failed=no
@@ -12458,35 +12459,96 @@ fi
# Put the nasty error message in config.log where it belongs
echo "$DEBUGINFOD_PKG_ERRORS" >&5

- if test "x$with_debuginfod" = xyes; then
- as_fn_error $? "\"--with-debuginfod was given, but libdebuginfod is missing or unusable.\"" "$LINENO" 5
- else
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libdebuginfod is missing or unusable; some features may be unavailable." >&5
-$as_echo "$as_me: WARNING: libdebuginfod is missing or unusable; some features may be unavailable." >&2;}
- fi
+ as_fn_error $? "Package requirements (libdebuginfod >= 0.179) were not met:
+
+$DEBUGINFOD_PKG_ERRORS
+
+Consider adjusting the PKG_CONFIG_PATH environment variable if you
+installed software in a non-standard prefix.
+
+Alternatively, you may set the environment variables DEBUGINFOD_CFLAGS
+and DEBUGINFOD_LIBS to avoid the need to call pkg-config.
+See the pkg-config man page for more details." "$LINENO" 5
elif test $pkg_failed = untried; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
- if test "x$with_debuginfod" = xyes; then
- as_fn_error $? "\"--with-debuginfod was given, but libdebuginfod is missing or unusable.\"" "$LINENO" 5
- else
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libdebuginfod is missing or unusable; some features may be unavailable." >&5
-$as_echo "$as_me: WARNING: libdebuginfod is missing or unusable; some features may be unavailable." >&2;}
- fi
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it
+is in your PATH or set the PKG_CONFIG environment variable to the full
+path to pkg-config.
+
+Alternatively, you may set the environment variables DEBUGINFOD_CFLAGS
+and DEBUGINFOD_LIBS to avoid the need to call pkg-config.
+See the pkg-config man page for more details.
+
+To get pkg-config, see <http://pkg-config.freedesktop.org/>.
+See \`config.log' for more details" "$LINENO" 5; }
else
DEBUGINFOD_CFLAGS=$pkg_cv_DEBUGINFOD_CFLAGS
DEBUGINFOD_LIBS=$pkg_cv_DEBUGINFOD_LIBS
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for debuginfod_begin in -ldebuginfod" >&5
+$as_echo_n "checking for debuginfod_begin in -ldebuginfod... " >&6; }
+if ${ac_cv_lib_debuginfod_debuginfod_begin+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldebuginfod $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */

-$as_echo "#define HAVE_LIBDEBUGINFOD 1" >>confdefs.h
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char debuginfod_begin ();
+int
+main ()
+{
+return debuginfod_begin ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_lib_debuginfod_debuginfod_begin=yes
+else
+ ac_cv_lib_debuginfod_debuginfod_begin=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_debuginfod_debuginfod_begin" >&5
+$as_echo "$ac_cv_lib_debuginfod_debuginfod_begin" >&6; }
+if test "x$ac_cv_lib_debuginfod_debuginfod_begin" = xyes; then :
+ have_libdebuginfod=1
+fi

fi
+ if test "x$have_libdebuginfod" = "x0"; then
+ DEBUGINFOD_LIBS=
+ if test "x$with_debuginfod" = xyes; then
+ as_fn_error $? "\"--with-debuginfod was given, but libdebuginfod is missing or unusable.\"" "$LINENO" 5
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libdebuginfod is missing or unusable; some features may be unavailable." >&5
+$as_echo "$as_me: WARNING: libdebuginfod is missing or unusable; some features may be unavailable." >&2;}
+ fi
+ fi
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: debuginfod support disabled; some features may be unavailable." >&5
$as_echo "$as_me: WARNING: debuginfod support disabled; some features may be unavailable." >&2;}
fi

+cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBDEBUGINFOD $have_libdebuginfod
+_ACEOF
+
+

cat >>confdefs.h <<_ACEOF
diff --git a/config/debuginfod.m4 b/config/debuginfod.m4
index f9eb0988e3..e05d69e24c 100644
--- a/config/debuginfod.m4
+++ b/config/debuginfod.m4
@@ -16,15 +16,23 @@ AC_ARG_WITH([debuginfod],
AC_MSG_CHECKING([whether to use debuginfod])
AC_MSG_RESULT([$with_debuginfod])

+have_libdebuginfod=0
if test "x$with_debuginfod" != xno; then
PKG_CHECK_MODULES([DEBUGINFOD], [libdebuginfod >= 0.179],
- [AC_DEFINE([HAVE_LIBDEBUGINFOD], [1], [Define to 1 if debuginfod is enabled.])],
- [if test "x$with_debuginfod" = xyes; then
+ [AC_CHECK_LIB([debuginfod], [debuginfod_begin],
+ [have_libdebuginfod=1])])
+ if test "x$have_libdebuginfod" = "x0"; then
+ DEBUGINFOD_LIBS=
+ if test "x$with_debuginfod" = xyes; then
AC_MSG_ERROR(["--with-debuginfod was given, but libdebuginfod is missing or unusable."])
else
AC_MSG_WARN([libdebuginfod is missing or unusable; some features may be unavailable.])
- fi])
+ fi
+ fi
else
AC_MSG_WARN([debuginfod support disabled; some features may be unavailable.])
fi
+AC_DEFINE_UNQUOTED([HAVE_LIBDEBUGINFOD],
+ [$have_libdebuginfod],
+ [Define to 1 if debuginfod is enabled.])
])
diff --git a/gdb/configure b/gdb/configure
index adcfa49c63..154370f9ab 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -6996,6 +6996,7 @@ $as_echo_n "checking whether to use debuginfod... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_debuginfod" >&5
$as_echo "$with_debuginfod" >&6; }

+have_libdebuginfod=0
if test "x$with_debuginfod" != xno; then

pkg_failed=no
@@ -7056,35 +7057,96 @@ fi
# Put the nasty error message in config.log where it belongs
echo "$DEBUGINFOD_PKG_ERRORS" >&5

- if test "x$with_debuginfod" = xyes; then
- as_fn_error $? "\"--with-debuginfod was given, but libdebuginfod is missing or unusable.\"" "$LINENO" 5
- else
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libdebuginfod is missing or unusable; some features may be unavailable." >&5
-$as_echo "$as_me: WARNING: libdebuginfod is missing or unusable; some features may be unavailable." >&2;}
- fi
+ as_fn_error $? "Package requirements (libdebuginfod >= 0.179) were not met:
+
+$DEBUGINFOD_PKG_ERRORS
+
+Consider adjusting the PKG_CONFIG_PATH environment variable if you
+installed software in a non-standard prefix.
+
+Alternatively, you may set the environment variables DEBUGINFOD_CFLAGS
+and DEBUGINFOD_LIBS to avoid the need to call pkg-config.
+See the pkg-config man page for more details." "$LINENO" 5
elif test $pkg_failed = untried; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
- if test "x$with_debuginfod" = xyes; then
- as_fn_error $? "\"--with-debuginfod was given, but libdebuginfod is missing or unusable.\"" "$LINENO" 5
- else
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libdebuginfod is missing or unusable; some features may be unavailable." >&5
-$as_echo "$as_me: WARNING: libdebuginfod is missing or unusable; some features may be unavailable." >&2;}
- fi
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it
+is in your PATH or set the PKG_CONFIG environment variable to the full
+path to pkg-config.
+
+Alternatively, you may set the environment variables DEBUGINFOD_CFLAGS
+and DEBUGINFOD_LIBS to avoid the need to call pkg-config.
+See the pkg-config man page for more details.
+
+To get pkg-config, see <http://pkg-config.freedesktop.org/>.
+See \`config.log' for more details" "$LINENO" 5; }
else
DEBUGINFOD_CFLAGS=$pkg_cv_DEBUGINFOD_CFLAGS
DEBUGINFOD_LIBS=$pkg_cv_DEBUGINFOD_LIBS
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for debuginfod_begin in -ldebuginfod" >&5
+$as_echo_n "checking for debuginfod_begin in -ldebuginfod... " >&6; }
+if ${ac_cv_lib_debuginfod_debuginfod_begin+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldebuginfod $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */

-$as_echo "#define HAVE_LIBDEBUGINFOD 1" >>confdefs.h
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char debuginfod_begin ();
+int
+main ()
+{
+return debuginfod_begin ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_lib_debuginfod_debuginfod_begin=yes
+else
+ ac_cv_lib_debuginfod_debuginfod_begin=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_debuginfod_debuginfod_begin" >&5
+$as_echo "$ac_cv_lib_debuginfod_debuginfod_begin" >&6; }
+if test "x$ac_cv_lib_debuginfod_debuginfod_begin" = xyes; then :
+ have_libdebuginfod=1
+fi

fi
+ if test "x$have_libdebuginfod" = "x0"; then
+ DEBUGINFOD_LIBS=
+ if test "x$with_debuginfod" = xyes; then
+ as_fn_error $? "\"--with-debuginfod was given, but libdebuginfod is missing or unusable.\"" "$LINENO" 5
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libdebuginfod is missing or unusable; some features may be unavailable." >&5
+$as_echo "$as_me: WARNING: libdebuginfod is missing or unusable; some features may be unavailable." >&2;}
+ fi
+ fi
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: debuginfod support disabled; some features may be unavailable." >&5
$as_echo "$as_me: WARNING: debuginfod support disabled; some features may be unavailable." >&2;}
fi

+cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBDEBUGINFOD $have_libdebuginfod
+_ACEOF
+
+

# Libunwind support for ia64.

--
2.26.2