public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] config/debuginfod.m4: Use PKG_CHECK_MODULES
@ 2020-05-02  2:29 Aaron Merey
  2020-05-05 16:41 ` Jeff Law
  0 siblings, 1 reply; 37+ messages in thread
From: Aaron Merey @ 2020-05-02  2:29 UTC (permalink / raw)
  To: gcc-patches; +Cc: simark, nickc

Hello,

I'm not sure if this is the right mailing list for this patch but it modifies 
the top level directory of binutils-gdb for which I understand GCC to be the 
upstream. The purpose of this patch is to use PKG_CHECK_MODULES in 
config/debuginfod.m4 since debuginfod supports pkg-config. Otherwise the 
functionality of debuginfod.m4 is not changed by this patch. The rest of the 
changes involve renaming a debuginfod autoconf variable, removing an 
unnecessary call to AC_DEBUGINFOD in the top level configure.ac and the 
regeneration of files in gdb/, binutils/ and the top-level directory.

Aaron Merey


From 31c1e42fb7185080a21673b8818dca01fc7d4d6f Mon Sep 17 00:00:00 2001
From: Aaron Merey <amerey@redhat.com>
Date: Fri, 1 May 2020 21:51:43 -0400
Subject: [PATCH] config/debuginfod.m4: Use PKG_CHECK_MODULES

Use PKG_CHECK_MODULES to set the debuginfod autoconf vars.

ChangeLog:

        * config/debuginfod.m4: use PKG_CHECK_MODULES.
        * configure: Rebuild.
        * configure.ac: Remove AC_DEBUGINFOD.

ChangeLog/binutils:

        * Makefile.am: Replace LIBDEBUGINFOD with DEBUGINFOD_LIBS.
        * Makefile.in: Rebuild.
        * aclocal.m4: Rebuild.
        * configure: Rebuild.
        * doc/Makefile.in: Rebuild.

ChangeLog/gdb:

        * Makefile.in: Replace LIBDEBUGINFOD with DEBUGINFOD_LIBS.
        * aclocal.m4: Rebuild.
        * configure: Rebuild.
---
 ChangeLog                |   6 +
 binutils/ChangeLog       |   9 +
 binutils/Makefile.am     |   6 +-
 binutils/Makefile.in     |   7 +-
 binutils/aclocal.m4      | 344 ++++++++++++++++++++++++++++++++++++
 binutils/configure       | 369 ++++++++++++++++++++++++++++-----------
 binutils/doc/Makefile.in |   6 +-
 config/debuginfod.m4     |  36 ++--
 configure                | 139 +--------------
 configure.ac             |   3 -
 gdb/ChangeLog            |   7 +
 gdb/Makefile.in          |   2 +-
 gdb/aclocal.m4           | 344 ++++++++++++++++++++++++++++++++++++
 gdb/configure            | 365 +++++++++++++++++++++++++++-----------
 14 files changed, 1266 insertions(+), 377 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f79c3e8fb5..49dca08bbc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2020-05-01  Aaron Merey  <amerey@redhat.com>
+
+	* config/debuginfod.m4: use PKG_CHECK_MODULES.
+	* configure: Rebuild.
+	* configure.ac: Remove AC_DEBUGINFOD.
+
 2020-04-21  Stephen Casner  <casner@acm.org>
 
 	PR 25830
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 52082fcae1..da6ef9c8c3 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,12 @@
+ChangeLog/binutils:
+2020-05-01  Aaron Merey  <amerey@redhat.com>
+
+	* Makefile.am: Replace LIBDEBUGINFOD with DEBUGINFOD_LIBS.
+	* Makefile.in: Rebuild.
+	* aclocal.m4: Rebuild.
+	* configure: Rebuild.
+	* doc/Makefile.in: Rebuild.
+
 2020-05-01  Alan Modra  <amodra@gmail.com>
 	    Haim Shimonovich  <Haim.Shimonovich@ceva-dsp.com>
 
diff --git a/binutils/Makefile.am b/binutils/Makefile.am
index e5cf5634a7..ecc5283b1b 100644
--- a/binutils/Makefile.am
+++ b/binutils/Makefile.am
@@ -53,7 +53,7 @@ AM_CFLAGS = $(WARN_CFLAGS) $(ZLIBINC)
 AM_CFLAGS_FOR_BUILD = $(WARN_CFLAGS_FOR_BUILD) $(ZLIBINC)
 LIBICONV = @LIBICONV@
 
-LIBDEBUGINFOD = @LIBDEBUGINFOD@
+DEBUGINFOD_LIBS = @DEBUGINFOD_LIBS@
 
 # these two are almost the same program
 AR_PROG=ar
@@ -247,7 +247,7 @@ objcopy_SOURCES = objcopy.c not-strip.c rename.c $(WRITE_DEBUG_SRCS) $(BULIBS)
 strings_SOURCES = strings.c $(BULIBS)
 
 readelf_SOURCES = readelf.c version.c unwind-ia64.c dwarf.c $(ELFLIBS)
-readelf_LDADD   = $(LIBINTL) $(LIBCTF_NOBFD) $(LIBIBERTY) $(ZLIB) $(LIBDEBUGINFOD)
+readelf_LDADD   = $(LIBINTL) $(LIBCTF_NOBFD) $(LIBIBERTY) $(ZLIB) $(DEBUGINFOD_LIBS)
 
 elfedit_SOURCES = elfedit.c version.c $(ELFLIBS)
 elfedit_LDADD = $(LIBINTL) $(LIBIBERTY)
@@ -258,7 +258,7 @@ nm_new_SOURCES = nm.c $(BULIBS)
 
 objdump_SOURCES = objdump.c dwarf.c prdbg.c $(DEBUG_SRCS) $(BULIBS) $(ELFLIBS)
 EXTRA_objdump_SOURCES = od-xcoff.c
-objdump_LDADD = $(OBJDUMP_PRIVATE_OFILES) $(OPCODES) $(LIBCTF) $(BFDLIB) $(LIBIBERTY) $(LIBINTL) $(LIBDEBUGINFOD)
+objdump_LDADD = $(OBJDUMP_PRIVATE_OFILES) $(OPCODES) $(LIBCTF) $(BFDLIB) $(LIBIBERTY) $(LIBINTL) $(DEBUGINFOD_LIBS)
 
 objdump.@OBJEXT@:objdump.c
 if am__fastdepCC
diff --git a/binutils/Makefile.in b/binutils/Makefile.in
index ee6f267df9..7780729d69 100644
--- a/binutils/Makefile.in
+++ b/binutils/Makefile.in
@@ -420,6 +420,8 @@ CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DATADIRNAME = @DATADIRNAME@
+DEBUGINFOD_CFLAGS = @DEBUGINFOD_CFLAGS@
+DEBUGINFOD_LIBS = @DEBUGINFOD_LIBS@
 DEFS = @DEFS@
 DEMANGLER_NAME = @DEMANGLER_NAME@
 DEPDIR = @DEPDIR@
@@ -451,7 +453,6 @@ LDFLAGS = @LDFLAGS@
 LEX = `if [ -f ../flex/flex ]; then echo ../flex/flex; else echo @LEX@; fi`
 LEXLIB = @LEXLIB@
 LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
-LIBDEBUGINFOD = @LIBDEBUGINFOD@
 LIBICONV = @LIBICONV@
 LIBINTL = @LIBINTL@
 LIBINTL_DEP = @LIBINTL_DEP@
@@ -487,6 +488,9 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
+PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
 POSUB = @POSUB@
 RANLIB = @RANLIB@
 SED = @SED@
@@ -575,6 +579,7 @@ ZLIB = @zlibdir@ -lz
 ZLIBINC = @zlibinc@
 AM_CFLAGS = $(WARN_CFLAGS) $(ZLIBINC)
 AM_CFLAGS_FOR_BUILD = $(WARN_CFLAGS_FOR_BUILD) $(ZLIBINC)
+LIBDEBUGINFOD = @DEBUGINFOD_LIBS@
 
 # these two are almost the same program
 AR_PROG = ar
diff --git a/binutils/aclocal.m4 b/binutils/aclocal.m4
index 4fa32fffd8..01e7406f83 100644
--- a/binutils/aclocal.m4
+++ b/binutils/aclocal.m4
@@ -20,6 +20,350 @@ You have another version of autoconf.  It may work, but is not guaranteed to.
 If you have problems, you may need to regenerate the build system entirely.
 To do so, use the procedure documented by the package, typically 'autoreconf'.])])
 
+# pkg.m4 - Macros to locate and utilise pkg-config.   -*- Autoconf -*-
+# serial 11 (pkg-config-0.29.1)
+
+dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
+dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
+dnl
+dnl This program is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 2 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+dnl General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+dnl 02111-1307, USA.
+dnl
+dnl As a special exception to the GNU General Public License, if you
+dnl distribute this file as part of a program that contains a
+dnl configuration script generated by Autoconf, you may include it under
+dnl the same distribution terms that you use for the rest of that
+dnl program.
+
+dnl PKG_PREREQ(MIN-VERSION)
+dnl -----------------------
+dnl Since: 0.29
+dnl
+dnl Verify that the version of the pkg-config macros are at least
+dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's
+dnl installed version of pkg-config, this checks the developer's version
+dnl of pkg.m4 when generating configure.
+dnl
+dnl To ensure that this macro is defined, also add:
+dnl m4_ifndef([PKG_PREREQ],
+dnl     [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])])
+dnl
+dnl See the "Since" comment for each macro you use to see what version
+dnl of the macros you require.
+m4_defun([PKG_PREREQ],
+[m4_define([PKG_MACROS_VERSION], [0.29.1])
+m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
+    [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
+])dnl PKG_PREREQ
+
+dnl PKG_PROG_PKG_CONFIG([MIN-VERSION])
+dnl ----------------------------------
+dnl Since: 0.16
+dnl
+dnl Search for the pkg-config tool and set the PKG_CONFIG variable to
+dnl first found in the path. Checks that the version of pkg-config found
+dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is
+dnl used since that's the first version where most current features of
+dnl pkg-config existed.
+AC_DEFUN([PKG_PROG_PKG_CONFIG],
+[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
+m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
+m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
+AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
+AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
+AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
+
+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
+	AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
+fi
+if test -n "$PKG_CONFIG"; then
+	_pkg_min_version=m4_default([$1], [0.9.0])
+	AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
+	if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
+		AC_MSG_RESULT([yes])
+	else
+		AC_MSG_RESULT([no])
+		PKG_CONFIG=""
+	fi
+fi[]dnl
+])dnl PKG_PROG_PKG_CONFIG
+
+dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+dnl -------------------------------------------------------------------
+dnl Since: 0.18
+dnl
+dnl Check to see whether a particular set of modules exists. Similar to
+dnl PKG_CHECK_MODULES(), but does not set variables or print errors.
+dnl
+dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+dnl only at the first occurence in configure.ac, so if the first place
+dnl it's called might be skipped (such as if it is within an "if", you
+dnl have to call PKG_CHECK_EXISTS manually
+AC_DEFUN([PKG_CHECK_EXISTS],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+if test -n "$PKG_CONFIG" && \
+    AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
+  m4_default([$2], [:])
+m4_ifvaln([$3], [else
+  $3])dnl
+fi])
+
+dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
+dnl ---------------------------------------------
+dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting
+dnl pkg_failed based on the result.
+m4_define([_PKG_CONFIG],
+[if test -n "$$1"; then
+    pkg_cv_[]$1="$$1"
+ elif test -n "$PKG_CONFIG"; then
+    PKG_CHECK_EXISTS([$3],
+                     [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes ],
+		     [pkg_failed=yes])
+ else
+    pkg_failed=untried
+fi[]dnl
+])dnl _PKG_CONFIG
+
+dnl _PKG_SHORT_ERRORS_SUPPORTED
+dnl ---------------------------
+dnl Internal check to see if pkg-config supports short errors.
+AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+        _pkg_short_errors_supported=yes
+else
+        _pkg_short_errors_supported=no
+fi[]dnl
+])dnl _PKG_SHORT_ERRORS_SUPPORTED
+
+
+dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
+dnl   [ACTION-IF-NOT-FOUND])
+dnl --------------------------------------------------------------
+dnl Since: 0.4.0
+dnl
+dnl Note that if there is a possibility the first call to
+dnl PKG_CHECK_MODULES might not happen, you should be sure to include an
+dnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
+AC_DEFUN([PKG_CHECK_MODULES],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
+AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
+
+pkg_failed=no
+AC_MSG_CHECKING([for $1])
+
+_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
+_PKG_CONFIG([$1][_LIBS], [libs], [$2])
+
+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.])
+
+if test $pkg_failed = yes; then
+	AC_MSG_RESULT([no])
+        _PKG_SHORT_ERRORS_SUPPORTED
+        if test $_pkg_short_errors_supported = yes; then
+	        $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
+        else
+	        $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
+        fi
+	# Put the nasty error message in config.log where it belongs
+	echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
+
+	m4_default([$4], [AC_MSG_ERROR(
+[Package requirements ($2) were not met:
+
+$$1_PKG_ERRORS
+
+Consider adjusting the PKG_CONFIG_PATH environment variable if you
+installed software in a non-standard prefix.
+
+_PKG_TEXT])[]dnl
+        ])
+elif test $pkg_failed = untried; then
+	AC_MSG_RESULT([no])
+	m4_default([$4], [AC_MSG_FAILURE(
+[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.
+
+_PKG_TEXT
+
+To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl
+        ])
+else
+	$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
+	$1[]_LIBS=$pkg_cv_[]$1[]_LIBS
+        AC_MSG_RESULT([yes])
+	$3
+fi[]dnl
+])dnl PKG_CHECK_MODULES
+
+
+dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
+dnl   [ACTION-IF-NOT-FOUND])
+dnl ---------------------------------------------------------------------
+dnl Since: 0.29
+dnl
+dnl Checks for existence of MODULES and gathers its build flags with
+dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags
+dnl and VARIABLE-PREFIX_LIBS from --libs.
+dnl
+dnl Note that if there is a possibility the first call to
+dnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to
+dnl include an explicit call to PKG_PROG_PKG_CONFIG in your
+dnl configure.ac.
+AC_DEFUN([PKG_CHECK_MODULES_STATIC],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+_save_PKG_CONFIG=$PKG_CONFIG
+PKG_CONFIG="$PKG_CONFIG --static"
+PKG_CHECK_MODULES($@)
+PKG_CONFIG=$_save_PKG_CONFIG[]dnl
+])dnl PKG_CHECK_MODULES_STATIC
+
+
+dnl PKG_INSTALLDIR([DIRECTORY])
+dnl -------------------------
+dnl Since: 0.27
+dnl
+dnl Substitutes the variable pkgconfigdir as the location where a module
+dnl should install pkg-config .pc files. By default the directory is
+dnl $libdir/pkgconfig, but the default can be changed by passing
+dnl DIRECTORY. The user can override through the --with-pkgconfigdir
+dnl parameter.
+AC_DEFUN([PKG_INSTALLDIR],
+[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
+m4_pushdef([pkg_description],
+    [pkg-config installation directory @<:@]pkg_default[@:>@])
+AC_ARG_WITH([pkgconfigdir],
+    [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],,
+    [with_pkgconfigdir=]pkg_default)
+AC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
+m4_popdef([pkg_default])
+m4_popdef([pkg_description])
+])dnl PKG_INSTALLDIR
+
+
+dnl PKG_NOARCH_INSTALLDIR([DIRECTORY])
+dnl --------------------------------
+dnl Since: 0.27
+dnl
+dnl Substitutes the variable noarch_pkgconfigdir as the location where a
+dnl module should install arch-independent pkg-config .pc files. By
+dnl default the directory is $datadir/pkgconfig, but the default can be
+dnl changed by passing DIRECTORY. The user can override through the
+dnl --with-noarch-pkgconfigdir parameter.
+AC_DEFUN([PKG_NOARCH_INSTALLDIR],
+[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
+m4_pushdef([pkg_description],
+    [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@])
+AC_ARG_WITH([noarch-pkgconfigdir],
+    [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],,
+    [with_noarch_pkgconfigdir=]pkg_default)
+AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
+m4_popdef([pkg_default])
+m4_popdef([pkg_description])
+])dnl PKG_NOARCH_INSTALLDIR
+
+
+dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
+dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+dnl -------------------------------------------
+dnl Since: 0.28
+dnl
+dnl Retrieves the value of the pkg-config variable for the given module.
+AC_DEFUN([PKG_CHECK_VAR],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
+
+_PKG_CONFIG([$1], [variable="][$3]["], [$2])
+AS_VAR_COPY([$1], [pkg_cv_][$1])
+
+AS_VAR_IF([$1], [""], [$5], [$4])dnl
+])dnl PKG_CHECK_VAR
+
+dnl PKG_WITH_MODULES(VARIABLE-PREFIX, MODULES,
+dnl   [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND],
+dnl   [DESCRIPTION], [DEFAULT])
+dnl ------------------------------------------
+dnl
+dnl Prepare a "--with-" configure option using the lowercase
+dnl [VARIABLE-PREFIX] name, merging the behaviour of AC_ARG_WITH and
+dnl PKG_CHECK_MODULES in a single macro.
+AC_DEFUN([PKG_WITH_MODULES],
+[
+m4_pushdef([with_arg], m4_tolower([$1]))
+
+m4_pushdef([description],
+           [m4_default([$5], [build with ]with_arg[ support])])
+
+m4_pushdef([def_arg], [m4_default([$6], [auto])])
+m4_pushdef([def_action_if_found], [AS_TR_SH([with_]with_arg)=yes])
+m4_pushdef([def_action_if_not_found], [AS_TR_SH([with_]with_arg)=no])
+
+m4_case(def_arg,
+            [yes],[m4_pushdef([with_without], [--without-]with_arg)],
+            [m4_pushdef([with_without],[--with-]with_arg)])
+
+AC_ARG_WITH(with_arg,
+     AS_HELP_STRING(with_without, description[ @<:@default=]def_arg[@:>@]),,
+    [AS_TR_SH([with_]with_arg)=def_arg])
+
+AS_CASE([$AS_TR_SH([with_]with_arg)],
+            [yes],[PKG_CHECK_MODULES([$1],[$2],$3,$4)],
+            [auto],[PKG_CHECK_MODULES([$1],[$2],
+                                        [m4_n([def_action_if_found]) $3],
+                                        [m4_n([def_action_if_not_found]) $4])])
+
+m4_popdef([with_arg])
+m4_popdef([description])
+m4_popdef([def_arg])
+
+])dnl PKG_WITH_MODULES
+
+dnl PKG_HAVE_WITH_MODULES(VARIABLE-PREFIX, MODULES,
+dnl   [DESCRIPTION], [DEFAULT])
+dnl -----------------------------------------------
+dnl
+dnl Convenience macro to trigger AM_CONDITIONAL after PKG_WITH_MODULES
+dnl check._[VARIABLE-PREFIX] is exported as make variable.
+AC_DEFUN([PKG_HAVE_WITH_MODULES],
+[
+PKG_WITH_MODULES([$1],[$2],,,[$3],[$4])
+
+AM_CONDITIONAL([HAVE_][$1],
+               [test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"])
+])dnl PKG_HAVE_WITH_MODULES
+
+dnl PKG_HAVE_DEFINE_WITH_MODULES(VARIABLE-PREFIX, MODULES,
+dnl   [DESCRIPTION], [DEFAULT])
+dnl ------------------------------------------------------
+dnl
+dnl Convenience macro to run AM_CONDITIONAL and AC_DEFINE after
+dnl PKG_WITH_MODULES check. HAVE_[VARIABLE-PREFIX] is exported as make
+dnl and preprocessor variable.
+AC_DEFUN([PKG_HAVE_DEFINE_WITH_MODULES],
+[
+PKG_HAVE_WITH_MODULES([$1],[$2],[$3],[$4])
+
+AS_IF([test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"],
+        [AC_DEFINE([HAVE_][$1], 1, [Enable ]m4_tolower([$1])[ support])])
+])dnl PKG_HAVE_DEFINE_WITH_MODULES
+
 # Copyright (C) 2002-2017 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
diff --git a/binutils/configure b/binutils/configure
index 782fffac6f..97d321acb3 100755
--- a/binutils/configure
+++ b/binutils/configure
@@ -684,7 +684,11 @@ WARN_WRITE_STRINGS
 NO_WERROR
 WARN_CFLAGS_FOR_BUILD
 WARN_CFLAGS
-LIBDEBUGINFOD
+DEBUGINFOD_LIBS
+DEBUGINFOD_CFLAGS
+PKG_CONFIG_LIBDIR
+PKG_CONFIG_PATH
+PKG_CONFIG
 OTOOL64
 OTOOL
 LIPO
@@ -833,6 +837,11 @@ LDFLAGS
 LIBS
 CPPFLAGS
 CPP
+PKG_CONFIG
+PKG_CONFIG_PATH
+PKG_CONFIG_LIBDIR
+DEBUGINFOD_CFLAGS
+DEBUGINFOD_LIBS
 YACC
 YFLAGS'
 
@@ -1503,6 +1512,15 @@ Some influential environment variables:
   CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
               you have headers in a nonstandard directory <include dir>
   CPP         C preprocessor
+  PKG_CONFIG  path to pkg-config utility
+  PKG_CONFIG_PATH
+              directories to add to pkg-config's search path
+  PKG_CONFIG_LIBDIR
+              path overriding pkg-config's built-in search path
+  DEBUGINFOD_CFLAGS
+              C compiler flags for DEBUGINFOD, overriding pkg-config
+  DEBUGINFOD_LIBS
+              linker flags for DEBUGINFOD, overriding pkg-config
   YACC        The `Yet Another Compiler Compiler' implementation to use.
               Defaults to the first program found out of: `bison -y', `byacc',
               `yacc'.
@@ -1938,52 +1956,6 @@ $as_echo "$ac_res" >&6; }
 
 } # ac_fn_c_check_func
 
-# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
-# ---------------------------------------------
-# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
-# accordingly.
-ac_fn_c_check_decl ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  as_decl_name=`echo $2|sed 's/ *(.*//'`
-  as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
-$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
-if eval \${$3+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$4
-int
-main ()
-{
-#ifndef $as_decl_name
-#ifdef __cplusplus
-  (void) $as_decl_use;
-#else
-  (void) $as_decl_name;
-#endif
-#endif
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  eval "$3=yes"
-else
-  eval "$3=no"
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-eval ac_res=\$$3
-	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-
-} # ac_fn_c_check_decl
-
 # ac_fn_c_compute_int LINENO EXPR VAR INCLUDES
 # --------------------------------------------
 # Tries to find the compile-time value of EXPR in a program that includes
@@ -2220,6 +2192,52 @@ $as_echo "$ac_res" >&6; }
   eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
 
 } # ac_fn_c_check_type
+
+# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
+# ---------------------------------------------
+# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
+# accordingly.
+ac_fn_c_check_decl ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  as_decl_name=`echo $2|sed 's/ *(.*//'`
+  as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
+$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
+if eval \${$3+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+#ifndef $as_decl_name
+#ifdef __cplusplus
+  (void) $as_decl_use;
+#else
+  (void) $as_decl_name;
+#endif
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$3=yes"
+else
+  eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_decl
 cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
@@ -11529,7 +11547,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11532 "configure"
+#line 11550 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11635,7 +11653,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11638 "configure"
+#line 11656 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12242,7 +12260,127 @@ fi
 
 
 
-# Enable debuginfod
+
+
+
+
+
+
+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
+	if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
+set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_PKG_CONFIG+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $PKG_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+PKG_CONFIG=$ac_cv_path_PKG_CONFIG
+if test -n "$PKG_CONFIG"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
+$as_echo "$PKG_CONFIG" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_path_PKG_CONFIG"; then
+  ac_pt_PKG_CONFIG=$PKG_CONFIG
+  # Extract the first word of "pkg-config", so it can be a program name with args.
+set dummy pkg-config; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $ac_pt_PKG_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG
+if test -n "$ac_pt_PKG_CONFIG"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5
+$as_echo "$ac_pt_PKG_CONFIG" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_pt_PKG_CONFIG" = x; then
+    PKG_CONFIG=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    PKG_CONFIG=$ac_pt_PKG_CONFIG
+  fi
+else
+  PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
+fi
+
+fi
+if test -n "$PKG_CONFIG"; then
+	_pkg_min_version=0.9.0
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5
+$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; }
+	if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+	else
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+		PKG_CONFIG=""
+	fi
+fi
+
+# Handle optional debuginfod support
 
 # Check whether --with-debuginfod was given.
 if test "${with_debuginfod+set}" = set; then :
@@ -12256,72 +12394,93 @@ $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; }
 
-if test "${with_debuginfod}" = no; then
-  { $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;}
-else
-  { $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.  */
+if test "x$with_debuginfod" != xno; then
 
-/* 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
+pkg_failed=no
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for DEBUGINFOD" >&5
+$as_echo_n "checking for DEBUGINFOD... " >&6; }
+
+if test -n "$DEBUGINFOD_CFLAGS"; then
+    pkg_cv_DEBUGINFOD_CFLAGS="$DEBUGINFOD_CFLAGS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libdebuginfod >= 0.179\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "libdebuginfod >= 0.179") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_DEBUGINFOD_CFLAGS=`$PKG_CONFIG --cflags "libdebuginfod >= 0.179" 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes
 else
-  ac_cv_lib_debuginfod_debuginfod_begin=no
+  pkg_failed=yes
 fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
+ else
+    pkg_failed=untried
+fi
+if test -n "$DEBUGINFOD_LIBS"; then
+    pkg_cv_DEBUGINFOD_LIBS="$DEBUGINFOD_LIBS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libdebuginfod >= 0.179\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "libdebuginfod >= 0.179") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_DEBUGINFOD_LIBS=`$PKG_CONFIG --libs "libdebuginfod >= 0.179" 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes
+else
+  pkg_failed=yes
 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_debuginfod_lib=yes
+ else
+    pkg_failed=untried
 fi
 
-  ac_fn_c_check_decl "$LINENO" "debuginfod_begin" "ac_cv_have_decl_debuginfod_begin" "#include <elfutils/debuginfod.h>
-"
-if test "x$ac_cv_have_decl_debuginfod_begin" = xyes; then :
-  have_debuginfod_h=yes
-fi
 
-  if test "x$have_debuginfod_lib" = "xyes" -a \
-          "x$have_debuginfod_h" = "xyes"; then
 
-$as_echo "#define HAVE_LIBDEBUGINFOD 1" >>confdefs.h
+if test $pkg_failed = yes; then
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
 
-    LIBDEBUGINFOD="-ldebuginfod"
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+        _pkg_short_errors_supported=yes
+else
+        _pkg_short_errors_supported=no
+fi
+        if test $_pkg_short_errors_supported = yes; then
+	        DEBUGINFOD_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libdebuginfod >= 0.179" 2>&1`
+        else
+	        DEBUGINFOD_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libdebuginfod >= 0.179" 2>&1`
+        fi
+	# Put the nasty error message in config.log where it belongs
+	echo "$DEBUGINFOD_PKG_ERRORS" >&5
 
-  else
+	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
+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
+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; }
 
-    if test "$with_debuginfod" = yes; then
-      as_fn_error $? "debuginfod is missing or unusable" "$LINENO" 5
-    else
-      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: debuginfod is missing or unusable; some features may be unavailable." >&5
-$as_echo "$as_me: WARNING: debuginfod is missing or unusable; some features may be unavailable." >&2;}
-    fi
-  fi
+$as_echo "#define HAVE_LIBDEBUGINFOD 1" >>confdefs.h
+
+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
 
 
diff --git a/binutils/doc/Makefile.in b/binutils/doc/Makefile.in
index b00260bc25..1025d7bdee 100644
--- a/binutils/doc/Makefile.in
+++ b/binutils/doc/Makefile.in
@@ -255,6 +255,8 @@ CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DATADIRNAME = @DATADIRNAME@
+DEBUGINFOD_CFLAGS = @DEBUGINFOD_CFLAGS@
+DEBUGINFOD_LIBS = @DEBUGINFOD_LIBS@
 DEFS = @DEFS@
 DEMANGLER_NAME = @DEMANGLER_NAME@
 DEPDIR = @DEPDIR@
@@ -286,7 +288,6 @@ LDFLAGS = @LDFLAGS@
 LEX = @LEX@
 LEXLIB = @LEXLIB@
 LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
-LIBDEBUGINFOD = @LIBDEBUGINFOD@
 LIBICONV = @LIBICONV@
 LIBINTL = @LIBINTL@
 LIBINTL_DEP = @LIBINTL_DEP@
@@ -320,6 +321,9 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
+PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
 POSUB = @POSUB@
 RANLIB = @RANLIB@
 SED = @SED@
diff --git a/config/debuginfod.m4 b/config/debuginfod.m4
index 9979abe89d..2c1bfbdb54 100644
--- a/config/debuginfod.m4
+++ b/config/debuginfod.m4
@@ -1,4 +1,4 @@
-dnl Copyright (C) 1997-2019 Free Software Foundation, Inc.
+dnl Copyright (C) 1997-2020 Free Software Foundation, Inc.
 dnl This file is free software, distributed under the terms of the GNU
 dnl General Public License.  As a special exception to the GNU General
 dnl Public License, this file may be distributed as part of a program
@@ -7,32 +7,22 @@ dnl the same distribution terms as the rest of that program.
 
 AC_DEFUN([AC_DEBUGINFOD],
 [
-# Enable debuginfod
+# Handle optional debuginfod support
 AC_ARG_WITH([debuginfod],
-        AC_HELP_STRING([--with-debuginfod],
-                       [Enable debuginfo lookups with debuginfod (auto/yes/no)]),
-        [], [with_debuginfod=auto])
+  AC_HELP_STRING([--with-debuginfod], [Enable debuginfo lookups with debuginfod (auto/yes/no)]),
+  [], [with_debuginfod=auto])
 AC_MSG_CHECKING([whether to use debuginfod])
 AC_MSG_RESULT([$with_debuginfod])
 
-if test "${with_debuginfod}" = no; then
-  AC_MSG_WARN([debuginfod support disabled; some features may be unavailable.])
+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_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])
 else
-  AC_CHECK_LIB([debuginfod], [debuginfod_begin], [have_debuginfod_lib=yes])
-  AC_CHECK_DECL([debuginfod_begin], [have_debuginfod_h=yes], [],
-                [#include <elfutils/debuginfod.h>])
-  if test "x$have_debuginfod_lib" = "xyes" -a \
-          "x$have_debuginfod_h" = "xyes"; then
-    AC_DEFINE([HAVE_LIBDEBUGINFOD], [1],
-              [Define to 1 if debuginfod is enabled.])
-    AC_SUBST([LIBDEBUGINFOD], ["-ldebuginfod"])
-  else
-    AC_SUBST([LIBDEBUGINFOD], [])
-    if test "$with_debuginfod" = yes; then
-      AC_MSG_ERROR([debuginfod is missing or unusable])
-    else
-      AC_MSG_WARN([debuginfod is missing or unusable; some features may be unavailable.])
-    fi
-  fi
+  AC_MSG_WARN([debuginfod support disabled; some features may be unavailable.])
 fi
 ])
diff --git a/configure b/configure
index 54d0339ab9..68779feb42 100755
--- a/configure
+++ b/configure
@@ -690,7 +690,6 @@ extra_mpc_gmp_configure_flags
 extra_mpfr_configure_flags
 gmpinc
 gmplibs
-LIBDEBUGINFOD
 do_compare
 GNATMAKE
 GNATBIND
@@ -791,7 +790,6 @@ enable_libssp
 enable_libstdcxx
 enable_liboffloadmic
 enable_bootstrap
-with_debuginfod
 with_mpc
 with_mpc_include
 with_mpc_lib
@@ -1555,8 +1553,6 @@ Optional Packages:
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
   --with-build-libsubdir=DIR  Directory where to find libraries for build system
   --with-system-zlib      use installed libz
-  --with-debuginfod       Enable debuginfo lookups with debuginfod
-                          (auto/yes/no)
   --with-mpc=PATH         specify prefix directory for installed MPC package.
                           Equivalent to --with-mpc-include=PATH/include plus
                           --with-mpc-lib=PATH/lib
@@ -1925,52 +1921,6 @@ fi
   as_fn_set_status $ac_retval
 
 } # ac_fn_c_try_link
-
-# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
-# ---------------------------------------------
-# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
-# accordingly.
-ac_fn_c_check_decl ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  as_decl_name=`echo $2|sed 's/ *(.*//'`
-  as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
-$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
-if eval \${$3+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$4
-int
-main ()
-{
-#ifndef $as_decl_name
-#ifdef __cplusplus
-  (void) $as_decl_use;
-#else
-  (void) $as_decl_name;
-#endif
-#endif
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  eval "$3=yes"
-else
-  eval "$3=no"
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-eval ac_res=\$$3
-	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-
-} # ac_fn_c_check_decl
 cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
@@ -5505,92 +5455,6 @@ gmplibs="-lmpc -lmpfr -lgmp"
 gmpinc=
 have_gmp=no
 
-# Check for debuginfod
-
-
-# Enable debuginfod
-
-# Check whether --with-debuginfod was given.
-if test "${with_debuginfod+set}" = set; then :
-  withval=$with_debuginfod;
-else
-  with_debuginfod=auto
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use debuginfod" >&5
-$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; }
-
-if test "${with_debuginfod}" = no; then
-  { $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;}
-else
-  { $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.  */
-
-/* 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_debuginfod_lib=yes
-fi
-
-  ac_fn_c_check_decl "$LINENO" "debuginfod_begin" "ac_cv_have_decl_debuginfod_begin" "#include <elfutils/debuginfod.h>
-"
-if test "x$ac_cv_have_decl_debuginfod_begin" = xyes; then :
-  have_debuginfod_h=yes
-fi
-
-  if test "x$have_debuginfod_lib" = "xyes" -a \
-          "x$have_debuginfod_h" = "xyes"; then
-
-$as_echo "#define HAVE_LIBDEBUGINFOD 1" >>confdefs.h
-
-    LIBDEBUGINFOD="-ldebuginfod"
-
-  else
-
-    if test "$with_debuginfod" = yes; then
-      as_fn_error $? "debuginfod is missing or unusable" "$LINENO" 5
-    else
-      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: debuginfod is missing or unusable; some features may be unavailable." >&5
-$as_echo "$as_me: WARNING: debuginfod is missing or unusable; some features may be unavailable." >&2;}
-    fi
-  fi
-fi
-
-
 # Specify a location for mpc
 # check for this first so it ends up on the link line before mpfr.
 
@@ -5745,7 +5609,8 @@ if test -d ${srcdir}/gcc && test "x$have_gmp" = xno; then
   # Check for the recommended and required versions of GMP.
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the correct version of gmp.h" >&5
 $as_echo_n "checking for the correct version of gmp.h... " >&6; }
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include "gmp.h"
 int
diff --git a/configure.ac b/configure.ac
index a910c4fd6b..49790877e8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1383,9 +1383,6 @@ gmplibs="-lmpc -lmpfr -lgmp"
 gmpinc=
 have_gmp=no
 
-# Check for debuginfod
-AC_DEBUGINFOD
-
 # Specify a location for mpc
 # check for this first so it ends up on the link line before mpfr.
 AC_ARG_WITH(mpc,
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index ee4f3a74c0..225518919c 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+ChangeLog/gdb:
+2020-05-01  Aaron Merey  <amerey@redhat.com>
+
+	* Makefile.in: Replace LIBDEBUGINFOD with DEBUGINFOD_LIBS.
+	* aclocal.m4: Rebuild.
+	* configure: Rebuild.
+
 2020-05-01  Philippe Waroquiers  <philippe.waroquiers@skynet.be>
 	* gdb-gdb.gdb-in: Remove breakpoint on disappeared function
 	info_command.
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index e3ce6a285f..75108910c1 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -621,7 +621,7 @@ CLIBS = $(SIM) $(READLINE) $(OPCODES) $(BFD) $(LIBCTF) $(ZLIB) \
 	$(LIBEXPAT) $(LIBLZMA) $(LIBBABELTRACE) $(LIBIPT) \
 	$(WIN32LIBS) $(LIBGNU) $(LIBICONV) \
 	$(LIBMPFR) $(SRCHIGH_LIBS) $(LIBXXHASH) $(PTHREAD_LIBS) \
-	@LIBDEBUGINFOD@
+	@DEBUGINFOD_LIBS@
 CDEPS = $(NAT_CDEPS) $(SIM) $(BFD) $(READLINE_DEPS) $(LIBCTF) \
 	$(OPCODES) $(INTL_DEPS) $(LIBIBERTY) $(CONFIG_DEPS) $(LIBGNU) \
 	$(LIBSUPPORT)
diff --git a/gdb/aclocal.m4 b/gdb/aclocal.m4
index 110b416e61..ea8816ee21 100644
--- a/gdb/aclocal.m4
+++ b/gdb/aclocal.m4
@@ -12,6 +12,350 @@
 # PARTICULAR PURPOSE.
 
 m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
+# pkg.m4 - Macros to locate and utilise pkg-config.   -*- Autoconf -*-
+# serial 11 (pkg-config-0.29.1)
+
+dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
+dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
+dnl
+dnl This program is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 2 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+dnl General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+dnl 02111-1307, USA.
+dnl
+dnl As a special exception to the GNU General Public License, if you
+dnl distribute this file as part of a program that contains a
+dnl configuration script generated by Autoconf, you may include it under
+dnl the same distribution terms that you use for the rest of that
+dnl program.
+
+dnl PKG_PREREQ(MIN-VERSION)
+dnl -----------------------
+dnl Since: 0.29
+dnl
+dnl Verify that the version of the pkg-config macros are at least
+dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's
+dnl installed version of pkg-config, this checks the developer's version
+dnl of pkg.m4 when generating configure.
+dnl
+dnl To ensure that this macro is defined, also add:
+dnl m4_ifndef([PKG_PREREQ],
+dnl     [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])])
+dnl
+dnl See the "Since" comment for each macro you use to see what version
+dnl of the macros you require.
+m4_defun([PKG_PREREQ],
+[m4_define([PKG_MACROS_VERSION], [0.29.1])
+m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
+    [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
+])dnl PKG_PREREQ
+
+dnl PKG_PROG_PKG_CONFIG([MIN-VERSION])
+dnl ----------------------------------
+dnl Since: 0.16
+dnl
+dnl Search for the pkg-config tool and set the PKG_CONFIG variable to
+dnl first found in the path. Checks that the version of pkg-config found
+dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is
+dnl used since that's the first version where most current features of
+dnl pkg-config existed.
+AC_DEFUN([PKG_PROG_PKG_CONFIG],
+[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
+m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
+m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
+AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
+AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
+AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
+
+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
+	AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
+fi
+if test -n "$PKG_CONFIG"; then
+	_pkg_min_version=m4_default([$1], [0.9.0])
+	AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
+	if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
+		AC_MSG_RESULT([yes])
+	else
+		AC_MSG_RESULT([no])
+		PKG_CONFIG=""
+	fi
+fi[]dnl
+])dnl PKG_PROG_PKG_CONFIG
+
+dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+dnl -------------------------------------------------------------------
+dnl Since: 0.18
+dnl
+dnl Check to see whether a particular set of modules exists. Similar to
+dnl PKG_CHECK_MODULES(), but does not set variables or print errors.
+dnl
+dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+dnl only at the first occurence in configure.ac, so if the first place
+dnl it's called might be skipped (such as if it is within an "if", you
+dnl have to call PKG_CHECK_EXISTS manually
+AC_DEFUN([PKG_CHECK_EXISTS],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+if test -n "$PKG_CONFIG" && \
+    AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
+  m4_default([$2], [:])
+m4_ifvaln([$3], [else
+  $3])dnl
+fi])
+
+dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
+dnl ---------------------------------------------
+dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting
+dnl pkg_failed based on the result.
+m4_define([_PKG_CONFIG],
+[if test -n "$$1"; then
+    pkg_cv_[]$1="$$1"
+ elif test -n "$PKG_CONFIG"; then
+    PKG_CHECK_EXISTS([$3],
+                     [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes ],
+		     [pkg_failed=yes])
+ else
+    pkg_failed=untried
+fi[]dnl
+])dnl _PKG_CONFIG
+
+dnl _PKG_SHORT_ERRORS_SUPPORTED
+dnl ---------------------------
+dnl Internal check to see if pkg-config supports short errors.
+AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+        _pkg_short_errors_supported=yes
+else
+        _pkg_short_errors_supported=no
+fi[]dnl
+])dnl _PKG_SHORT_ERRORS_SUPPORTED
+
+
+dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
+dnl   [ACTION-IF-NOT-FOUND])
+dnl --------------------------------------------------------------
+dnl Since: 0.4.0
+dnl
+dnl Note that if there is a possibility the first call to
+dnl PKG_CHECK_MODULES might not happen, you should be sure to include an
+dnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
+AC_DEFUN([PKG_CHECK_MODULES],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
+AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
+
+pkg_failed=no
+AC_MSG_CHECKING([for $1])
+
+_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
+_PKG_CONFIG([$1][_LIBS], [libs], [$2])
+
+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.])
+
+if test $pkg_failed = yes; then
+	AC_MSG_RESULT([no])
+        _PKG_SHORT_ERRORS_SUPPORTED
+        if test $_pkg_short_errors_supported = yes; then
+	        $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
+        else
+	        $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
+        fi
+	# Put the nasty error message in config.log where it belongs
+	echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
+
+	m4_default([$4], [AC_MSG_ERROR(
+[Package requirements ($2) were not met:
+
+$$1_PKG_ERRORS
+
+Consider adjusting the PKG_CONFIG_PATH environment variable if you
+installed software in a non-standard prefix.
+
+_PKG_TEXT])[]dnl
+        ])
+elif test $pkg_failed = untried; then
+	AC_MSG_RESULT([no])
+	m4_default([$4], [AC_MSG_FAILURE(
+[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.
+
+_PKG_TEXT
+
+To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl
+        ])
+else
+	$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
+	$1[]_LIBS=$pkg_cv_[]$1[]_LIBS
+        AC_MSG_RESULT([yes])
+	$3
+fi[]dnl
+])dnl PKG_CHECK_MODULES
+
+
+dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
+dnl   [ACTION-IF-NOT-FOUND])
+dnl ---------------------------------------------------------------------
+dnl Since: 0.29
+dnl
+dnl Checks for existence of MODULES and gathers its build flags with
+dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags
+dnl and VARIABLE-PREFIX_LIBS from --libs.
+dnl
+dnl Note that if there is a possibility the first call to
+dnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to
+dnl include an explicit call to PKG_PROG_PKG_CONFIG in your
+dnl configure.ac.
+AC_DEFUN([PKG_CHECK_MODULES_STATIC],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+_save_PKG_CONFIG=$PKG_CONFIG
+PKG_CONFIG="$PKG_CONFIG --static"
+PKG_CHECK_MODULES($@)
+PKG_CONFIG=$_save_PKG_CONFIG[]dnl
+])dnl PKG_CHECK_MODULES_STATIC
+
+
+dnl PKG_INSTALLDIR([DIRECTORY])
+dnl -------------------------
+dnl Since: 0.27
+dnl
+dnl Substitutes the variable pkgconfigdir as the location where a module
+dnl should install pkg-config .pc files. By default the directory is
+dnl $libdir/pkgconfig, but the default can be changed by passing
+dnl DIRECTORY. The user can override through the --with-pkgconfigdir
+dnl parameter.
+AC_DEFUN([PKG_INSTALLDIR],
+[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
+m4_pushdef([pkg_description],
+    [pkg-config installation directory @<:@]pkg_default[@:>@])
+AC_ARG_WITH([pkgconfigdir],
+    [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],,
+    [with_pkgconfigdir=]pkg_default)
+AC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
+m4_popdef([pkg_default])
+m4_popdef([pkg_description])
+])dnl PKG_INSTALLDIR
+
+
+dnl PKG_NOARCH_INSTALLDIR([DIRECTORY])
+dnl --------------------------------
+dnl Since: 0.27
+dnl
+dnl Substitutes the variable noarch_pkgconfigdir as the location where a
+dnl module should install arch-independent pkg-config .pc files. By
+dnl default the directory is $datadir/pkgconfig, but the default can be
+dnl changed by passing DIRECTORY. The user can override through the
+dnl --with-noarch-pkgconfigdir parameter.
+AC_DEFUN([PKG_NOARCH_INSTALLDIR],
+[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
+m4_pushdef([pkg_description],
+    [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@])
+AC_ARG_WITH([noarch-pkgconfigdir],
+    [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],,
+    [with_noarch_pkgconfigdir=]pkg_default)
+AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
+m4_popdef([pkg_default])
+m4_popdef([pkg_description])
+])dnl PKG_NOARCH_INSTALLDIR
+
+
+dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
+dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+dnl -------------------------------------------
+dnl Since: 0.28
+dnl
+dnl Retrieves the value of the pkg-config variable for the given module.
+AC_DEFUN([PKG_CHECK_VAR],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
+
+_PKG_CONFIG([$1], [variable="][$3]["], [$2])
+AS_VAR_COPY([$1], [pkg_cv_][$1])
+
+AS_VAR_IF([$1], [""], [$5], [$4])dnl
+])dnl PKG_CHECK_VAR
+
+dnl PKG_WITH_MODULES(VARIABLE-PREFIX, MODULES,
+dnl   [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND],
+dnl   [DESCRIPTION], [DEFAULT])
+dnl ------------------------------------------
+dnl
+dnl Prepare a "--with-" configure option using the lowercase
+dnl [VARIABLE-PREFIX] name, merging the behaviour of AC_ARG_WITH and
+dnl PKG_CHECK_MODULES in a single macro.
+AC_DEFUN([PKG_WITH_MODULES],
+[
+m4_pushdef([with_arg], m4_tolower([$1]))
+
+m4_pushdef([description],
+           [m4_default([$5], [build with ]with_arg[ support])])
+
+m4_pushdef([def_arg], [m4_default([$6], [auto])])
+m4_pushdef([def_action_if_found], [AS_TR_SH([with_]with_arg)=yes])
+m4_pushdef([def_action_if_not_found], [AS_TR_SH([with_]with_arg)=no])
+
+m4_case(def_arg,
+            [yes],[m4_pushdef([with_without], [--without-]with_arg)],
+            [m4_pushdef([with_without],[--with-]with_arg)])
+
+AC_ARG_WITH(with_arg,
+     AS_HELP_STRING(with_without, description[ @<:@default=]def_arg[@:>@]),,
+    [AS_TR_SH([with_]with_arg)=def_arg])
+
+AS_CASE([$AS_TR_SH([with_]with_arg)],
+            [yes],[PKG_CHECK_MODULES([$1],[$2],$3,$4)],
+            [auto],[PKG_CHECK_MODULES([$1],[$2],
+                                        [m4_n([def_action_if_found]) $3],
+                                        [m4_n([def_action_if_not_found]) $4])])
+
+m4_popdef([with_arg])
+m4_popdef([description])
+m4_popdef([def_arg])
+
+])dnl PKG_WITH_MODULES
+
+dnl PKG_HAVE_WITH_MODULES(VARIABLE-PREFIX, MODULES,
+dnl   [DESCRIPTION], [DEFAULT])
+dnl -----------------------------------------------
+dnl
+dnl Convenience macro to trigger AM_CONDITIONAL after PKG_WITH_MODULES
+dnl check._[VARIABLE-PREFIX] is exported as make variable.
+AC_DEFUN([PKG_HAVE_WITH_MODULES],
+[
+PKG_WITH_MODULES([$1],[$2],,,[$3],[$4])
+
+AM_CONDITIONAL([HAVE_][$1],
+               [test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"])
+])dnl PKG_HAVE_WITH_MODULES
+
+dnl PKG_HAVE_DEFINE_WITH_MODULES(VARIABLE-PREFIX, MODULES,
+dnl   [DESCRIPTION], [DEFAULT])
+dnl ------------------------------------------------------
+dnl
+dnl Convenience macro to run AM_CONDITIONAL and AC_DEFINE after
+dnl PKG_WITH_MODULES check. HAVE_[VARIABLE-PREFIX] is exported as make
+dnl and preprocessor variable.
+AC_DEFUN([PKG_HAVE_DEFINE_WITH_MODULES],
+[
+PKG_HAVE_WITH_MODULES([$1],[$2],[$3],[$4])
+
+AS_IF([test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"],
+        [AC_DEFINE([HAVE_][$1], 1, [Enable ]m4_tolower([$1])[ support])])
+])dnl PKG_HAVE_DEFINE_WITH_MODULES
+
 # AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
 
 # Copyright (C) 2001-2017 Free Software Foundation, Inc.
diff --git a/gdb/configure b/gdb/configure
index b6233adccf..1000467b19 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -758,7 +758,11 @@ REPORT_BUGS_TEXI
 REPORT_BUGS_TO
 PKGVERSION
 CODESIGN_CERT
-LIBDEBUGINFOD
+DEBUGINFOD_LIBS
+DEBUGINFOD_CFLAGS
+PKG_CONFIG_LIBDIR
+PKG_CONFIG_PATH
+PKG_CONFIG
 HAVE_NATIVE_GCORE_TARGET
 TARGET_OBS
 subdirs
@@ -935,6 +939,11 @@ CCC
 CPP
 MAKEINFO
 MAKEINFOFLAGS
+PKG_CONFIG
+PKG_CONFIG_PATH
+PKG_CONFIG_LIBDIR
+DEBUGINFOD_CFLAGS
+DEBUGINFOD_LIBS
 YACC
 YFLAGS
 XMKMF'
@@ -1678,6 +1687,15 @@ Some influential environment variables:
   MAKEINFO    Parent configure detects if it is of sufficient version.
   MAKEINFOFLAGS
               Parameters for MAKEINFO.
+  PKG_CONFIG  path to pkg-config utility
+  PKG_CONFIG_PATH
+              directories to add to pkg-config's search path
+  PKG_CONFIG_LIBDIR
+              path overriding pkg-config's built-in search path
+  DEBUGINFOD_CFLAGS
+              C compiler flags for DEBUGINFOD, overriding pkg-config
+  DEBUGINFOD_LIBS
+              linker flags for DEBUGINFOD, overriding pkg-config
   YACC        The `Yet Another Compiler Compiler' implementation to use.
               Defaults to the first program found out of: `bison -y', `byacc',
               `yacc'.
@@ -2268,52 +2286,6 @@ rm -f conftest.val
 
 } # ac_fn_c_compute_int
 
-# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
-# ---------------------------------------------
-# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
-# accordingly.
-ac_fn_c_check_decl ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  as_decl_name=`echo $2|sed 's/ *(.*//'`
-  as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
-$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
-if eval \${$3+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$4
-int
-main ()
-{
-#ifndef $as_decl_name
-#ifdef __cplusplus
-  (void) $as_decl_use;
-#else
-  (void) $as_decl_name;
-#endif
-#endif
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  eval "$3=yes"
-else
-  eval "$3=no"
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-eval ac_res=\$$3
-	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-
-} # ac_fn_c_check_decl
-
 # ac_fn_c_check_func LINENO FUNC VAR
 # ----------------------------------
 # Tests whether FUNC exists, setting the cache variable VAR accordingly
@@ -2435,6 +2407,52 @@ $as_echo "$ac_res" >&6; }
 
 } # ac_fn_c_check_type
 
+# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
+# ---------------------------------------------
+# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
+# accordingly.
+ac_fn_c_check_decl ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  as_decl_name=`echo $2|sed 's/ *(.*//'`
+  as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
+$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
+if eval \${$3+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+#ifndef $as_decl_name
+#ifdef __cplusplus
+  (void) $as_decl_use;
+#else
+  (void) $as_decl_name;
+#endif
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$3=yes"
+else
+  eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_decl
+
 # ac_fn_c_check_member LINENO AGGR MEMBER VAR INCLUDES
 # ----------------------------------------------------
 # Tries to find if the field MEMBER exists in type AGGR, after including
@@ -6839,7 +6857,127 @@ esac
 
 # Handle optional debuginfod support
 
-# Enable debuginfod
+
+
+
+
+
+
+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
+	if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
+set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_PKG_CONFIG+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $PKG_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+PKG_CONFIG=$ac_cv_path_PKG_CONFIG
+if test -n "$PKG_CONFIG"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
+$as_echo "$PKG_CONFIG" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_path_PKG_CONFIG"; then
+  ac_pt_PKG_CONFIG=$PKG_CONFIG
+  # Extract the first word of "pkg-config", so it can be a program name with args.
+set dummy pkg-config; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $ac_pt_PKG_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG
+if test -n "$ac_pt_PKG_CONFIG"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5
+$as_echo "$ac_pt_PKG_CONFIG" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_pt_PKG_CONFIG" = x; then
+    PKG_CONFIG=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    PKG_CONFIG=$ac_pt_PKG_CONFIG
+  fi
+else
+  PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
+fi
+
+fi
+if test -n "$PKG_CONFIG"; then
+	_pkg_min_version=0.9.0
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5
+$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; }
+	if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+	else
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+		PKG_CONFIG=""
+	fi
+fi
+
+# Handle optional debuginfod support
 
 # Check whether --with-debuginfod was given.
 if test "${with_debuginfod+set}" = set; then :
@@ -6853,72 +6991,93 @@ $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; }
 
-if test "${with_debuginfod}" = no; then
-  { $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;}
-else
-  { $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.  */
+if test "x$with_debuginfod" != xno; then
 
-/* 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
+pkg_failed=no
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for DEBUGINFOD" >&5
+$as_echo_n "checking for DEBUGINFOD... " >&6; }
+
+if test -n "$DEBUGINFOD_CFLAGS"; then
+    pkg_cv_DEBUGINFOD_CFLAGS="$DEBUGINFOD_CFLAGS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libdebuginfod >= 0.179\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "libdebuginfod >= 0.179") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_DEBUGINFOD_CFLAGS=`$PKG_CONFIG --cflags "libdebuginfod >= 0.179" 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes
 else
-  ac_cv_lib_debuginfod_debuginfod_begin=no
+  pkg_failed=yes
 fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
+ else
+    pkg_failed=untried
 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_debuginfod_lib=yes
+if test -n "$DEBUGINFOD_LIBS"; then
+    pkg_cv_DEBUGINFOD_LIBS="$DEBUGINFOD_LIBS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libdebuginfod >= 0.179\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "libdebuginfod >= 0.179") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_DEBUGINFOD_LIBS=`$PKG_CONFIG --libs "libdebuginfod >= 0.179" 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes
+else
+  pkg_failed=yes
 fi
-
-  ac_fn_c_check_decl "$LINENO" "debuginfod_begin" "ac_cv_have_decl_debuginfod_begin" "#include <elfutils/debuginfod.h>
-"
-if test "x$ac_cv_have_decl_debuginfod_begin" = xyes; then :
-  have_debuginfod_h=yes
+ else
+    pkg_failed=untried
 fi
 
-  if test "x$have_debuginfod_lib" = "xyes" -a \
-          "x$have_debuginfod_h" = "xyes"; then
 
-$as_echo "#define HAVE_LIBDEBUGINFOD 1" >>confdefs.h
 
-    LIBDEBUGINFOD="-ldebuginfod"
+if test $pkg_failed = yes; then
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
 
-  else
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+        _pkg_short_errors_supported=yes
+else
+        _pkg_short_errors_supported=no
+fi
+        if test $_pkg_short_errors_supported = yes; then
+	        DEBUGINFOD_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libdebuginfod >= 0.179" 2>&1`
+        else
+	        DEBUGINFOD_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libdebuginfod >= 0.179" 2>&1`
+        fi
+	# Put the nasty error message in config.log where it belongs
+	echo "$DEBUGINFOD_PKG_ERRORS" >&5
 
-    if test "$with_debuginfod" = yes; then
-      as_fn_error $? "debuginfod is missing or unusable" "$LINENO" 5
-    else
-      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: debuginfod is missing or unusable; some features may be unavailable." >&5
-$as_echo "$as_me: WARNING: debuginfod is missing or unusable; some features may be unavailable." >&2;}
-    fi
-  fi
+	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
+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
+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 "#define HAVE_LIBDEBUGINFOD 1" >>confdefs.h
+
+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
 
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH] config/debuginfod.m4: Use PKG_CHECK_MODULES
  2020-05-02  2:29 [PATCH] config/debuginfod.m4: Use PKG_CHECK_MODULES Aaron Merey
@ 2020-05-05 16:41 ` Jeff Law
  2020-05-05 21:23   ` Aaron Merey
  0 siblings, 1 reply; 37+ messages in thread
From: Jeff Law @ 2020-05-05 16:41 UTC (permalink / raw)
  To: Aaron Merey, gcc-patches, binutils; +Cc: simark

On Fri, 2020-05-01 at 22:29 -0400, Aaron Merey via Gcc-patches wrote:
> Hello,
> 
> I'm not sure if this is the right mailing list for this patch but it modifies 
> the top level directory of binutils-gdb for which I understand GCC to be the 
> upstream. The purpose of this patch is to use PKG_CHECK_MODULES in 
> config/debuginfod.m4 since debuginfod supports pkg-config. Otherwise the 
> functionality of debuginfod.m4 is not changed by this patch. The rest of the 
> changes involve renaming a debuginfod autoconf variable, removing an 
> unnecessary call to AC_DEBUGINFOD in the top level configure.ac and the 
> regeneration of files in gdb/, binutils/ and the top-level directory.
> 
> Aaron Merey
> 
> 
> From 31c1e42fb7185080a21673b8818dca01fc7d4d6f Mon Sep 17 00:00:00 2001
> From: Aaron Merey <amerey@redhat.com>
> Date: Fri, 1 May 2020 21:51:43 -0400
> Subject: [PATCH] config/debuginfod.m4: Use PKG_CHECK_MODULES
> 
> Use PKG_CHECK_MODULES to set the debuginfod autoconf vars.
> 
> ChangeLog:
> 
>         * config/debuginfod.m4: use PKG_CHECK_MODULES.
>         * configure: Rebuild.
>         * configure.ac: Remove AC_DEBUGINFOD.
> 
> ChangeLog/binutils:
> 
>         * Makefile.am: Replace LIBDEBUGINFOD with DEBUGINFOD_LIBS.
>         * Makefile.in: Rebuild.
>         * aclocal.m4: Rebuild.
>         * configure: Rebuild.
>         * doc/Makefile.in: Rebuild.
> 
> ChangeLog/gdb:
> 
>         * Makefile.in: Replace LIBDEBUGINFOD with DEBUGINFOD_LIBS.
>         * aclocal.m4: Rebuild.
>         * configure: Rebuild.
I can't ack the binutils or gdb directories.  But the toplevel and config/ bits
are fine.  Do you have commit privs to the GCC repo?  Do all these have to go in
together?  If so, that means we should coordinate commits and resyncing gcc, gdb
and binutils

jeff
> 


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH] config/debuginfod.m4: Use PKG_CHECK_MODULES
  2020-05-05 16:41 ` Jeff Law
@ 2020-05-05 21:23   ` Aaron Merey
  2020-05-08 20:56     ` Tom Tromey
  0 siblings, 1 reply; 37+ messages in thread
From: Aaron Merey @ 2020-05-05 21:23 UTC (permalink / raw)
  To: law; +Cc: gcc-patches, binutils, Simon Marchi, gdb-patches

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

On Tue, May 5, 2020 at 12:41 PM Jeff Law <law@redhat.com> wrote:
>
> On Fri, 2020-05-01 at 22:29 -0400, Aaron Merey via Gcc-patches wrote:
> > Hello,
> >
> > I'm not sure if this is the right mailing list for this patch but it modifies
> > the top level directory of binutils-gdb for which I understand GCC to be the
> > upstream. The purpose of this patch is to use PKG_CHECK_MODULES in
> > config/debuginfod.m4 since debuginfod supports pkg-config. Otherwise the
> > functionality of debuginfod.m4 is not changed by this patch. The rest of the
> > changes involve renaming a debuginfod autoconf variable, removing an
> > unnecessary call to AC_DEBUGINFOD in the top level configure.ac and the
> > regeneration of files in gdb/, binutils/ and the top-level directory.
> >
> > Aaron Merey
> >
> >
> > From 31c1e42fb7185080a21673b8818dca01fc7d4d6f Mon Sep 17 00:00:00 2001
> > From: Aaron Merey <amerey@redhat.com>
> > Date: Fri, 1 May 2020 21:51:43 -0400
> > Subject: [PATCH] config/debuginfod.m4: Use PKG_CHECK_MODULES
> >
> > Use PKG_CHECK_MODULES to set the debuginfod autoconf vars.
> >
> > ChangeLog:
> >
> >         * config/debuginfod.m4: use PKG_CHECK_MODULES.
> >         * configure: Rebuild.
> >         * configure.ac: Remove AC_DEBUGINFOD.
> >
> > ChangeLog/binutils:
> >
> >         * Makefile.am: Replace LIBDEBUGINFOD with DEBUGINFOD_LIBS.
> >         * Makefile.in: Rebuild.
> >         * aclocal.m4: Rebuild.
> >         * configure: Rebuild.
> >         * doc/Makefile.in: Rebuild.
> >
> > ChangeLog/gdb:
> >
> >         * Makefile.in: Replace LIBDEBUGINFOD with DEBUGINFOD_LIBS.
> >         * aclocal.m4: Rebuild.
> >         * configure: Rebuild.
> I can't ack the binutils or gdb directories.  But the toplevel and config/ bits
> are fine.  Do you have commit privs to the GCC repo?  Do all these have to go in
> together?  If so, that means we should coordinate commits and resyncing gcc, gdb
> and binutils

I do not have commit privs to the GCC repo. It's better if all parts
are committed
at once to keep the files consistent.

I've reattached the patch and cc'd gdb-patches. Binutils and GDB folks, do
you have any concerns with this patch?

Thanks,
Aaron

[-- Attachment #2: 0001-config-debuginfod.m4-Use-PKG_CHECK_MODULES.patch --]
[-- Type: text/x-patch, Size: 71772 bytes --]

[PATCH] config/debuginfod.m4: Use PKG_CHECK_MODULES

Hello,

I'm not sure if this is the right mailing list for this patch but it modifies 
the top level directory of binutils-gdb for which I understand GCC to be the 
upstream. The purpose of this patch is to use PKG_CHECK_MODULES in 
config/debuginfod.m4 since debuginfod supports pkg-config. Otherwise the 
functionality of debuginfod.m4 is not changed by this patch. The rest of the 
changes involve renaming a debuginfod autoconf variable, removing an 
unnecessary call to AC_DEBUGINFOD in the top level configure.ac and the 
regeneration of files in gdb/, binutils/ and the top-level directory.

Aaron Merey


From 31c1e42fb7185080a21673b8818dca01fc7d4d6f Mon Sep 17 00:00:00 2001
From: Aaron Merey <amerey@redhat.com>
Date: Fri, 1 May 2020 21:51:43 -0400
Subject: [PATCH] config/debuginfod.m4: Use PKG_CHECK_MODULES

Use PKG_CHECK_MODULES to set the debuginfod autoconf vars.

ChangeLog:

        * config/debuginfod.m4: use PKG_CHECK_MODULES.
        * configure: Rebuild.
        * configure.ac: Remove AC_DEBUGINFOD.

ChangeLog/binutils:

        * Makefile.am: Replace LIBDEBUGINFOD with DEBUGINFOD_LIBS.
        * Makefile.in: Rebuild.
        * aclocal.m4: Rebuild.
        * configure: Rebuild.
        * doc/Makefile.in: Rebuild.

ChangeLog/gdb:

        * Makefile.in: Replace LIBDEBUGINFOD with DEBUGINFOD_LIBS.
        * aclocal.m4: Rebuild.
        * configure: Rebuild.
---
 ChangeLog                |   6 +
 binutils/ChangeLog       |   9 +
 binutils/Makefile.am     |   6 +-
 binutils/Makefile.in     |   7 +-
 binutils/aclocal.m4      | 344 ++++++++++++++++++++++++++++++++++++
 binutils/configure       | 369 ++++++++++++++++++++++++++++-----------
 binutils/doc/Makefile.in |   6 +-
 config/debuginfod.m4     |  36 ++--
 configure                | 139 +--------------
 configure.ac             |   3 -
 gdb/ChangeLog            |   7 +
 gdb/Makefile.in          |   2 +-
 gdb/aclocal.m4           | 344 ++++++++++++++++++++++++++++++++++++
 gdb/configure            | 365 +++++++++++++++++++++++++++-----------
 14 files changed, 1266 insertions(+), 377 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f79c3e8fb5..49dca08bbc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2020-05-01  Aaron Merey  <amerey@redhat.com>
+
+	* config/debuginfod.m4: use PKG_CHECK_MODULES.
+	* configure: Rebuild.
+	* configure.ac: Remove AC_DEBUGINFOD.
+
 2020-04-21  Stephen Casner  <casner@acm.org>
 
 	PR 25830
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 52082fcae1..da6ef9c8c3 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,12 @@
+ChangeLog/binutils:
+2020-05-01  Aaron Merey  <amerey@redhat.com>
+
+	* Makefile.am: Replace LIBDEBUGINFOD with DEBUGINFOD_LIBS.
+	* Makefile.in: Rebuild.
+	* aclocal.m4: Rebuild.
+	* configure: Rebuild.
+	* doc/Makefile.in: Rebuild.
+
 2020-05-01  Alan Modra  <amodra@gmail.com>
 	    Haim Shimonovich  <Haim.Shimonovich@ceva-dsp.com>
 
diff --git a/binutils/Makefile.am b/binutils/Makefile.am
index e5cf5634a7..ecc5283b1b 100644
--- a/binutils/Makefile.am
+++ b/binutils/Makefile.am
@@ -53,7 +53,7 @@ AM_CFLAGS = $(WARN_CFLAGS) $(ZLIBINC)
 AM_CFLAGS_FOR_BUILD = $(WARN_CFLAGS_FOR_BUILD) $(ZLIBINC)
 LIBICONV = @LIBICONV@
 
-LIBDEBUGINFOD = @LIBDEBUGINFOD@
+DEBUGINFOD_LIBS = @DEBUGINFOD_LIBS@
 
 # these two are almost the same program
 AR_PROG=ar
@@ -247,7 +247,7 @@ objcopy_SOURCES = objcopy.c not-strip.c rename.c $(WRITE_DEBUG_SRCS) $(BULIBS)
 strings_SOURCES = strings.c $(BULIBS)
 
 readelf_SOURCES = readelf.c version.c unwind-ia64.c dwarf.c $(ELFLIBS)
-readelf_LDADD   = $(LIBINTL) $(LIBCTF_NOBFD) $(LIBIBERTY) $(ZLIB) $(LIBDEBUGINFOD)
+readelf_LDADD   = $(LIBINTL) $(LIBCTF_NOBFD) $(LIBIBERTY) $(ZLIB) $(DEBUGINFOD_LIBS)
 
 elfedit_SOURCES = elfedit.c version.c $(ELFLIBS)
 elfedit_LDADD = $(LIBINTL) $(LIBIBERTY)
@@ -258,7 +258,7 @@ nm_new_SOURCES = nm.c $(BULIBS)
 
 objdump_SOURCES = objdump.c dwarf.c prdbg.c $(DEBUG_SRCS) $(BULIBS) $(ELFLIBS)
 EXTRA_objdump_SOURCES = od-xcoff.c
-objdump_LDADD = $(OBJDUMP_PRIVATE_OFILES) $(OPCODES) $(LIBCTF) $(BFDLIB) $(LIBIBERTY) $(LIBINTL) $(LIBDEBUGINFOD)
+objdump_LDADD = $(OBJDUMP_PRIVATE_OFILES) $(OPCODES) $(LIBCTF) $(BFDLIB) $(LIBIBERTY) $(LIBINTL) $(DEBUGINFOD_LIBS)
 
 objdump.@OBJEXT@:objdump.c
 if am__fastdepCC
diff --git a/binutils/Makefile.in b/binutils/Makefile.in
index ee6f267df9..7780729d69 100644
--- a/binutils/Makefile.in
+++ b/binutils/Makefile.in
@@ -420,6 +420,8 @@ CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DATADIRNAME = @DATADIRNAME@
+DEBUGINFOD_CFLAGS = @DEBUGINFOD_CFLAGS@
+DEBUGINFOD_LIBS = @DEBUGINFOD_LIBS@
 DEFS = @DEFS@
 DEMANGLER_NAME = @DEMANGLER_NAME@
 DEPDIR = @DEPDIR@
@@ -451,7 +453,6 @@ LDFLAGS = @LDFLAGS@
 LEX = `if [ -f ../flex/flex ]; then echo ../flex/flex; else echo @LEX@; fi`
 LEXLIB = @LEXLIB@
 LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
-LIBDEBUGINFOD = @LIBDEBUGINFOD@
 LIBICONV = @LIBICONV@
 LIBINTL = @LIBINTL@
 LIBINTL_DEP = @LIBINTL_DEP@
@@ -487,6 +488,9 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
+PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
 POSUB = @POSUB@
 RANLIB = @RANLIB@
 SED = @SED@
@@ -575,6 +579,7 @@ ZLIB = @zlibdir@ -lz
 ZLIBINC = @zlibinc@
 AM_CFLAGS = $(WARN_CFLAGS) $(ZLIBINC)
 AM_CFLAGS_FOR_BUILD = $(WARN_CFLAGS_FOR_BUILD) $(ZLIBINC)
+LIBDEBUGINFOD = @DEBUGINFOD_LIBS@
 
 # these two are almost the same program
 AR_PROG = ar
diff --git a/binutils/aclocal.m4 b/binutils/aclocal.m4
index 4fa32fffd8..01e7406f83 100644
--- a/binutils/aclocal.m4
+++ b/binutils/aclocal.m4
@@ -20,6 +20,350 @@ You have another version of autoconf.  It may work, but is not guaranteed to.
 If you have problems, you may need to regenerate the build system entirely.
 To do so, use the procedure documented by the package, typically 'autoreconf'.])])
 
+# pkg.m4 - Macros to locate and utilise pkg-config.   -*- Autoconf -*-
+# serial 11 (pkg-config-0.29.1)
+
+dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
+dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
+dnl
+dnl This program is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 2 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+dnl General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+dnl 02111-1307, USA.
+dnl
+dnl As a special exception to the GNU General Public License, if you
+dnl distribute this file as part of a program that contains a
+dnl configuration script generated by Autoconf, you may include it under
+dnl the same distribution terms that you use for the rest of that
+dnl program.
+
+dnl PKG_PREREQ(MIN-VERSION)
+dnl -----------------------
+dnl Since: 0.29
+dnl
+dnl Verify that the version of the pkg-config macros are at least
+dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's
+dnl installed version of pkg-config, this checks the developer's version
+dnl of pkg.m4 when generating configure.
+dnl
+dnl To ensure that this macro is defined, also add:
+dnl m4_ifndef([PKG_PREREQ],
+dnl     [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])])
+dnl
+dnl See the "Since" comment for each macro you use to see what version
+dnl of the macros you require.
+m4_defun([PKG_PREREQ],
+[m4_define([PKG_MACROS_VERSION], [0.29.1])
+m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
+    [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
+])dnl PKG_PREREQ
+
+dnl PKG_PROG_PKG_CONFIG([MIN-VERSION])
+dnl ----------------------------------
+dnl Since: 0.16
+dnl
+dnl Search for the pkg-config tool and set the PKG_CONFIG variable to
+dnl first found in the path. Checks that the version of pkg-config found
+dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is
+dnl used since that's the first version where most current features of
+dnl pkg-config existed.
+AC_DEFUN([PKG_PROG_PKG_CONFIG],
+[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
+m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
+m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
+AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
+AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
+AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
+
+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
+	AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
+fi
+if test -n "$PKG_CONFIG"; then
+	_pkg_min_version=m4_default([$1], [0.9.0])
+	AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
+	if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
+		AC_MSG_RESULT([yes])
+	else
+		AC_MSG_RESULT([no])
+		PKG_CONFIG=""
+	fi
+fi[]dnl
+])dnl PKG_PROG_PKG_CONFIG
+
+dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+dnl -------------------------------------------------------------------
+dnl Since: 0.18
+dnl
+dnl Check to see whether a particular set of modules exists. Similar to
+dnl PKG_CHECK_MODULES(), but does not set variables or print errors.
+dnl
+dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+dnl only at the first occurence in configure.ac, so if the first place
+dnl it's called might be skipped (such as if it is within an "if", you
+dnl have to call PKG_CHECK_EXISTS manually
+AC_DEFUN([PKG_CHECK_EXISTS],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+if test -n "$PKG_CONFIG" && \
+    AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
+  m4_default([$2], [:])
+m4_ifvaln([$3], [else
+  $3])dnl
+fi])
+
+dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
+dnl ---------------------------------------------
+dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting
+dnl pkg_failed based on the result.
+m4_define([_PKG_CONFIG],
+[if test -n "$$1"; then
+    pkg_cv_[]$1="$$1"
+ elif test -n "$PKG_CONFIG"; then
+    PKG_CHECK_EXISTS([$3],
+                     [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes ],
+		     [pkg_failed=yes])
+ else
+    pkg_failed=untried
+fi[]dnl
+])dnl _PKG_CONFIG
+
+dnl _PKG_SHORT_ERRORS_SUPPORTED
+dnl ---------------------------
+dnl Internal check to see if pkg-config supports short errors.
+AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+        _pkg_short_errors_supported=yes
+else
+        _pkg_short_errors_supported=no
+fi[]dnl
+])dnl _PKG_SHORT_ERRORS_SUPPORTED
+
+
+dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
+dnl   [ACTION-IF-NOT-FOUND])
+dnl --------------------------------------------------------------
+dnl Since: 0.4.0
+dnl
+dnl Note that if there is a possibility the first call to
+dnl PKG_CHECK_MODULES might not happen, you should be sure to include an
+dnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
+AC_DEFUN([PKG_CHECK_MODULES],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
+AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
+
+pkg_failed=no
+AC_MSG_CHECKING([for $1])
+
+_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
+_PKG_CONFIG([$1][_LIBS], [libs], [$2])
+
+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.])
+
+if test $pkg_failed = yes; then
+	AC_MSG_RESULT([no])
+        _PKG_SHORT_ERRORS_SUPPORTED
+        if test $_pkg_short_errors_supported = yes; then
+	        $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
+        else
+	        $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
+        fi
+	# Put the nasty error message in config.log where it belongs
+	echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
+
+	m4_default([$4], [AC_MSG_ERROR(
+[Package requirements ($2) were not met:
+
+$$1_PKG_ERRORS
+
+Consider adjusting the PKG_CONFIG_PATH environment variable if you
+installed software in a non-standard prefix.
+
+_PKG_TEXT])[]dnl
+        ])
+elif test $pkg_failed = untried; then
+	AC_MSG_RESULT([no])
+	m4_default([$4], [AC_MSG_FAILURE(
+[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.
+
+_PKG_TEXT
+
+To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl
+        ])
+else
+	$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
+	$1[]_LIBS=$pkg_cv_[]$1[]_LIBS
+        AC_MSG_RESULT([yes])
+	$3
+fi[]dnl
+])dnl PKG_CHECK_MODULES
+
+
+dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
+dnl   [ACTION-IF-NOT-FOUND])
+dnl ---------------------------------------------------------------------
+dnl Since: 0.29
+dnl
+dnl Checks for existence of MODULES and gathers its build flags with
+dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags
+dnl and VARIABLE-PREFIX_LIBS from --libs.
+dnl
+dnl Note that if there is a possibility the first call to
+dnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to
+dnl include an explicit call to PKG_PROG_PKG_CONFIG in your
+dnl configure.ac.
+AC_DEFUN([PKG_CHECK_MODULES_STATIC],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+_save_PKG_CONFIG=$PKG_CONFIG
+PKG_CONFIG="$PKG_CONFIG --static"
+PKG_CHECK_MODULES($@)
+PKG_CONFIG=$_save_PKG_CONFIG[]dnl
+])dnl PKG_CHECK_MODULES_STATIC
+
+
+dnl PKG_INSTALLDIR([DIRECTORY])
+dnl -------------------------
+dnl Since: 0.27
+dnl
+dnl Substitutes the variable pkgconfigdir as the location where a module
+dnl should install pkg-config .pc files. By default the directory is
+dnl $libdir/pkgconfig, but the default can be changed by passing
+dnl DIRECTORY. The user can override through the --with-pkgconfigdir
+dnl parameter.
+AC_DEFUN([PKG_INSTALLDIR],
+[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
+m4_pushdef([pkg_description],
+    [pkg-config installation directory @<:@]pkg_default[@:>@])
+AC_ARG_WITH([pkgconfigdir],
+    [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],,
+    [with_pkgconfigdir=]pkg_default)
+AC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
+m4_popdef([pkg_default])
+m4_popdef([pkg_description])
+])dnl PKG_INSTALLDIR
+
+
+dnl PKG_NOARCH_INSTALLDIR([DIRECTORY])
+dnl --------------------------------
+dnl Since: 0.27
+dnl
+dnl Substitutes the variable noarch_pkgconfigdir as the location where a
+dnl module should install arch-independent pkg-config .pc files. By
+dnl default the directory is $datadir/pkgconfig, but the default can be
+dnl changed by passing DIRECTORY. The user can override through the
+dnl --with-noarch-pkgconfigdir parameter.
+AC_DEFUN([PKG_NOARCH_INSTALLDIR],
+[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
+m4_pushdef([pkg_description],
+    [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@])
+AC_ARG_WITH([noarch-pkgconfigdir],
+    [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],,
+    [with_noarch_pkgconfigdir=]pkg_default)
+AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
+m4_popdef([pkg_default])
+m4_popdef([pkg_description])
+])dnl PKG_NOARCH_INSTALLDIR
+
+
+dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
+dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+dnl -------------------------------------------
+dnl Since: 0.28
+dnl
+dnl Retrieves the value of the pkg-config variable for the given module.
+AC_DEFUN([PKG_CHECK_VAR],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
+
+_PKG_CONFIG([$1], [variable="][$3]["], [$2])
+AS_VAR_COPY([$1], [pkg_cv_][$1])
+
+AS_VAR_IF([$1], [""], [$5], [$4])dnl
+])dnl PKG_CHECK_VAR
+
+dnl PKG_WITH_MODULES(VARIABLE-PREFIX, MODULES,
+dnl   [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND],
+dnl   [DESCRIPTION], [DEFAULT])
+dnl ------------------------------------------
+dnl
+dnl Prepare a "--with-" configure option using the lowercase
+dnl [VARIABLE-PREFIX] name, merging the behaviour of AC_ARG_WITH and
+dnl PKG_CHECK_MODULES in a single macro.
+AC_DEFUN([PKG_WITH_MODULES],
+[
+m4_pushdef([with_arg], m4_tolower([$1]))
+
+m4_pushdef([description],
+           [m4_default([$5], [build with ]with_arg[ support])])
+
+m4_pushdef([def_arg], [m4_default([$6], [auto])])
+m4_pushdef([def_action_if_found], [AS_TR_SH([with_]with_arg)=yes])
+m4_pushdef([def_action_if_not_found], [AS_TR_SH([with_]with_arg)=no])
+
+m4_case(def_arg,
+            [yes],[m4_pushdef([with_without], [--without-]with_arg)],
+            [m4_pushdef([with_without],[--with-]with_arg)])
+
+AC_ARG_WITH(with_arg,
+     AS_HELP_STRING(with_without, description[ @<:@default=]def_arg[@:>@]),,
+    [AS_TR_SH([with_]with_arg)=def_arg])
+
+AS_CASE([$AS_TR_SH([with_]with_arg)],
+            [yes],[PKG_CHECK_MODULES([$1],[$2],$3,$4)],
+            [auto],[PKG_CHECK_MODULES([$1],[$2],
+                                        [m4_n([def_action_if_found]) $3],
+                                        [m4_n([def_action_if_not_found]) $4])])
+
+m4_popdef([with_arg])
+m4_popdef([description])
+m4_popdef([def_arg])
+
+])dnl PKG_WITH_MODULES
+
+dnl PKG_HAVE_WITH_MODULES(VARIABLE-PREFIX, MODULES,
+dnl   [DESCRIPTION], [DEFAULT])
+dnl -----------------------------------------------
+dnl
+dnl Convenience macro to trigger AM_CONDITIONAL after PKG_WITH_MODULES
+dnl check._[VARIABLE-PREFIX] is exported as make variable.
+AC_DEFUN([PKG_HAVE_WITH_MODULES],
+[
+PKG_WITH_MODULES([$1],[$2],,,[$3],[$4])
+
+AM_CONDITIONAL([HAVE_][$1],
+               [test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"])
+])dnl PKG_HAVE_WITH_MODULES
+
+dnl PKG_HAVE_DEFINE_WITH_MODULES(VARIABLE-PREFIX, MODULES,
+dnl   [DESCRIPTION], [DEFAULT])
+dnl ------------------------------------------------------
+dnl
+dnl Convenience macro to run AM_CONDITIONAL and AC_DEFINE after
+dnl PKG_WITH_MODULES check. HAVE_[VARIABLE-PREFIX] is exported as make
+dnl and preprocessor variable.
+AC_DEFUN([PKG_HAVE_DEFINE_WITH_MODULES],
+[
+PKG_HAVE_WITH_MODULES([$1],[$2],[$3],[$4])
+
+AS_IF([test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"],
+        [AC_DEFINE([HAVE_][$1], 1, [Enable ]m4_tolower([$1])[ support])])
+])dnl PKG_HAVE_DEFINE_WITH_MODULES
+
 # Copyright (C) 2002-2017 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
diff --git a/binutils/configure b/binutils/configure
index 782fffac6f..97d321acb3 100755
--- a/binutils/configure
+++ b/binutils/configure
@@ -684,7 +684,11 @@ WARN_WRITE_STRINGS
 NO_WERROR
 WARN_CFLAGS_FOR_BUILD
 WARN_CFLAGS
-LIBDEBUGINFOD
+DEBUGINFOD_LIBS
+DEBUGINFOD_CFLAGS
+PKG_CONFIG_LIBDIR
+PKG_CONFIG_PATH
+PKG_CONFIG
 OTOOL64
 OTOOL
 LIPO
@@ -833,6 +837,11 @@ LDFLAGS
 LIBS
 CPPFLAGS
 CPP
+PKG_CONFIG
+PKG_CONFIG_PATH
+PKG_CONFIG_LIBDIR
+DEBUGINFOD_CFLAGS
+DEBUGINFOD_LIBS
 YACC
 YFLAGS'
 
@@ -1503,6 +1512,15 @@ Some influential environment variables:
   CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
               you have headers in a nonstandard directory <include dir>
   CPP         C preprocessor
+  PKG_CONFIG  path to pkg-config utility
+  PKG_CONFIG_PATH
+              directories to add to pkg-config's search path
+  PKG_CONFIG_LIBDIR
+              path overriding pkg-config's built-in search path
+  DEBUGINFOD_CFLAGS
+              C compiler flags for DEBUGINFOD, overriding pkg-config
+  DEBUGINFOD_LIBS
+              linker flags for DEBUGINFOD, overriding pkg-config
   YACC        The `Yet Another Compiler Compiler' implementation to use.
               Defaults to the first program found out of: `bison -y', `byacc',
               `yacc'.
@@ -1938,52 +1956,6 @@ $as_echo "$ac_res" >&6; }
 
 } # ac_fn_c_check_func
 
-# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
-# ---------------------------------------------
-# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
-# accordingly.
-ac_fn_c_check_decl ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  as_decl_name=`echo $2|sed 's/ *(.*//'`
-  as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
-$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
-if eval \${$3+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$4
-int
-main ()
-{
-#ifndef $as_decl_name
-#ifdef __cplusplus
-  (void) $as_decl_use;
-#else
-  (void) $as_decl_name;
-#endif
-#endif
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  eval "$3=yes"
-else
-  eval "$3=no"
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-eval ac_res=\$$3
-	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-
-} # ac_fn_c_check_decl
-
 # ac_fn_c_compute_int LINENO EXPR VAR INCLUDES
 # --------------------------------------------
 # Tries to find the compile-time value of EXPR in a program that includes
@@ -2220,6 +2192,52 @@ $as_echo "$ac_res" >&6; }
   eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
 
 } # ac_fn_c_check_type
+
+# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
+# ---------------------------------------------
+# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
+# accordingly.
+ac_fn_c_check_decl ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  as_decl_name=`echo $2|sed 's/ *(.*//'`
+  as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
+$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
+if eval \${$3+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+#ifndef $as_decl_name
+#ifdef __cplusplus
+  (void) $as_decl_use;
+#else
+  (void) $as_decl_name;
+#endif
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$3=yes"
+else
+  eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_decl
 cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
@@ -11529,7 +11547,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11532 "configure"
+#line 11550 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11635,7 +11653,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11638 "configure"
+#line 11656 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12242,7 +12260,127 @@ fi
 
 
 
-# Enable debuginfod
+
+
+
+
+
+
+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
+	if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
+set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_PKG_CONFIG+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $PKG_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+PKG_CONFIG=$ac_cv_path_PKG_CONFIG
+if test -n "$PKG_CONFIG"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
+$as_echo "$PKG_CONFIG" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_path_PKG_CONFIG"; then
+  ac_pt_PKG_CONFIG=$PKG_CONFIG
+  # Extract the first word of "pkg-config", so it can be a program name with args.
+set dummy pkg-config; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $ac_pt_PKG_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG
+if test -n "$ac_pt_PKG_CONFIG"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5
+$as_echo "$ac_pt_PKG_CONFIG" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_pt_PKG_CONFIG" = x; then
+    PKG_CONFIG=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    PKG_CONFIG=$ac_pt_PKG_CONFIG
+  fi
+else
+  PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
+fi
+
+fi
+if test -n "$PKG_CONFIG"; then
+	_pkg_min_version=0.9.0
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5
+$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; }
+	if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+	else
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+		PKG_CONFIG=""
+	fi
+fi
+
+# Handle optional debuginfod support
 
 # Check whether --with-debuginfod was given.
 if test "${with_debuginfod+set}" = set; then :
@@ -12256,72 +12394,93 @@ $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; }
 
-if test "${with_debuginfod}" = no; then
-  { $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;}
-else
-  { $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.  */
+if test "x$with_debuginfod" != xno; then
 
-/* 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
+pkg_failed=no
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for DEBUGINFOD" >&5
+$as_echo_n "checking for DEBUGINFOD... " >&6; }
+
+if test -n "$DEBUGINFOD_CFLAGS"; then
+    pkg_cv_DEBUGINFOD_CFLAGS="$DEBUGINFOD_CFLAGS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libdebuginfod >= 0.179\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "libdebuginfod >= 0.179") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_DEBUGINFOD_CFLAGS=`$PKG_CONFIG --cflags "libdebuginfod >= 0.179" 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes
 else
-  ac_cv_lib_debuginfod_debuginfod_begin=no
+  pkg_failed=yes
 fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
+ else
+    pkg_failed=untried
+fi
+if test -n "$DEBUGINFOD_LIBS"; then
+    pkg_cv_DEBUGINFOD_LIBS="$DEBUGINFOD_LIBS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libdebuginfod >= 0.179\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "libdebuginfod >= 0.179") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_DEBUGINFOD_LIBS=`$PKG_CONFIG --libs "libdebuginfod >= 0.179" 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes
+else
+  pkg_failed=yes
 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_debuginfod_lib=yes
+ else
+    pkg_failed=untried
 fi
 
-  ac_fn_c_check_decl "$LINENO" "debuginfod_begin" "ac_cv_have_decl_debuginfod_begin" "#include <elfutils/debuginfod.h>
-"
-if test "x$ac_cv_have_decl_debuginfod_begin" = xyes; then :
-  have_debuginfod_h=yes
-fi
 
-  if test "x$have_debuginfod_lib" = "xyes" -a \
-          "x$have_debuginfod_h" = "xyes"; then
 
-$as_echo "#define HAVE_LIBDEBUGINFOD 1" >>confdefs.h
+if test $pkg_failed = yes; then
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
 
-    LIBDEBUGINFOD="-ldebuginfod"
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+        _pkg_short_errors_supported=yes
+else
+        _pkg_short_errors_supported=no
+fi
+        if test $_pkg_short_errors_supported = yes; then
+	        DEBUGINFOD_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libdebuginfod >= 0.179" 2>&1`
+        else
+	        DEBUGINFOD_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libdebuginfod >= 0.179" 2>&1`
+        fi
+	# Put the nasty error message in config.log where it belongs
+	echo "$DEBUGINFOD_PKG_ERRORS" >&5
 
-  else
+	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
+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
+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; }
 
-    if test "$with_debuginfod" = yes; then
-      as_fn_error $? "debuginfod is missing or unusable" "$LINENO" 5
-    else
-      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: debuginfod is missing or unusable; some features may be unavailable." >&5
-$as_echo "$as_me: WARNING: debuginfod is missing or unusable; some features may be unavailable." >&2;}
-    fi
-  fi
+$as_echo "#define HAVE_LIBDEBUGINFOD 1" >>confdefs.h
+
+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
 
 
diff --git a/binutils/doc/Makefile.in b/binutils/doc/Makefile.in
index b00260bc25..1025d7bdee 100644
--- a/binutils/doc/Makefile.in
+++ b/binutils/doc/Makefile.in
@@ -255,6 +255,8 @@ CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DATADIRNAME = @DATADIRNAME@
+DEBUGINFOD_CFLAGS = @DEBUGINFOD_CFLAGS@
+DEBUGINFOD_LIBS = @DEBUGINFOD_LIBS@
 DEFS = @DEFS@
 DEMANGLER_NAME = @DEMANGLER_NAME@
 DEPDIR = @DEPDIR@
@@ -286,7 +288,6 @@ LDFLAGS = @LDFLAGS@
 LEX = @LEX@
 LEXLIB = @LEXLIB@
 LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
-LIBDEBUGINFOD = @LIBDEBUGINFOD@
 LIBICONV = @LIBICONV@
 LIBINTL = @LIBINTL@
 LIBINTL_DEP = @LIBINTL_DEP@
@@ -320,6 +321,9 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
+PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
 POSUB = @POSUB@
 RANLIB = @RANLIB@
 SED = @SED@
diff --git a/config/debuginfod.m4 b/config/debuginfod.m4
index 9979abe89d..2c1bfbdb54 100644
--- a/config/debuginfod.m4
+++ b/config/debuginfod.m4
@@ -1,4 +1,4 @@
-dnl Copyright (C) 1997-2019 Free Software Foundation, Inc.
+dnl Copyright (C) 1997-2020 Free Software Foundation, Inc.
 dnl This file is free software, distributed under the terms of the GNU
 dnl General Public License.  As a special exception to the GNU General
 dnl Public License, this file may be distributed as part of a program
@@ -7,32 +7,22 @@ dnl the same distribution terms as the rest of that program.
 
 AC_DEFUN([AC_DEBUGINFOD],
 [
-# Enable debuginfod
+# Handle optional debuginfod support
 AC_ARG_WITH([debuginfod],
-        AC_HELP_STRING([--with-debuginfod],
-                       [Enable debuginfo lookups with debuginfod (auto/yes/no)]),
-        [], [with_debuginfod=auto])
+  AC_HELP_STRING([--with-debuginfod], [Enable debuginfo lookups with debuginfod (auto/yes/no)]),
+  [], [with_debuginfod=auto])
 AC_MSG_CHECKING([whether to use debuginfod])
 AC_MSG_RESULT([$with_debuginfod])
 
-if test "${with_debuginfod}" = no; then
-  AC_MSG_WARN([debuginfod support disabled; some features may be unavailable.])
+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_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])
 else
-  AC_CHECK_LIB([debuginfod], [debuginfod_begin], [have_debuginfod_lib=yes])
-  AC_CHECK_DECL([debuginfod_begin], [have_debuginfod_h=yes], [],
-                [#include <elfutils/debuginfod.h>])
-  if test "x$have_debuginfod_lib" = "xyes" -a \
-          "x$have_debuginfod_h" = "xyes"; then
-    AC_DEFINE([HAVE_LIBDEBUGINFOD], [1],
-              [Define to 1 if debuginfod is enabled.])
-    AC_SUBST([LIBDEBUGINFOD], ["-ldebuginfod"])
-  else
-    AC_SUBST([LIBDEBUGINFOD], [])
-    if test "$with_debuginfod" = yes; then
-      AC_MSG_ERROR([debuginfod is missing or unusable])
-    else
-      AC_MSG_WARN([debuginfod is missing or unusable; some features may be unavailable.])
-    fi
-  fi
+  AC_MSG_WARN([debuginfod support disabled; some features may be unavailable.])
 fi
 ])
diff --git a/configure b/configure
index 54d0339ab9..68779feb42 100755
--- a/configure
+++ b/configure
@@ -690,7 +690,6 @@ extra_mpc_gmp_configure_flags
 extra_mpfr_configure_flags
 gmpinc
 gmplibs
-LIBDEBUGINFOD
 do_compare
 GNATMAKE
 GNATBIND
@@ -791,7 +790,6 @@ enable_libssp
 enable_libstdcxx
 enable_liboffloadmic
 enable_bootstrap
-with_debuginfod
 with_mpc
 with_mpc_include
 with_mpc_lib
@@ -1555,8 +1553,6 @@ Optional Packages:
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
   --with-build-libsubdir=DIR  Directory where to find libraries for build system
   --with-system-zlib      use installed libz
-  --with-debuginfod       Enable debuginfo lookups with debuginfod
-                          (auto/yes/no)
   --with-mpc=PATH         specify prefix directory for installed MPC package.
                           Equivalent to --with-mpc-include=PATH/include plus
                           --with-mpc-lib=PATH/lib
@@ -1925,52 +1921,6 @@ fi
   as_fn_set_status $ac_retval
 
 } # ac_fn_c_try_link
-
-# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
-# ---------------------------------------------
-# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
-# accordingly.
-ac_fn_c_check_decl ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  as_decl_name=`echo $2|sed 's/ *(.*//'`
-  as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
-$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
-if eval \${$3+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$4
-int
-main ()
-{
-#ifndef $as_decl_name
-#ifdef __cplusplus
-  (void) $as_decl_use;
-#else
-  (void) $as_decl_name;
-#endif
-#endif
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  eval "$3=yes"
-else
-  eval "$3=no"
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-eval ac_res=\$$3
-	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-
-} # ac_fn_c_check_decl
 cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
@@ -5505,92 +5455,6 @@ gmplibs="-lmpc -lmpfr -lgmp"
 gmpinc=
 have_gmp=no
 
-# Check for debuginfod
-
-
-# Enable debuginfod
-
-# Check whether --with-debuginfod was given.
-if test "${with_debuginfod+set}" = set; then :
-  withval=$with_debuginfod;
-else
-  with_debuginfod=auto
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use debuginfod" >&5
-$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; }
-
-if test "${with_debuginfod}" = no; then
-  { $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;}
-else
-  { $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.  */
-
-/* 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_debuginfod_lib=yes
-fi
-
-  ac_fn_c_check_decl "$LINENO" "debuginfod_begin" "ac_cv_have_decl_debuginfod_begin" "#include <elfutils/debuginfod.h>
-"
-if test "x$ac_cv_have_decl_debuginfod_begin" = xyes; then :
-  have_debuginfod_h=yes
-fi
-
-  if test "x$have_debuginfod_lib" = "xyes" -a \
-          "x$have_debuginfod_h" = "xyes"; then
-
-$as_echo "#define HAVE_LIBDEBUGINFOD 1" >>confdefs.h
-
-    LIBDEBUGINFOD="-ldebuginfod"
-
-  else
-
-    if test "$with_debuginfod" = yes; then
-      as_fn_error $? "debuginfod is missing or unusable" "$LINENO" 5
-    else
-      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: debuginfod is missing or unusable; some features may be unavailable." >&5
-$as_echo "$as_me: WARNING: debuginfod is missing or unusable; some features may be unavailable." >&2;}
-    fi
-  fi
-fi
-
-
 # Specify a location for mpc
 # check for this first so it ends up on the link line before mpfr.
 
@@ -5745,7 +5609,8 @@ if test -d ${srcdir}/gcc && test "x$have_gmp" = xno; then
   # Check for the recommended and required versions of GMP.
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the correct version of gmp.h" >&5
 $as_echo_n "checking for the correct version of gmp.h... " >&6; }
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include "gmp.h"
 int
diff --git a/configure.ac b/configure.ac
index a910c4fd6b..49790877e8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1383,9 +1383,6 @@ gmplibs="-lmpc -lmpfr -lgmp"
 gmpinc=
 have_gmp=no
 
-# Check for debuginfod
-AC_DEBUGINFOD
-
 # Specify a location for mpc
 # check for this first so it ends up on the link line before mpfr.
 AC_ARG_WITH(mpc,
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index ee4f3a74c0..225518919c 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+ChangeLog/gdb:
+2020-05-01  Aaron Merey  <amerey@redhat.com>
+
+	* Makefile.in: Replace LIBDEBUGINFOD with DEBUGINFOD_LIBS.
+	* aclocal.m4: Rebuild.
+	* configure: Rebuild.
+
 2020-05-01  Philippe Waroquiers  <philippe.waroquiers@skynet.be>
 	* gdb-gdb.gdb-in: Remove breakpoint on disappeared function
 	info_command.
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index e3ce6a285f..75108910c1 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -621,7 +621,7 @@ CLIBS = $(SIM) $(READLINE) $(OPCODES) $(BFD) $(LIBCTF) $(ZLIB) \
 	$(LIBEXPAT) $(LIBLZMA) $(LIBBABELTRACE) $(LIBIPT) \
 	$(WIN32LIBS) $(LIBGNU) $(LIBICONV) \
 	$(LIBMPFR) $(SRCHIGH_LIBS) $(LIBXXHASH) $(PTHREAD_LIBS) \
-	@LIBDEBUGINFOD@
+	@DEBUGINFOD_LIBS@
 CDEPS = $(NAT_CDEPS) $(SIM) $(BFD) $(READLINE_DEPS) $(LIBCTF) \
 	$(OPCODES) $(INTL_DEPS) $(LIBIBERTY) $(CONFIG_DEPS) $(LIBGNU) \
 	$(LIBSUPPORT)
diff --git a/gdb/aclocal.m4 b/gdb/aclocal.m4
index 110b416e61..ea8816ee21 100644
--- a/gdb/aclocal.m4
+++ b/gdb/aclocal.m4
@@ -12,6 +12,350 @@
 # PARTICULAR PURPOSE.
 
 m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
+# pkg.m4 - Macros to locate and utilise pkg-config.   -*- Autoconf -*-
+# serial 11 (pkg-config-0.29.1)
+
+dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
+dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
+dnl
+dnl This program is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 2 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+dnl General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+dnl 02111-1307, USA.
+dnl
+dnl As a special exception to the GNU General Public License, if you
+dnl distribute this file as part of a program that contains a
+dnl configuration script generated by Autoconf, you may include it under
+dnl the same distribution terms that you use for the rest of that
+dnl program.
+
+dnl PKG_PREREQ(MIN-VERSION)
+dnl -----------------------
+dnl Since: 0.29
+dnl
+dnl Verify that the version of the pkg-config macros are at least
+dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's
+dnl installed version of pkg-config, this checks the developer's version
+dnl of pkg.m4 when generating configure.
+dnl
+dnl To ensure that this macro is defined, also add:
+dnl m4_ifndef([PKG_PREREQ],
+dnl     [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])])
+dnl
+dnl See the "Since" comment for each macro you use to see what version
+dnl of the macros you require.
+m4_defun([PKG_PREREQ],
+[m4_define([PKG_MACROS_VERSION], [0.29.1])
+m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
+    [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
+])dnl PKG_PREREQ
+
+dnl PKG_PROG_PKG_CONFIG([MIN-VERSION])
+dnl ----------------------------------
+dnl Since: 0.16
+dnl
+dnl Search for the pkg-config tool and set the PKG_CONFIG variable to
+dnl first found in the path. Checks that the version of pkg-config found
+dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is
+dnl used since that's the first version where most current features of
+dnl pkg-config existed.
+AC_DEFUN([PKG_PROG_PKG_CONFIG],
+[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
+m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
+m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
+AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
+AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
+AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
+
+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
+	AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
+fi
+if test -n "$PKG_CONFIG"; then
+	_pkg_min_version=m4_default([$1], [0.9.0])
+	AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
+	if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
+		AC_MSG_RESULT([yes])
+	else
+		AC_MSG_RESULT([no])
+		PKG_CONFIG=""
+	fi
+fi[]dnl
+])dnl PKG_PROG_PKG_CONFIG
+
+dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+dnl -------------------------------------------------------------------
+dnl Since: 0.18
+dnl
+dnl Check to see whether a particular set of modules exists. Similar to
+dnl PKG_CHECK_MODULES(), but does not set variables or print errors.
+dnl
+dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+dnl only at the first occurence in configure.ac, so if the first place
+dnl it's called might be skipped (such as if it is within an "if", you
+dnl have to call PKG_CHECK_EXISTS manually
+AC_DEFUN([PKG_CHECK_EXISTS],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+if test -n "$PKG_CONFIG" && \
+    AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
+  m4_default([$2], [:])
+m4_ifvaln([$3], [else
+  $3])dnl
+fi])
+
+dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
+dnl ---------------------------------------------
+dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting
+dnl pkg_failed based on the result.
+m4_define([_PKG_CONFIG],
+[if test -n "$$1"; then
+    pkg_cv_[]$1="$$1"
+ elif test -n "$PKG_CONFIG"; then
+    PKG_CHECK_EXISTS([$3],
+                     [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes ],
+		     [pkg_failed=yes])
+ else
+    pkg_failed=untried
+fi[]dnl
+])dnl _PKG_CONFIG
+
+dnl _PKG_SHORT_ERRORS_SUPPORTED
+dnl ---------------------------
+dnl Internal check to see if pkg-config supports short errors.
+AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+        _pkg_short_errors_supported=yes
+else
+        _pkg_short_errors_supported=no
+fi[]dnl
+])dnl _PKG_SHORT_ERRORS_SUPPORTED
+
+
+dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
+dnl   [ACTION-IF-NOT-FOUND])
+dnl --------------------------------------------------------------
+dnl Since: 0.4.0
+dnl
+dnl Note that if there is a possibility the first call to
+dnl PKG_CHECK_MODULES might not happen, you should be sure to include an
+dnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
+AC_DEFUN([PKG_CHECK_MODULES],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
+AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
+
+pkg_failed=no
+AC_MSG_CHECKING([for $1])
+
+_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
+_PKG_CONFIG([$1][_LIBS], [libs], [$2])
+
+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.])
+
+if test $pkg_failed = yes; then
+	AC_MSG_RESULT([no])
+        _PKG_SHORT_ERRORS_SUPPORTED
+        if test $_pkg_short_errors_supported = yes; then
+	        $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
+        else
+	        $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
+        fi
+	# Put the nasty error message in config.log where it belongs
+	echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
+
+	m4_default([$4], [AC_MSG_ERROR(
+[Package requirements ($2) were not met:
+
+$$1_PKG_ERRORS
+
+Consider adjusting the PKG_CONFIG_PATH environment variable if you
+installed software in a non-standard prefix.
+
+_PKG_TEXT])[]dnl
+        ])
+elif test $pkg_failed = untried; then
+	AC_MSG_RESULT([no])
+	m4_default([$4], [AC_MSG_FAILURE(
+[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.
+
+_PKG_TEXT
+
+To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl
+        ])
+else
+	$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
+	$1[]_LIBS=$pkg_cv_[]$1[]_LIBS
+        AC_MSG_RESULT([yes])
+	$3
+fi[]dnl
+])dnl PKG_CHECK_MODULES
+
+
+dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
+dnl   [ACTION-IF-NOT-FOUND])
+dnl ---------------------------------------------------------------------
+dnl Since: 0.29
+dnl
+dnl Checks for existence of MODULES and gathers its build flags with
+dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags
+dnl and VARIABLE-PREFIX_LIBS from --libs.
+dnl
+dnl Note that if there is a possibility the first call to
+dnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to
+dnl include an explicit call to PKG_PROG_PKG_CONFIG in your
+dnl configure.ac.
+AC_DEFUN([PKG_CHECK_MODULES_STATIC],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+_save_PKG_CONFIG=$PKG_CONFIG
+PKG_CONFIG="$PKG_CONFIG --static"
+PKG_CHECK_MODULES($@)
+PKG_CONFIG=$_save_PKG_CONFIG[]dnl
+])dnl PKG_CHECK_MODULES_STATIC
+
+
+dnl PKG_INSTALLDIR([DIRECTORY])
+dnl -------------------------
+dnl Since: 0.27
+dnl
+dnl Substitutes the variable pkgconfigdir as the location where a module
+dnl should install pkg-config .pc files. By default the directory is
+dnl $libdir/pkgconfig, but the default can be changed by passing
+dnl DIRECTORY. The user can override through the --with-pkgconfigdir
+dnl parameter.
+AC_DEFUN([PKG_INSTALLDIR],
+[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
+m4_pushdef([pkg_description],
+    [pkg-config installation directory @<:@]pkg_default[@:>@])
+AC_ARG_WITH([pkgconfigdir],
+    [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],,
+    [with_pkgconfigdir=]pkg_default)
+AC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
+m4_popdef([pkg_default])
+m4_popdef([pkg_description])
+])dnl PKG_INSTALLDIR
+
+
+dnl PKG_NOARCH_INSTALLDIR([DIRECTORY])
+dnl --------------------------------
+dnl Since: 0.27
+dnl
+dnl Substitutes the variable noarch_pkgconfigdir as the location where a
+dnl module should install arch-independent pkg-config .pc files. By
+dnl default the directory is $datadir/pkgconfig, but the default can be
+dnl changed by passing DIRECTORY. The user can override through the
+dnl --with-noarch-pkgconfigdir parameter.
+AC_DEFUN([PKG_NOARCH_INSTALLDIR],
+[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
+m4_pushdef([pkg_description],
+    [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@])
+AC_ARG_WITH([noarch-pkgconfigdir],
+    [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],,
+    [with_noarch_pkgconfigdir=]pkg_default)
+AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
+m4_popdef([pkg_default])
+m4_popdef([pkg_description])
+])dnl PKG_NOARCH_INSTALLDIR
+
+
+dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
+dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+dnl -------------------------------------------
+dnl Since: 0.28
+dnl
+dnl Retrieves the value of the pkg-config variable for the given module.
+AC_DEFUN([PKG_CHECK_VAR],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
+
+_PKG_CONFIG([$1], [variable="][$3]["], [$2])
+AS_VAR_COPY([$1], [pkg_cv_][$1])
+
+AS_VAR_IF([$1], [""], [$5], [$4])dnl
+])dnl PKG_CHECK_VAR
+
+dnl PKG_WITH_MODULES(VARIABLE-PREFIX, MODULES,
+dnl   [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND],
+dnl   [DESCRIPTION], [DEFAULT])
+dnl ------------------------------------------
+dnl
+dnl Prepare a "--with-" configure option using the lowercase
+dnl [VARIABLE-PREFIX] name, merging the behaviour of AC_ARG_WITH and
+dnl PKG_CHECK_MODULES in a single macro.
+AC_DEFUN([PKG_WITH_MODULES],
+[
+m4_pushdef([with_arg], m4_tolower([$1]))
+
+m4_pushdef([description],
+           [m4_default([$5], [build with ]with_arg[ support])])
+
+m4_pushdef([def_arg], [m4_default([$6], [auto])])
+m4_pushdef([def_action_if_found], [AS_TR_SH([with_]with_arg)=yes])
+m4_pushdef([def_action_if_not_found], [AS_TR_SH([with_]with_arg)=no])
+
+m4_case(def_arg,
+            [yes],[m4_pushdef([with_without], [--without-]with_arg)],
+            [m4_pushdef([with_without],[--with-]with_arg)])
+
+AC_ARG_WITH(with_arg,
+     AS_HELP_STRING(with_without, description[ @<:@default=]def_arg[@:>@]),,
+    [AS_TR_SH([with_]with_arg)=def_arg])
+
+AS_CASE([$AS_TR_SH([with_]with_arg)],
+            [yes],[PKG_CHECK_MODULES([$1],[$2],$3,$4)],
+            [auto],[PKG_CHECK_MODULES([$1],[$2],
+                                        [m4_n([def_action_if_found]) $3],
+                                        [m4_n([def_action_if_not_found]) $4])])
+
+m4_popdef([with_arg])
+m4_popdef([description])
+m4_popdef([def_arg])
+
+])dnl PKG_WITH_MODULES
+
+dnl PKG_HAVE_WITH_MODULES(VARIABLE-PREFIX, MODULES,
+dnl   [DESCRIPTION], [DEFAULT])
+dnl -----------------------------------------------
+dnl
+dnl Convenience macro to trigger AM_CONDITIONAL after PKG_WITH_MODULES
+dnl check._[VARIABLE-PREFIX] is exported as make variable.
+AC_DEFUN([PKG_HAVE_WITH_MODULES],
+[
+PKG_WITH_MODULES([$1],[$2],,,[$3],[$4])
+
+AM_CONDITIONAL([HAVE_][$1],
+               [test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"])
+])dnl PKG_HAVE_WITH_MODULES
+
+dnl PKG_HAVE_DEFINE_WITH_MODULES(VARIABLE-PREFIX, MODULES,
+dnl   [DESCRIPTION], [DEFAULT])
+dnl ------------------------------------------------------
+dnl
+dnl Convenience macro to run AM_CONDITIONAL and AC_DEFINE after
+dnl PKG_WITH_MODULES check. HAVE_[VARIABLE-PREFIX] is exported as make
+dnl and preprocessor variable.
+AC_DEFUN([PKG_HAVE_DEFINE_WITH_MODULES],
+[
+PKG_HAVE_WITH_MODULES([$1],[$2],[$3],[$4])
+
+AS_IF([test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"],
+        [AC_DEFINE([HAVE_][$1], 1, [Enable ]m4_tolower([$1])[ support])])
+])dnl PKG_HAVE_DEFINE_WITH_MODULES
+
 # AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
 
 # Copyright (C) 2001-2017 Free Software Foundation, Inc.
diff --git a/gdb/configure b/gdb/configure
index b6233adccf..1000467b19 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -758,7 +758,11 @@ REPORT_BUGS_TEXI
 REPORT_BUGS_TO
 PKGVERSION
 CODESIGN_CERT
-LIBDEBUGINFOD
+DEBUGINFOD_LIBS
+DEBUGINFOD_CFLAGS
+PKG_CONFIG_LIBDIR
+PKG_CONFIG_PATH
+PKG_CONFIG
 HAVE_NATIVE_GCORE_TARGET
 TARGET_OBS
 subdirs
@@ -935,6 +939,11 @@ CCC
 CPP
 MAKEINFO
 MAKEINFOFLAGS
+PKG_CONFIG
+PKG_CONFIG_PATH
+PKG_CONFIG_LIBDIR
+DEBUGINFOD_CFLAGS
+DEBUGINFOD_LIBS
 YACC
 YFLAGS
 XMKMF'
@@ -1678,6 +1687,15 @@ Some influential environment variables:
   MAKEINFO    Parent configure detects if it is of sufficient version.
   MAKEINFOFLAGS
               Parameters for MAKEINFO.
+  PKG_CONFIG  path to pkg-config utility
+  PKG_CONFIG_PATH
+              directories to add to pkg-config's search path
+  PKG_CONFIG_LIBDIR
+              path overriding pkg-config's built-in search path
+  DEBUGINFOD_CFLAGS
+              C compiler flags for DEBUGINFOD, overriding pkg-config
+  DEBUGINFOD_LIBS
+              linker flags for DEBUGINFOD, overriding pkg-config
   YACC        The `Yet Another Compiler Compiler' implementation to use.
               Defaults to the first program found out of: `bison -y', `byacc',
               `yacc'.
@@ -2268,52 +2286,6 @@ rm -f conftest.val
 
 } # ac_fn_c_compute_int
 
-# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
-# ---------------------------------------------
-# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
-# accordingly.
-ac_fn_c_check_decl ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  as_decl_name=`echo $2|sed 's/ *(.*//'`
-  as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
-$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
-if eval \${$3+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$4
-int
-main ()
-{
-#ifndef $as_decl_name
-#ifdef __cplusplus
-  (void) $as_decl_use;
-#else
-  (void) $as_decl_name;
-#endif
-#endif
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  eval "$3=yes"
-else
-  eval "$3=no"
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-eval ac_res=\$$3
-	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-
-} # ac_fn_c_check_decl
-
 # ac_fn_c_check_func LINENO FUNC VAR
 # ----------------------------------
 # Tests whether FUNC exists, setting the cache variable VAR accordingly
@@ -2435,6 +2407,52 @@ $as_echo "$ac_res" >&6; }
 
 } # ac_fn_c_check_type
 
+# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
+# ---------------------------------------------
+# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
+# accordingly.
+ac_fn_c_check_decl ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  as_decl_name=`echo $2|sed 's/ *(.*//'`
+  as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
+$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
+if eval \${$3+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+#ifndef $as_decl_name
+#ifdef __cplusplus
+  (void) $as_decl_use;
+#else
+  (void) $as_decl_name;
+#endif
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$3=yes"
+else
+  eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_decl
+
 # ac_fn_c_check_member LINENO AGGR MEMBER VAR INCLUDES
 # ----------------------------------------------------
 # Tries to find if the field MEMBER exists in type AGGR, after including
@@ -6839,7 +6857,127 @@ esac
 
 # Handle optional debuginfod support
 
-# Enable debuginfod
+
+
+
+
+
+
+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
+	if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
+set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_PKG_CONFIG+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $PKG_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+PKG_CONFIG=$ac_cv_path_PKG_CONFIG
+if test -n "$PKG_CONFIG"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
+$as_echo "$PKG_CONFIG" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_path_PKG_CONFIG"; then
+  ac_pt_PKG_CONFIG=$PKG_CONFIG
+  # Extract the first word of "pkg-config", so it can be a program name with args.
+set dummy pkg-config; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $ac_pt_PKG_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG
+if test -n "$ac_pt_PKG_CONFIG"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5
+$as_echo "$ac_pt_PKG_CONFIG" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_pt_PKG_CONFIG" = x; then
+    PKG_CONFIG=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    PKG_CONFIG=$ac_pt_PKG_CONFIG
+  fi
+else
+  PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
+fi
+
+fi
+if test -n "$PKG_CONFIG"; then
+	_pkg_min_version=0.9.0
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5
+$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; }
+	if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+	else
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+		PKG_CONFIG=""
+	fi
+fi
+
+# Handle optional debuginfod support
 
 # Check whether --with-debuginfod was given.
 if test "${with_debuginfod+set}" = set; then :
@@ -6853,72 +6991,93 @@ $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; }
 
-if test "${with_debuginfod}" = no; then
-  { $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;}
-else
-  { $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.  */
+if test "x$with_debuginfod" != xno; then
 
-/* 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
+pkg_failed=no
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for DEBUGINFOD" >&5
+$as_echo_n "checking for DEBUGINFOD... " >&6; }
+
+if test -n "$DEBUGINFOD_CFLAGS"; then
+    pkg_cv_DEBUGINFOD_CFLAGS="$DEBUGINFOD_CFLAGS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libdebuginfod >= 0.179\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "libdebuginfod >= 0.179") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_DEBUGINFOD_CFLAGS=`$PKG_CONFIG --cflags "libdebuginfod >= 0.179" 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes
 else
-  ac_cv_lib_debuginfod_debuginfod_begin=no
+  pkg_failed=yes
 fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
+ else
+    pkg_failed=untried
 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_debuginfod_lib=yes
+if test -n "$DEBUGINFOD_LIBS"; then
+    pkg_cv_DEBUGINFOD_LIBS="$DEBUGINFOD_LIBS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libdebuginfod >= 0.179\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "libdebuginfod >= 0.179") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_DEBUGINFOD_LIBS=`$PKG_CONFIG --libs "libdebuginfod >= 0.179" 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes
+else
+  pkg_failed=yes
 fi
-
-  ac_fn_c_check_decl "$LINENO" "debuginfod_begin" "ac_cv_have_decl_debuginfod_begin" "#include <elfutils/debuginfod.h>
-"
-if test "x$ac_cv_have_decl_debuginfod_begin" = xyes; then :
-  have_debuginfod_h=yes
+ else
+    pkg_failed=untried
 fi
 
-  if test "x$have_debuginfod_lib" = "xyes" -a \
-          "x$have_debuginfod_h" = "xyes"; then
 
-$as_echo "#define HAVE_LIBDEBUGINFOD 1" >>confdefs.h
 
-    LIBDEBUGINFOD="-ldebuginfod"
+if test $pkg_failed = yes; then
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
 
-  else
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+        _pkg_short_errors_supported=yes
+else
+        _pkg_short_errors_supported=no
+fi
+        if test $_pkg_short_errors_supported = yes; then
+	        DEBUGINFOD_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libdebuginfod >= 0.179" 2>&1`
+        else
+	        DEBUGINFOD_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libdebuginfod >= 0.179" 2>&1`
+        fi
+	# Put the nasty error message in config.log where it belongs
+	echo "$DEBUGINFOD_PKG_ERRORS" >&5
 
-    if test "$with_debuginfod" = yes; then
-      as_fn_error $? "debuginfod is missing or unusable" "$LINENO" 5
-    else
-      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: debuginfod is missing or unusable; some features may be unavailable." >&5
-$as_echo "$as_me: WARNING: debuginfod is missing or unusable; some features may be unavailable." >&2;}
-    fi
-  fi
+	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
+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
+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 "#define HAVE_LIBDEBUGINFOD 1" >>confdefs.h
+
+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
 
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH] config/debuginfod.m4: Use PKG_CHECK_MODULES
  2020-05-05 21:23   ` Aaron Merey
@ 2020-05-08 20:56     ` Tom Tromey
  2020-07-16 22:17       ` Aaron Merey
  2020-07-16 22:37       ` Aaron Merey
  0 siblings, 2 replies; 37+ messages in thread
From: Tom Tromey @ 2020-05-08 20:56 UTC (permalink / raw)
  To: Aaron Merey via Binutils
  Cc: law, Aaron Merey, Simon Marchi, gcc-patches, gdb-patches

>>>>> "Aaron" == Aaron Merey via Binutils <binutils@sourceware.org> writes:

Aaron>         * Makefile.in: Replace LIBDEBUGINFOD with DEBUGINFOD_LIBS.
Aaron>         * aclocal.m4: Rebuild.

Instead of inlining pkg.m4 into aclocal.m4, how about making
config/pkg.m4 and then using m4_include from gdb/acinclude.m4?
That's what gdb does for other shared m4 code.

Tom

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH] config/debuginfod.m4: Use PKG_CHECK_MODULES
  2020-05-08 20:56     ` Tom Tromey
@ 2020-07-16 22:17       ` Aaron Merey
  2020-07-16 22:37       ` Aaron Merey
  1 sibling, 0 replies; 37+ messages in thread
From: Aaron Merey @ 2020-07-16 22:17 UTC (permalink / raw)
  To: tom; +Cc: binutils, gcc-patches, gdb-patches, simark, law

Hi Tom,

Sorry for the delay, I've modified the patch to include config/pkg.m4.

Aaron


Use PKG_CHECK_MODULES to set debuginfod autoconf vars. Also add
pkg.m4 to config/.

ChangeLog:

	* config/debuginfod.m4: use PKG_CHECK_MODULES.
	* config/pkg.m4: New file.
	* configure: Rebuild.
	* configure.ac: Remove AC_DEBUGINFOD.

ChangeLog/binutils:

	* Makefile.am: Replace LIBDEBUGINFOD with DEBUGINFOD_LIBS.
	* Makefile.in: Rebuild.
	* configure: Rebuild.
	* configure.ac: Include pkg.m4.
	* doc/Makefile.in: Rebuild.

ChangeLog/gdb:

	* Makefile.in: Replace LIBDEBUGINFOD with DEBUGINFOD_LIBS.
	* configure: Rebuild.
	* configure.ac: Include pkg.m4.
---
 ChangeLog                |   7 +
 binutils/ChangeLog       |   8 +
 binutils/Makefile.am     |   6 +-
 binutils/Makefile.in     |  12 +-
 binutils/configure       | 369 ++++++++++++++++++++++++++++-----------
 binutils/configure.ac    |   1 +
 binutils/doc/Makefile.in |   8 +-
 config/debuginfod.m4     |  36 ++--
 config/pkg.m4            | 275 +++++++++++++++++++++++++++++
 configure                | 139 +--------------
 configure.ac             |   4 -
 gdb/ChangeLog            |   6 +
 gdb/Makefile.in          |   2 +-
 gdb/configure            | 365 +++++++++++++++++++++++++++-----------
 gdb/configure.ac         |   3 +-
 15 files changed, 858 insertions(+), 383 deletions(-)
 create mode 100644 config/pkg.m4

diff --git a/ChangeLog b/ChangeLog
index 49e9cf6148..e3a248c5fa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2020-07-16  Aaron Merey  <amerey@redhat.com>
+
+	* config/debuginfod.m4: use PKG_CHECK_MODULES.
+	* config/pkg.m4: New file.
+	* configure: Rebuild.
+	* configure.ac: Remove AC_DEBUGINFOD.
+
 2020-07-04  Nick Clifton  <nickc@redhat.com>
 
 	Binutils 2.35 branch created.
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 708be22cfd..679b22f1f9 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,11 @@
+2020-07-16  Aaron Merey  <amerey@redhat.com>
+
+	* Makefile.am: Replace LIBDEBUGINFOD with DEBUGINFOD_LIBS.
+	* Makefile.in: Rebuild.
+	* configure: Rebuild.
+	* configure.ac: Include pkg.m4.
+	* doc/Makefile.in: Rebuild.
+
 2020-07-14  Claudiu Zissulescu  <claziss@gmail.com>
 
 	* testsuite/binutils-all/arc/double_regs.s: New test.
diff --git a/binutils/Makefile.am b/binutils/Makefile.am
index 2ee1196790..fb54653fd3 100644
--- a/binutils/Makefile.am
+++ b/binutils/Makefile.am
@@ -53,7 +53,7 @@ AM_CFLAGS = $(WARN_CFLAGS) $(ZLIBINC)
 AM_CFLAGS_FOR_BUILD = $(WARN_CFLAGS_FOR_BUILD) $(ZLIBINC)
 LIBICONV = @LIBICONV@
 
-LIBDEBUGINFOD = @LIBDEBUGINFOD@
+DEBUGINFOD_LIBS = @DEBUGINFOD_LIBS@
 
 # these two are almost the same program
 AR_PROG=ar
@@ -252,7 +252,7 @@ objcopy_SOURCES = objcopy.c not-strip.c rename.c $(WRITE_DEBUG_SRCS) $(BULIBS)
 strings_SOURCES = strings.c $(BULIBS)
 
 readelf_SOURCES = readelf.c version.c unwind-ia64.c dwarf.c $(ELFLIBS)
-readelf_LDADD   = $(LIBINTL) $(LIBCTF_NOBFD) $(LIBIBERTY) $(ZLIB) $(LIBDEBUGINFOD)
+readelf_LDADD   = $(LIBINTL) $(LIBCTF_NOBFD) $(LIBIBERTY) $(ZLIB) $(DEBUGINFOD_LIBS)
 
 elfedit_SOURCES = elfedit.c version.c $(ELFLIBS)
 elfedit_LDADD = $(LIBINTL) $(LIBIBERTY)
@@ -263,7 +263,7 @@ nm_new_SOURCES = nm.c $(BULIBS)
 
 objdump_SOURCES = objdump.c dwarf.c prdbg.c $(DEBUG_SRCS) $(BULIBS) $(ELFLIBS)
 EXTRA_objdump_SOURCES = od-xcoff.c
-objdump_LDADD = $(OBJDUMP_PRIVATE_OFILES) $(OPCODES) $(LIBCTF) $(BFDLIB) $(LIBIBERTY) $(LIBINTL) $(LIBDEBUGINFOD)
+objdump_LDADD = $(OBJDUMP_PRIVATE_OFILES) $(OPCODES) $(LIBCTF) $(BFDLIB) $(LIBIBERTY) $(LIBINTL) $(DEBUGINFOD_LIBS)
 
 objdump.@OBJEXT@:objdump.c
 if am__fastdepCC
diff --git a/binutils/Makefile.in b/binutils/Makefile.in
index 7ef2af4aff..951dd2c6d0 100644
--- a/binutils/Makefile.in
+++ b/binutils/Makefile.in
@@ -139,7 +139,7 @@ am__aclocal_m4_deps = $(top_srcdir)/../bfd/acinclude.m4 \
 	$(top_srcdir)/../config/zlib.m4 $(top_srcdir)/../libtool.m4 \
 	$(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \
 	$(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \
-	$(top_srcdir)/../bfd/version.m4 \
+	$(top_srcdir)/../bfd/version.m4 $(top_srcdir)/../config/pkg.m4 \
 	$(top_srcdir)/../config/debuginfod.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
@@ -423,6 +423,8 @@ CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DATADIRNAME = @DATADIRNAME@
+DEBUGINFOD_CFLAGS = @DEBUGINFOD_CFLAGS@
+DEBUGINFOD_LIBS = @DEBUGINFOD_LIBS@
 DEFS = @DEFS@
 DEMANGLER_NAME = @DEMANGLER_NAME@
 DEPDIR = @DEPDIR@
@@ -454,7 +456,6 @@ LDFLAGS = @LDFLAGS@
 LEX = `if [ -f ../flex/flex ]; then echo ../flex/flex; else echo @LEX@; fi`
 LEXLIB = @LEXLIB@
 LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
-LIBDEBUGINFOD = @LIBDEBUGINFOD@
 LIBICONV = @LIBICONV@
 LIBINTL = @LIBINTL@
 LIBINTL_DEP = @LIBINTL_DEP@
@@ -490,6 +491,9 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
+PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
 POSUB = @POSUB@
 RANLIB = @RANLIB@
 SED = @SED@
@@ -714,14 +718,14 @@ size_SOURCES = size.c $(BULIBS)
 objcopy_SOURCES = objcopy.c not-strip.c rename.c $(WRITE_DEBUG_SRCS) $(BULIBS)
 strings_SOURCES = strings.c $(BULIBS)
 readelf_SOURCES = readelf.c version.c unwind-ia64.c dwarf.c $(ELFLIBS)
-readelf_LDADD = $(LIBINTL) $(LIBCTF_NOBFD) $(LIBIBERTY) $(ZLIB) $(LIBDEBUGINFOD)
+readelf_LDADD = $(LIBINTL) $(LIBCTF_NOBFD) $(LIBIBERTY) $(ZLIB) $(DEBUGINFOD_LIBS)
 elfedit_SOURCES = elfedit.c version.c $(ELFLIBS)
 elfedit_LDADD = $(LIBINTL) $(LIBIBERTY)
 strip_new_SOURCES = objcopy.c is-strip.c rename.c $(WRITE_DEBUG_SRCS) $(BULIBS)
 nm_new_SOURCES = nm.c $(BULIBS)
 objdump_SOURCES = objdump.c dwarf.c prdbg.c $(DEBUG_SRCS) $(BULIBS) $(ELFLIBS)
 EXTRA_objdump_SOURCES = od-xcoff.c
-objdump_LDADD = $(OBJDUMP_PRIVATE_OFILES) $(OPCODES) $(LIBCTF) $(BFDLIB) $(LIBIBERTY) $(LIBINTL) $(LIBDEBUGINFOD)
+objdump_LDADD = $(OBJDUMP_PRIVATE_OFILES) $(OPCODES) $(LIBCTF) $(BFDLIB) $(LIBIBERTY) $(LIBINTL) $(DEBUGINFOD_LIBS)
 cxxfilt_SOURCES = cxxfilt.c $(BULIBS)
 ar_SOURCES = arparse.y arlex.l ar.c not-ranlib.c arsup.c rename.c binemul.c \
 	emul_$(EMULATION).c $(BULIBS)
diff --git a/binutils/configure b/binutils/configure
index da7da53f1d..c9fc5108e0 100755
--- a/binutils/configure
+++ b/binutils/configure
@@ -686,7 +686,11 @@ WARN_CFLAGS_FOR_BUILD
 WARN_CFLAGS
 ENABLE_LIBCTF_FALSE
 ENABLE_LIBCTF_TRUE
-LIBDEBUGINFOD
+DEBUGINFOD_LIBS
+DEBUGINFOD_CFLAGS
+PKG_CONFIG_LIBDIR
+PKG_CONFIG_PATH
+PKG_CONFIG
 OTOOL64
 OTOOL
 LIPO
@@ -836,6 +840,11 @@ LDFLAGS
 LIBS
 CPPFLAGS
 CPP
+PKG_CONFIG
+PKG_CONFIG_PATH
+PKG_CONFIG_LIBDIR
+DEBUGINFOD_CFLAGS
+DEBUGINFOD_LIBS
 YACC
 YFLAGS'
 
@@ -1507,6 +1516,15 @@ Some influential environment variables:
   CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
               you have headers in a nonstandard directory <include dir>
   CPP         C preprocessor
+  PKG_CONFIG  path to pkg-config utility
+  PKG_CONFIG_PATH
+              directories to add to pkg-config's search path
+  PKG_CONFIG_LIBDIR
+              path overriding pkg-config's built-in search path
+  DEBUGINFOD_CFLAGS
+              C compiler flags for DEBUGINFOD, overriding pkg-config
+  DEBUGINFOD_LIBS
+              linker flags for DEBUGINFOD, overriding pkg-config
   YACC        The `Yet Another Compiler Compiler' implementation to use.
               Defaults to the first program found out of: `bison -y', `byacc',
               `yacc'.
@@ -1942,52 +1960,6 @@ $as_echo "$ac_res" >&6; }
 
 } # ac_fn_c_check_func
 
-# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
-# ---------------------------------------------
-# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
-# accordingly.
-ac_fn_c_check_decl ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  as_decl_name=`echo $2|sed 's/ *(.*//'`
-  as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
-$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
-if eval \${$3+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$4
-int
-main ()
-{
-#ifndef $as_decl_name
-#ifdef __cplusplus
-  (void) $as_decl_use;
-#else
-  (void) $as_decl_name;
-#endif
-#endif
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  eval "$3=yes"
-else
-  eval "$3=no"
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-eval ac_res=\$$3
-	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-
-} # ac_fn_c_check_decl
-
 # ac_fn_c_compute_int LINENO EXPR VAR INCLUDES
 # --------------------------------------------
 # Tries to find the compile-time value of EXPR in a program that includes
@@ -2224,6 +2196,52 @@ $as_echo "$ac_res" >&6; }
   eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
 
 } # ac_fn_c_check_type
+
+# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
+# ---------------------------------------------
+# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
+# accordingly.
+ac_fn_c_check_decl ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  as_decl_name=`echo $2|sed 's/ *(.*//'`
+  as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
+$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
+if eval \${$3+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+#ifndef $as_decl_name
+#ifdef __cplusplus
+  (void) $as_decl_use;
+#else
+  (void) $as_decl_name;
+#endif
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$3=yes"
+else
+  eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_decl
 cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
@@ -11533,7 +11551,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11536 "configure"
+#line 11554 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11639,7 +11657,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11642 "configure"
+#line 11660 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12246,7 +12264,127 @@ fi
 
 
 
-# Enable debuginfod
+
+
+
+
+
+
+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
+	if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
+set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_PKG_CONFIG+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $PKG_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+PKG_CONFIG=$ac_cv_path_PKG_CONFIG
+if test -n "$PKG_CONFIG"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
+$as_echo "$PKG_CONFIG" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_path_PKG_CONFIG"; then
+  ac_pt_PKG_CONFIG=$PKG_CONFIG
+  # Extract the first word of "pkg-config", so it can be a program name with args.
+set dummy pkg-config; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $ac_pt_PKG_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG
+if test -n "$ac_pt_PKG_CONFIG"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5
+$as_echo "$ac_pt_PKG_CONFIG" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_pt_PKG_CONFIG" = x; then
+    PKG_CONFIG=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    PKG_CONFIG=$ac_pt_PKG_CONFIG
+  fi
+else
+  PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
+fi
+
+fi
+if test -n "$PKG_CONFIG"; then
+	_pkg_min_version=0.9.0
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5
+$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; }
+	if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+	else
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+		PKG_CONFIG=""
+	fi
+fi
+
+# Handle optional debuginfod support
 
 # Check whether --with-debuginfod was given.
 if test "${with_debuginfod+set}" = set; then :
@@ -12260,72 +12398,93 @@ $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; }
 
-if test "${with_debuginfod}" = no; then
-  { $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;}
-else
-  { $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.  */
+if test "x$with_debuginfod" != xno; then
 
-/* 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
+pkg_failed=no
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libdebuginfod >= 0.179" >&5
+$as_echo_n "checking for libdebuginfod >= 0.179... " >&6; }
+
+if test -n "$DEBUGINFOD_CFLAGS"; then
+    pkg_cv_DEBUGINFOD_CFLAGS="$DEBUGINFOD_CFLAGS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libdebuginfod >= 0.179\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "libdebuginfod >= 0.179") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_DEBUGINFOD_CFLAGS=`$PKG_CONFIG --cflags "libdebuginfod >= 0.179" 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes
 else
-  ac_cv_lib_debuginfod_debuginfod_begin=no
+  pkg_failed=yes
 fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
+ else
+    pkg_failed=untried
+fi
+if test -n "$DEBUGINFOD_LIBS"; then
+    pkg_cv_DEBUGINFOD_LIBS="$DEBUGINFOD_LIBS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libdebuginfod >= 0.179\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "libdebuginfod >= 0.179") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_DEBUGINFOD_LIBS=`$PKG_CONFIG --libs "libdebuginfod >= 0.179" 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes
+else
+  pkg_failed=yes
 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_debuginfod_lib=yes
+ else
+    pkg_failed=untried
 fi
 
-  ac_fn_c_check_decl "$LINENO" "debuginfod_begin" "ac_cv_have_decl_debuginfod_begin" "#include <elfutils/debuginfod.h>
-"
-if test "x$ac_cv_have_decl_debuginfod_begin" = xyes; then :
-  have_debuginfod_h=yes
-fi
 
-  if test "x$have_debuginfod_lib" = "xyes" -a \
-          "x$have_debuginfod_h" = "xyes"; then
 
-$as_echo "#define HAVE_LIBDEBUGINFOD 1" >>confdefs.h
+if test $pkg_failed = yes; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
 
-    LIBDEBUGINFOD="-ldebuginfod"
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+        _pkg_short_errors_supported=yes
+else
+        _pkg_short_errors_supported=no
+fi
+        if test $_pkg_short_errors_supported = yes; then
+	        DEBUGINFOD_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libdebuginfod >= 0.179" 2>&1`
+        else
+	        DEBUGINFOD_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libdebuginfod >= 0.179" 2>&1`
+        fi
+	# Put the nasty error message in config.log where it belongs
+	echo "$DEBUGINFOD_PKG_ERRORS" >&5
 
-  else
+	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
+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
+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; }
 
-    if test "$with_debuginfod" = yes; then
-      as_fn_error $? "debuginfod is missing or unusable" "$LINENO" 5
-    else
-      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: debuginfod is missing or unusable; some features may be unavailable." >&5
-$as_echo "$as_me: WARNING: debuginfod is missing or unusable; some features may be unavailable." >&2;}
-    fi
-  fi
+$as_echo "#define HAVE_LIBDEBUGINFOD 1" >>confdefs.h
+
+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
 
 
diff --git a/binutils/configure.ac b/binutils/configure.ac
index 883f3187e7..3c29df0b66 100644
--- a/binutils/configure.ac
+++ b/binutils/configure.ac
@@ -18,6 +18,7 @@ dnl <http://www.gnu.org/licenses/>.
 dnl
 
 m4_include([../bfd/version.m4])
+m4_include([../config/pkg.m4])
 m4_include([../config/debuginfod.m4])
 AC_INIT([binutils], BFD_VERSION)
 AC_CONFIG_SRCDIR(ar.c)
diff --git a/binutils/doc/Makefile.in b/binutils/doc/Makefile.in
index e925b81e0d..27adfe753b 100644
--- a/binutils/doc/Makefile.in
+++ b/binutils/doc/Makefile.in
@@ -128,7 +128,7 @@ am__aclocal_m4_deps = $(top_srcdir)/../bfd/acinclude.m4 \
 	$(top_srcdir)/../config/zlib.m4 $(top_srcdir)/../libtool.m4 \
 	$(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \
 	$(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \
-	$(top_srcdir)/../bfd/version.m4 \
+	$(top_srcdir)/../bfd/version.m4 $(top_srcdir)/../config/pkg.m4 \
 	$(top_srcdir)/../config/debuginfod.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
@@ -256,6 +256,8 @@ CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DATADIRNAME = @DATADIRNAME@
+DEBUGINFOD_CFLAGS = @DEBUGINFOD_CFLAGS@
+DEBUGINFOD_LIBS = @DEBUGINFOD_LIBS@
 DEFS = @DEFS@
 DEMANGLER_NAME = @DEMANGLER_NAME@
 DEPDIR = @DEPDIR@
@@ -287,7 +289,6 @@ LDFLAGS = @LDFLAGS@
 LEX = @LEX@
 LEXLIB = @LEXLIB@
 LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
-LIBDEBUGINFOD = @LIBDEBUGINFOD@
 LIBICONV = @LIBICONV@
 LIBINTL = @LIBINTL@
 LIBINTL_DEP = @LIBINTL_DEP@
@@ -321,6 +322,9 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
+PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
 POSUB = @POSUB@
 RANLIB = @RANLIB@
 SED = @SED@
diff --git a/config/debuginfod.m4 b/config/debuginfod.m4
index 9979abe89d..2c1bfbdb54 100644
--- a/config/debuginfod.m4
+++ b/config/debuginfod.m4
@@ -1,4 +1,4 @@
-dnl Copyright (C) 1997-2019 Free Software Foundation, Inc.
+dnl Copyright (C) 1997-2020 Free Software Foundation, Inc.
 dnl This file is free software, distributed under the terms of the GNU
 dnl General Public License.  As a special exception to the GNU General
 dnl Public License, this file may be distributed as part of a program
@@ -7,32 +7,22 @@ dnl the same distribution terms as the rest of that program.
 
 AC_DEFUN([AC_DEBUGINFOD],
 [
-# Enable debuginfod
+# Handle optional debuginfod support
 AC_ARG_WITH([debuginfod],
-        AC_HELP_STRING([--with-debuginfod],
-                       [Enable debuginfo lookups with debuginfod (auto/yes/no)]),
-        [], [with_debuginfod=auto])
+  AC_HELP_STRING([--with-debuginfod], [Enable debuginfo lookups with debuginfod (auto/yes/no)]),
+  [], [with_debuginfod=auto])
 AC_MSG_CHECKING([whether to use debuginfod])
 AC_MSG_RESULT([$with_debuginfod])
 
-if test "${with_debuginfod}" = no; then
-  AC_MSG_WARN([debuginfod support disabled; some features may be unavailable.])
+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_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])
 else
-  AC_CHECK_LIB([debuginfod], [debuginfod_begin], [have_debuginfod_lib=yes])
-  AC_CHECK_DECL([debuginfod_begin], [have_debuginfod_h=yes], [],
-                [#include <elfutils/debuginfod.h>])
-  if test "x$have_debuginfod_lib" = "xyes" -a \
-          "x$have_debuginfod_h" = "xyes"; then
-    AC_DEFINE([HAVE_LIBDEBUGINFOD], [1],
-              [Define to 1 if debuginfod is enabled.])
-    AC_SUBST([LIBDEBUGINFOD], ["-ldebuginfod"])
-  else
-    AC_SUBST([LIBDEBUGINFOD], [])
-    if test "$with_debuginfod" = yes; then
-      AC_MSG_ERROR([debuginfod is missing or unusable])
-    else
-      AC_MSG_WARN([debuginfod is missing or unusable; some features may be unavailable.])
-    fi
-  fi
+  AC_MSG_WARN([debuginfod support disabled; some features may be unavailable.])
 fi
 ])
diff --git a/config/pkg.m4 b/config/pkg.m4
new file mode 100644
index 0000000000..13a8890178
--- /dev/null
+++ b/config/pkg.m4
@@ -0,0 +1,275 @@
+# pkg.m4 - Macros to locate and utilise pkg-config.   -*- Autoconf -*-
+# serial 12 (pkg-config-0.29.2)
+
+dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
+dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
+dnl
+dnl This program is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 2 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+dnl General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+dnl 02111-1307, USA.
+dnl
+dnl As a special exception to the GNU General Public License, if you
+dnl distribute this file as part of a program that contains a
+dnl configuration script generated by Autoconf, you may include it under
+dnl the same distribution terms that you use for the rest of that
+dnl program.
+
+dnl PKG_PREREQ(MIN-VERSION)
+dnl -----------------------
+dnl Since: 0.29
+dnl
+dnl Verify that the version of the pkg-config macros are at least
+dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's
+dnl installed version of pkg-config, this checks the developer's version
+dnl of pkg.m4 when generating configure.
+dnl
+dnl To ensure that this macro is defined, also add:
+dnl m4_ifndef([PKG_PREREQ],
+dnl     [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])])
+dnl
+dnl See the "Since" comment for each macro you use to see what version
+dnl of the macros you require.
+m4_defun([PKG_PREREQ],
+[m4_define([PKG_MACROS_VERSION], [0.29.2])
+m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
+    [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
+])dnl PKG_PREREQ
+
+dnl PKG_PROG_PKG_CONFIG([MIN-VERSION])
+dnl ----------------------------------
+dnl Since: 0.16
+dnl
+dnl Search for the pkg-config tool and set the PKG_CONFIG variable to
+dnl first found in the path. Checks that the version of pkg-config found
+dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is
+dnl used since that's the first version where most current features of
+dnl pkg-config existed.
+AC_DEFUN([PKG_PROG_PKG_CONFIG],
+[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
+m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
+m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
+AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
+AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
+AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
+
+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
+	AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
+fi
+if test -n "$PKG_CONFIG"; then
+	_pkg_min_version=m4_default([$1], [0.9.0])
+	AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
+	if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
+		AC_MSG_RESULT([yes])
+	else
+		AC_MSG_RESULT([no])
+		PKG_CONFIG=""
+	fi
+fi[]dnl
+])dnl PKG_PROG_PKG_CONFIG
+
+dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+dnl -------------------------------------------------------------------
+dnl Since: 0.18
+dnl
+dnl Check to see whether a particular set of modules exists. Similar to
+dnl PKG_CHECK_MODULES(), but does not set variables or print errors.
+dnl
+dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+dnl only at the first occurence in configure.ac, so if the first place
+dnl it's called might be skipped (such as if it is within an "if", you
+dnl have to call PKG_CHECK_EXISTS manually
+AC_DEFUN([PKG_CHECK_EXISTS],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+if test -n "$PKG_CONFIG" && \
+    AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
+  m4_default([$2], [:])
+m4_ifvaln([$3], [else
+  $3])dnl
+fi])
+
+dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
+dnl ---------------------------------------------
+dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting
+dnl pkg_failed based on the result.
+m4_define([_PKG_CONFIG],
+[if test -n "$$1"; then
+    pkg_cv_[]$1="$$1"
+ elif test -n "$PKG_CONFIG"; then
+    PKG_CHECK_EXISTS([$3],
+                     [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes ],
+		     [pkg_failed=yes])
+ else
+    pkg_failed=untried
+fi[]dnl
+])dnl _PKG_CONFIG
+
+dnl _PKG_SHORT_ERRORS_SUPPORTED
+dnl ---------------------------
+dnl Internal check to see if pkg-config supports short errors.
+AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+        _pkg_short_errors_supported=yes
+else
+        _pkg_short_errors_supported=no
+fi[]dnl
+])dnl _PKG_SHORT_ERRORS_SUPPORTED
+
+
+dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
+dnl   [ACTION-IF-NOT-FOUND])
+dnl --------------------------------------------------------------
+dnl Since: 0.4.0
+dnl
+dnl Note that if there is a possibility the first call to
+dnl PKG_CHECK_MODULES might not happen, you should be sure to include an
+dnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
+AC_DEFUN([PKG_CHECK_MODULES],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
+AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
+
+pkg_failed=no
+AC_MSG_CHECKING([for $2])
+
+_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
+_PKG_CONFIG([$1][_LIBS], [libs], [$2])
+
+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.])
+
+if test $pkg_failed = yes; then
+        AC_MSG_RESULT([no])
+        _PKG_SHORT_ERRORS_SUPPORTED
+        if test $_pkg_short_errors_supported = yes; then
+	        $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
+        else
+	        $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
+        fi
+	# Put the nasty error message in config.log where it belongs
+	echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
+
+	m4_default([$4], [AC_MSG_ERROR(
+[Package requirements ($2) were not met:
+
+$$1_PKG_ERRORS
+
+Consider adjusting the PKG_CONFIG_PATH environment variable if you
+installed software in a non-standard prefix.
+
+_PKG_TEXT])[]dnl
+        ])
+elif test $pkg_failed = untried; then
+        AC_MSG_RESULT([no])
+	m4_default([$4], [AC_MSG_FAILURE(
+[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.
+
+_PKG_TEXT
+
+To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl
+        ])
+else
+	$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
+	$1[]_LIBS=$pkg_cv_[]$1[]_LIBS
+        AC_MSG_RESULT([yes])
+	$3
+fi[]dnl
+])dnl PKG_CHECK_MODULES
+
+
+dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
+dnl   [ACTION-IF-NOT-FOUND])
+dnl ---------------------------------------------------------------------
+dnl Since: 0.29
+dnl
+dnl Checks for existence of MODULES and gathers its build flags with
+dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags
+dnl and VARIABLE-PREFIX_LIBS from --libs.
+dnl
+dnl Note that if there is a possibility the first call to
+dnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to
+dnl include an explicit call to PKG_PROG_PKG_CONFIG in your
+dnl configure.ac.
+AC_DEFUN([PKG_CHECK_MODULES_STATIC],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+_save_PKG_CONFIG=$PKG_CONFIG
+PKG_CONFIG="$PKG_CONFIG --static"
+PKG_CHECK_MODULES($@)
+PKG_CONFIG=$_save_PKG_CONFIG[]dnl
+])dnl PKG_CHECK_MODULES_STATIC
+
+
+dnl PKG_INSTALLDIR([DIRECTORY])
+dnl -------------------------
+dnl Since: 0.27
+dnl
+dnl Substitutes the variable pkgconfigdir as the location where a module
+dnl should install pkg-config .pc files. By default the directory is
+dnl $libdir/pkgconfig, but the default can be changed by passing
+dnl DIRECTORY. The user can override through the --with-pkgconfigdir
+dnl parameter.
+AC_DEFUN([PKG_INSTALLDIR],
+[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
+m4_pushdef([pkg_description],
+    [pkg-config installation directory @<:@]pkg_default[@:>@])
+AC_ARG_WITH([pkgconfigdir],
+    [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],,
+    [with_pkgconfigdir=]pkg_default)
+AC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
+m4_popdef([pkg_default])
+m4_popdef([pkg_description])
+])dnl PKG_INSTALLDIR
+
+
+dnl PKG_NOARCH_INSTALLDIR([DIRECTORY])
+dnl --------------------------------
+dnl Since: 0.27
+dnl
+dnl Substitutes the variable noarch_pkgconfigdir as the location where a
+dnl module should install arch-independent pkg-config .pc files. By
+dnl default the directory is $datadir/pkgconfig, but the default can be
+dnl changed by passing DIRECTORY. The user can override through the
+dnl --with-noarch-pkgconfigdir parameter.
+AC_DEFUN([PKG_NOARCH_INSTALLDIR],
+[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
+m4_pushdef([pkg_description],
+    [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@])
+AC_ARG_WITH([noarch-pkgconfigdir],
+    [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],,
+    [with_noarch_pkgconfigdir=]pkg_default)
+AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
+m4_popdef([pkg_default])
+m4_popdef([pkg_description])
+])dnl PKG_NOARCH_INSTALLDIR
+
+
+dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
+dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+dnl -------------------------------------------
+dnl Since: 0.28
+dnl
+dnl Retrieves the value of the pkg-config variable for the given module.
+AC_DEFUN([PKG_CHECK_VAR],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
+
+_PKG_CONFIG([$1], [variable="][$3]["], [$2])
+AS_VAR_COPY([$1], [pkg_cv_][$1])
+
+AS_VAR_IF([$1], [""], [$5], [$4])dnl
+])dnl PKG_CHECK_VAR
diff --git a/configure b/configure
index 54d0339ab9..68779feb42 100755
--- a/configure
+++ b/configure
@@ -690,7 +690,6 @@ extra_mpc_gmp_configure_flags
 extra_mpfr_configure_flags
 gmpinc
 gmplibs
-LIBDEBUGINFOD
 do_compare
 GNATMAKE
 GNATBIND
@@ -791,7 +790,6 @@ enable_libssp
 enable_libstdcxx
 enable_liboffloadmic
 enable_bootstrap
-with_debuginfod
 with_mpc
 with_mpc_include
 with_mpc_lib
@@ -1555,8 +1553,6 @@ Optional Packages:
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
   --with-build-libsubdir=DIR  Directory where to find libraries for build system
   --with-system-zlib      use installed libz
-  --with-debuginfod       Enable debuginfo lookups with debuginfod
-                          (auto/yes/no)
   --with-mpc=PATH         specify prefix directory for installed MPC package.
                           Equivalent to --with-mpc-include=PATH/include plus
                           --with-mpc-lib=PATH/lib
@@ -1925,52 +1921,6 @@ fi
   as_fn_set_status $ac_retval
 
 } # ac_fn_c_try_link
-
-# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
-# ---------------------------------------------
-# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
-# accordingly.
-ac_fn_c_check_decl ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  as_decl_name=`echo $2|sed 's/ *(.*//'`
-  as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
-$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
-if eval \${$3+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$4
-int
-main ()
-{
-#ifndef $as_decl_name
-#ifdef __cplusplus
-  (void) $as_decl_use;
-#else
-  (void) $as_decl_name;
-#endif
-#endif
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  eval "$3=yes"
-else
-  eval "$3=no"
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-eval ac_res=\$$3
-	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-
-} # ac_fn_c_check_decl
 cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
@@ -5505,92 +5455,6 @@ gmplibs="-lmpc -lmpfr -lgmp"
 gmpinc=
 have_gmp=no
 
-# Check for debuginfod
-
-
-# Enable debuginfod
-
-# Check whether --with-debuginfod was given.
-if test "${with_debuginfod+set}" = set; then :
-  withval=$with_debuginfod;
-else
-  with_debuginfod=auto
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use debuginfod" >&5
-$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; }
-
-if test "${with_debuginfod}" = no; then
-  { $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;}
-else
-  { $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.  */
-
-/* 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_debuginfod_lib=yes
-fi
-
-  ac_fn_c_check_decl "$LINENO" "debuginfod_begin" "ac_cv_have_decl_debuginfod_begin" "#include <elfutils/debuginfod.h>
-"
-if test "x$ac_cv_have_decl_debuginfod_begin" = xyes; then :
-  have_debuginfod_h=yes
-fi
-
-  if test "x$have_debuginfod_lib" = "xyes" -a \
-          "x$have_debuginfod_h" = "xyes"; then
-
-$as_echo "#define HAVE_LIBDEBUGINFOD 1" >>confdefs.h
-
-    LIBDEBUGINFOD="-ldebuginfod"
-
-  else
-
-    if test "$with_debuginfod" = yes; then
-      as_fn_error $? "debuginfod is missing or unusable" "$LINENO" 5
-    else
-      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: debuginfod is missing or unusable; some features may be unavailable." >&5
-$as_echo "$as_me: WARNING: debuginfod is missing or unusable; some features may be unavailable." >&2;}
-    fi
-  fi
-fi
-
-
 # Specify a location for mpc
 # check for this first so it ends up on the link line before mpfr.
 
@@ -5745,7 +5609,8 @@ if test -d ${srcdir}/gcc && test "x$have_gmp" = xno; then
   # Check for the recommended and required versions of GMP.
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the correct version of gmp.h" >&5
 $as_echo_n "checking for the correct version of gmp.h... " >&6; }
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include "gmp.h"
 int
diff --git a/configure.ac b/configure.ac
index a910c4fd6b..d16a275768 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,7 +23,6 @@ m4_include(config/acx.m4)
 m4_include(config/override.m4)
 m4_include(config/proginstall.m4)
 m4_include(config/elf.m4)
-m4_include(config/debuginfod.m4)
 m4_include([libtool.m4])
 m4_include([ltoptions.m4])
 m4_include([ltsugar.m4])
@@ -1383,9 +1382,6 @@ gmplibs="-lmpc -lmpfr -lgmp"
 gmpinc=
 have_gmp=no
 
-# Check for debuginfod
-AC_DEBUGINFOD
-
 # Specify a location for mpc
 # check for this first so it ends up on the link line before mpfr.
 AC_ARG_WITH(mpc,
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index f30edafdf9..eef4e0df77 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2020-07-16  Aaron Merey  <amerey@redhat.com>
+
+	* Makefile.in: Replace LIBDEBUGINFOD with DEBUGINFOD_LIBS.
+	* configure: Rebuild.
+	* configure.ac: Include pkg.m4.
+
 2020-07-15  Andrew Burgess  <andrew.burgess@embecosm.com>
 
 	* f-typeprint.c (f_type_print_base): Allow for dynamic types not
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 9d48445739..f9bde2b9a9 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -623,7 +623,7 @@ CLIBS = $(SIM) $(READLINE) $(OPCODES) $(LIBCTF) $(BFD) $(ZLIB) \
 	$(LIBEXPAT) $(LIBLZMA) $(LIBBABELTRACE) $(LIBIPT) \
 	$(WIN32LIBS) $(LIBGNU) $(LIBICONV) \
 	$(LIBMPFR) $(SRCHIGH_LIBS) $(LIBXXHASH) $(PTHREAD_LIBS) \
-	@LIBDEBUGINFOD@
+	@DEBUGINFOD_LIBS@
 CDEPS = $(NAT_CDEPS) $(SIM) $(BFD) $(READLINE_DEPS) $(CTF_DEPS) \
 	$(OPCODES) $(INTL_DEPS) $(LIBIBERTY) $(CONFIG_DEPS) $(LIBGNU) \
 	$(LIBSUPPORT)
diff --git a/gdb/configure b/gdb/configure
index e8bfdbc709..a83165e729 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -761,7 +761,11 @@ REPORT_BUGS_TEXI
 REPORT_BUGS_TO
 PKGVERSION
 CODESIGN_CERT
-LIBDEBUGINFOD
+DEBUGINFOD_LIBS
+DEBUGINFOD_CFLAGS
+PKG_CONFIG_LIBDIR
+PKG_CONFIG_PATH
+PKG_CONFIG
 HAVE_NATIVE_GCORE_TARGET
 TARGET_OBS
 subdirs
@@ -939,6 +943,11 @@ CCC
 CPP
 MAKEINFO
 MAKEINFOFLAGS
+PKG_CONFIG
+PKG_CONFIG_PATH
+PKG_CONFIG_LIBDIR
+DEBUGINFOD_CFLAGS
+DEBUGINFOD_LIBS
 YACC
 YFLAGS
 XMKMF'
@@ -1683,6 +1692,15 @@ Some influential environment variables:
   MAKEINFO    Parent configure detects if it is of sufficient version.
   MAKEINFOFLAGS
               Parameters for MAKEINFO.
+  PKG_CONFIG  path to pkg-config utility
+  PKG_CONFIG_PATH
+              directories to add to pkg-config's search path
+  PKG_CONFIG_LIBDIR
+              path overriding pkg-config's built-in search path
+  DEBUGINFOD_CFLAGS
+              C compiler flags for DEBUGINFOD, overriding pkg-config
+  DEBUGINFOD_LIBS
+              linker flags for DEBUGINFOD, overriding pkg-config
   YACC        The `Yet Another Compiler Compiler' implementation to use.
               Defaults to the first program found out of: `bison -y', `byacc',
               `yacc'.
@@ -2273,52 +2291,6 @@ rm -f conftest.val
 
 } # ac_fn_c_compute_int
 
-# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
-# ---------------------------------------------
-# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
-# accordingly.
-ac_fn_c_check_decl ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  as_decl_name=`echo $2|sed 's/ *(.*//'`
-  as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
-$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
-if eval \${$3+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$4
-int
-main ()
-{
-#ifndef $as_decl_name
-#ifdef __cplusplus
-  (void) $as_decl_use;
-#else
-  (void) $as_decl_name;
-#endif
-#endif
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  eval "$3=yes"
-else
-  eval "$3=no"
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-eval ac_res=\$$3
-	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-
-} # ac_fn_c_check_decl
-
 # ac_fn_c_check_func LINENO FUNC VAR
 # ----------------------------------
 # Tests whether FUNC exists, setting the cache variable VAR accordingly
@@ -2440,6 +2412,52 @@ $as_echo "$ac_res" >&6; }
 
 } # ac_fn_c_check_type
 
+# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
+# ---------------------------------------------
+# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
+# accordingly.
+ac_fn_c_check_decl ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  as_decl_name=`echo $2|sed 's/ *(.*//'`
+  as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
+$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
+if eval \${$3+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+#ifndef $as_decl_name
+#ifdef __cplusplus
+  (void) $as_decl_use;
+#else
+  (void) $as_decl_name;
+#endif
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$3=yes"
+else
+  eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_decl
+
 # ac_fn_c_check_member LINENO AGGR MEMBER VAR INCLUDES
 # ----------------------------------------------------
 # Tries to find if the field MEMBER exists in type AGGR, after including
@@ -6844,7 +6862,127 @@ esac
 
 # Handle optional debuginfod support
 
-# Enable debuginfod
+
+
+
+
+
+
+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
+	if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
+set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_PKG_CONFIG+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $PKG_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+PKG_CONFIG=$ac_cv_path_PKG_CONFIG
+if test -n "$PKG_CONFIG"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
+$as_echo "$PKG_CONFIG" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_path_PKG_CONFIG"; then
+  ac_pt_PKG_CONFIG=$PKG_CONFIG
+  # Extract the first word of "pkg-config", so it can be a program name with args.
+set dummy pkg-config; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $ac_pt_PKG_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG
+if test -n "$ac_pt_PKG_CONFIG"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5
+$as_echo "$ac_pt_PKG_CONFIG" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_pt_PKG_CONFIG" = x; then
+    PKG_CONFIG=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    PKG_CONFIG=$ac_pt_PKG_CONFIG
+  fi
+else
+  PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
+fi
+
+fi
+if test -n "$PKG_CONFIG"; then
+	_pkg_min_version=0.9.0
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5
+$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; }
+	if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+	else
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+		PKG_CONFIG=""
+	fi
+fi
+
+# Handle optional debuginfod support
 
 # Check whether --with-debuginfod was given.
 if test "${with_debuginfod+set}" = set; then :
@@ -6858,72 +6996,93 @@ $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; }
 
-if test "${with_debuginfod}" = no; then
-  { $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;}
-else
-  { $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.  */
+if test "x$with_debuginfod" != xno; then
 
-/* 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
+pkg_failed=no
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libdebuginfod >= 0.179" >&5
+$as_echo_n "checking for libdebuginfod >= 0.179... " >&6; }
+
+if test -n "$DEBUGINFOD_CFLAGS"; then
+    pkg_cv_DEBUGINFOD_CFLAGS="$DEBUGINFOD_CFLAGS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libdebuginfod >= 0.179\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "libdebuginfod >= 0.179") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_DEBUGINFOD_CFLAGS=`$PKG_CONFIG --cflags "libdebuginfod >= 0.179" 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes
 else
-  ac_cv_lib_debuginfod_debuginfod_begin=no
+  pkg_failed=yes
 fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
+ else
+    pkg_failed=untried
 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_debuginfod_lib=yes
+if test -n "$DEBUGINFOD_LIBS"; then
+    pkg_cv_DEBUGINFOD_LIBS="$DEBUGINFOD_LIBS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libdebuginfod >= 0.179\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "libdebuginfod >= 0.179") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_DEBUGINFOD_LIBS=`$PKG_CONFIG --libs "libdebuginfod >= 0.179" 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes
+else
+  pkg_failed=yes
 fi
-
-  ac_fn_c_check_decl "$LINENO" "debuginfod_begin" "ac_cv_have_decl_debuginfod_begin" "#include <elfutils/debuginfod.h>
-"
-if test "x$ac_cv_have_decl_debuginfod_begin" = xyes; then :
-  have_debuginfod_h=yes
+ else
+    pkg_failed=untried
 fi
 
-  if test "x$have_debuginfod_lib" = "xyes" -a \
-          "x$have_debuginfod_h" = "xyes"; then
 
-$as_echo "#define HAVE_LIBDEBUGINFOD 1" >>confdefs.h
 
-    LIBDEBUGINFOD="-ldebuginfod"
+if test $pkg_failed = yes; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
 
-  else
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+        _pkg_short_errors_supported=yes
+else
+        _pkg_short_errors_supported=no
+fi
+        if test $_pkg_short_errors_supported = yes; then
+	        DEBUGINFOD_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libdebuginfod >= 0.179" 2>&1`
+        else
+	        DEBUGINFOD_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libdebuginfod >= 0.179" 2>&1`
+        fi
+	# Put the nasty error message in config.log where it belongs
+	echo "$DEBUGINFOD_PKG_ERRORS" >&5
 
-    if test "$with_debuginfod" = yes; then
-      as_fn_error $? "debuginfod is missing or unusable" "$LINENO" 5
-    else
-      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: debuginfod is missing or unusable; some features may be unavailable." >&5
-$as_echo "$as_me: WARNING: debuginfod is missing or unusable; some features may be unavailable." >&2;}
-    fi
-  fi
+	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
+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
+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 "#define HAVE_LIBDEBUGINFOD 1" >>confdefs.h
+
+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
 
 
diff --git a/gdb/configure.ac b/gdb/configure.ac
index b975cec84f..eacd9b019f 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -18,7 +18,8 @@ dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 dnl Process this file with autoconf to produce a configure script.
 
-m4_include(../config/debuginfod.m4)
+m4_include([../config/pkg.m4])
+m4_include([../config/debuginfod.m4])
 
 AC_INIT(main.c)
 AC_CONFIG_HEADERS(config.h:config.in, [echo > stamp-h])
-- 
2.25.4


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH] config/debuginfod.m4: Use PKG_CHECK_MODULES
  2020-05-08 20:56     ` Tom Tromey
  2020-07-16 22:17       ` Aaron Merey
@ 2020-07-16 22:37       ` Aaron Merey
  2020-07-19 15:43         ` Simon Marchi
  1 sibling, 1 reply; 37+ messages in thread
From: Aaron Merey @ 2020-07-16 22:37 UTC (permalink / raw)
  To: Tom Tromey
  Cc: Aaron Merey via Binutils, Jeff Law, Simon Marchi, gcc-patches,
	gdb-patches

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

On Fri, May 8, 2020 at 4:56 PM Tom Tromey <tom@tromey.com> wrote:
>
> >>>>> "Aaron" == Aaron Merey via Binutils <binutils@sourceware.org> writes:
>
> Aaron>         * Makefile.in: Replace LIBDEBUGINFOD with DEBUGINFOD_LIBS.
> Aaron>         * aclocal.m4: Rebuild.
>
> Instead of inlining pkg.m4 into aclocal.m4, how about making
> config/pkg.m4 and then using m4_include from gdb/acinclude.m4?
> That's what gdb does for other shared m4 code.

Resending the patch for this since my last attempt didn't seem to
properly reply to
Tom's email.

[-- Attachment #2: 0001-config-debuginfod.m4-Use-PKG_CHECK_MODULES.patch --]
[-- Type: text/x-patch, Size: 57926 bytes --]

From 7a7ea339a9f1ba879eb0f29ab68cbcb715d11391 Mon Sep 17 00:00:00 2001
From: Aaron Merey <amerey@redhat.com>
Date: Thu, 16 Jul 2020 16:02:43 -0400
Subject: [PATCH] config/debuginfod.m4: Use PKG_CHECK_MODULES

Use PKG_CHECK_MODULES to set debuginfod autoconf vars. Also add
pkg.m4 to config/.

ChangeLog:

	* config/debuginfod.m4: use PKG_CHECK_MODULES.
	* config/pkg.m4: New file.
	* configure: Rebuild.
	* configure.ac: Remove AC_DEBUGINFOD.

ChangeLog/binutils:

	* Makefile.am: Replace LIBDEBUGINFOD with DEBUGINFOD_LIBS.
	* Makefile.in: Rebuild.
	* configure: Rebuild.
	* configure.ac: Include pkg.m4.
	* doc/Makefile.in: Rebuild.

ChangeLog/gdb:

	* Makefile.in: Replace LIBDEBUGINFOD with DEBUGINFOD_LIBS.
	* configure: Rebuild.
	* configure.ac: Include pkg.m4.
---
 ChangeLog                |   7 +
 binutils/ChangeLog       |   8 +
 binutils/Makefile.am     |   6 +-
 binutils/Makefile.in     |  12 +-
 binutils/configure       | 369 ++++++++++++++++++++++++++++-----------
 binutils/configure.ac    |   1 +
 binutils/doc/Makefile.in |   8 +-
 config/debuginfod.m4     |  36 ++--
 config/pkg.m4            | 275 +++++++++++++++++++++++++++++
 configure                | 139 +--------------
 configure.ac             |   4 -
 gdb/ChangeLog            |   6 +
 gdb/Makefile.in          |   2 +-
 gdb/configure            | 365 +++++++++++++++++++++++++++-----------
 gdb/configure.ac         |   3 +-
 15 files changed, 858 insertions(+), 383 deletions(-)
 create mode 100644 config/pkg.m4

diff --git a/ChangeLog b/ChangeLog
index 49e9cf6148..e3a248c5fa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2020-07-16  Aaron Merey  <amerey@redhat.com>
+
+	* config/debuginfod.m4: use PKG_CHECK_MODULES.
+	* config/pkg.m4: New file.
+	* configure: Rebuild.
+	* configure.ac: Remove AC_DEBUGINFOD.
+
 2020-07-04  Nick Clifton  <nickc@redhat.com>
 
 	Binutils 2.35 branch created.
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 708be22cfd..679b22f1f9 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,11 @@
+2020-07-16  Aaron Merey  <amerey@redhat.com>
+
+	* Makefile.am: Replace LIBDEBUGINFOD with DEBUGINFOD_LIBS.
+	* Makefile.in: Rebuild.
+	* configure: Rebuild.
+	* configure.ac: Include pkg.m4.
+	* doc/Makefile.in: Rebuild.
+
 2020-07-14  Claudiu Zissulescu  <claziss@gmail.com>
 
 	* testsuite/binutils-all/arc/double_regs.s: New test.
diff --git a/binutils/Makefile.am b/binutils/Makefile.am
index 2ee1196790..fb54653fd3 100644
--- a/binutils/Makefile.am
+++ b/binutils/Makefile.am
@@ -53,7 +53,7 @@ AM_CFLAGS = $(WARN_CFLAGS) $(ZLIBINC)
 AM_CFLAGS_FOR_BUILD = $(WARN_CFLAGS_FOR_BUILD) $(ZLIBINC)
 LIBICONV = @LIBICONV@
 
-LIBDEBUGINFOD = @LIBDEBUGINFOD@
+DEBUGINFOD_LIBS = @DEBUGINFOD_LIBS@
 
 # these two are almost the same program
 AR_PROG=ar
@@ -252,7 +252,7 @@ objcopy_SOURCES = objcopy.c not-strip.c rename.c $(WRITE_DEBUG_SRCS) $(BULIBS)
 strings_SOURCES = strings.c $(BULIBS)
 
 readelf_SOURCES = readelf.c version.c unwind-ia64.c dwarf.c $(ELFLIBS)
-readelf_LDADD   = $(LIBINTL) $(LIBCTF_NOBFD) $(LIBIBERTY) $(ZLIB) $(LIBDEBUGINFOD)
+readelf_LDADD   = $(LIBINTL) $(LIBCTF_NOBFD) $(LIBIBERTY) $(ZLIB) $(DEBUGINFOD_LIBS)
 
 elfedit_SOURCES = elfedit.c version.c $(ELFLIBS)
 elfedit_LDADD = $(LIBINTL) $(LIBIBERTY)
@@ -263,7 +263,7 @@ nm_new_SOURCES = nm.c $(BULIBS)
 
 objdump_SOURCES = objdump.c dwarf.c prdbg.c $(DEBUG_SRCS) $(BULIBS) $(ELFLIBS)
 EXTRA_objdump_SOURCES = od-xcoff.c
-objdump_LDADD = $(OBJDUMP_PRIVATE_OFILES) $(OPCODES) $(LIBCTF) $(BFDLIB) $(LIBIBERTY) $(LIBINTL) $(LIBDEBUGINFOD)
+objdump_LDADD = $(OBJDUMP_PRIVATE_OFILES) $(OPCODES) $(LIBCTF) $(BFDLIB) $(LIBIBERTY) $(LIBINTL) $(DEBUGINFOD_LIBS)
 
 objdump.@OBJEXT@:objdump.c
 if am__fastdepCC
diff --git a/binutils/Makefile.in b/binutils/Makefile.in
index 7ef2af4aff..951dd2c6d0 100644
--- a/binutils/Makefile.in
+++ b/binutils/Makefile.in
@@ -139,7 +139,7 @@ am__aclocal_m4_deps = $(top_srcdir)/../bfd/acinclude.m4 \
 	$(top_srcdir)/../config/zlib.m4 $(top_srcdir)/../libtool.m4 \
 	$(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \
 	$(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \
-	$(top_srcdir)/../bfd/version.m4 \
+	$(top_srcdir)/../bfd/version.m4 $(top_srcdir)/../config/pkg.m4 \
 	$(top_srcdir)/../config/debuginfod.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
@@ -423,6 +423,8 @@ CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DATADIRNAME = @DATADIRNAME@
+DEBUGINFOD_CFLAGS = @DEBUGINFOD_CFLAGS@
+DEBUGINFOD_LIBS = @DEBUGINFOD_LIBS@
 DEFS = @DEFS@
 DEMANGLER_NAME = @DEMANGLER_NAME@
 DEPDIR = @DEPDIR@
@@ -454,7 +456,6 @@ LDFLAGS = @LDFLAGS@
 LEX = `if [ -f ../flex/flex ]; then echo ../flex/flex; else echo @LEX@; fi`
 LEXLIB = @LEXLIB@
 LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
-LIBDEBUGINFOD = @LIBDEBUGINFOD@
 LIBICONV = @LIBICONV@
 LIBINTL = @LIBINTL@
 LIBINTL_DEP = @LIBINTL_DEP@
@@ -490,6 +491,9 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
+PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
 POSUB = @POSUB@
 RANLIB = @RANLIB@
 SED = @SED@
@@ -714,14 +718,14 @@ size_SOURCES = size.c $(BULIBS)
 objcopy_SOURCES = objcopy.c not-strip.c rename.c $(WRITE_DEBUG_SRCS) $(BULIBS)
 strings_SOURCES = strings.c $(BULIBS)
 readelf_SOURCES = readelf.c version.c unwind-ia64.c dwarf.c $(ELFLIBS)
-readelf_LDADD = $(LIBINTL) $(LIBCTF_NOBFD) $(LIBIBERTY) $(ZLIB) $(LIBDEBUGINFOD)
+readelf_LDADD = $(LIBINTL) $(LIBCTF_NOBFD) $(LIBIBERTY) $(ZLIB) $(DEBUGINFOD_LIBS)
 elfedit_SOURCES = elfedit.c version.c $(ELFLIBS)
 elfedit_LDADD = $(LIBINTL) $(LIBIBERTY)
 strip_new_SOURCES = objcopy.c is-strip.c rename.c $(WRITE_DEBUG_SRCS) $(BULIBS)
 nm_new_SOURCES = nm.c $(BULIBS)
 objdump_SOURCES = objdump.c dwarf.c prdbg.c $(DEBUG_SRCS) $(BULIBS) $(ELFLIBS)
 EXTRA_objdump_SOURCES = od-xcoff.c
-objdump_LDADD = $(OBJDUMP_PRIVATE_OFILES) $(OPCODES) $(LIBCTF) $(BFDLIB) $(LIBIBERTY) $(LIBINTL) $(LIBDEBUGINFOD)
+objdump_LDADD = $(OBJDUMP_PRIVATE_OFILES) $(OPCODES) $(LIBCTF) $(BFDLIB) $(LIBIBERTY) $(LIBINTL) $(DEBUGINFOD_LIBS)
 cxxfilt_SOURCES = cxxfilt.c $(BULIBS)
 ar_SOURCES = arparse.y arlex.l ar.c not-ranlib.c arsup.c rename.c binemul.c \
 	emul_$(EMULATION).c $(BULIBS)
diff --git a/binutils/configure b/binutils/configure
index da7da53f1d..c9fc5108e0 100755
--- a/binutils/configure
+++ b/binutils/configure
@@ -686,7 +686,11 @@ WARN_CFLAGS_FOR_BUILD
 WARN_CFLAGS
 ENABLE_LIBCTF_FALSE
 ENABLE_LIBCTF_TRUE
-LIBDEBUGINFOD
+DEBUGINFOD_LIBS
+DEBUGINFOD_CFLAGS
+PKG_CONFIG_LIBDIR
+PKG_CONFIG_PATH
+PKG_CONFIG
 OTOOL64
 OTOOL
 LIPO
@@ -836,6 +840,11 @@ LDFLAGS
 LIBS
 CPPFLAGS
 CPP
+PKG_CONFIG
+PKG_CONFIG_PATH
+PKG_CONFIG_LIBDIR
+DEBUGINFOD_CFLAGS
+DEBUGINFOD_LIBS
 YACC
 YFLAGS'
 
@@ -1507,6 +1516,15 @@ Some influential environment variables:
   CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
               you have headers in a nonstandard directory <include dir>
   CPP         C preprocessor
+  PKG_CONFIG  path to pkg-config utility
+  PKG_CONFIG_PATH
+              directories to add to pkg-config's search path
+  PKG_CONFIG_LIBDIR
+              path overriding pkg-config's built-in search path
+  DEBUGINFOD_CFLAGS
+              C compiler flags for DEBUGINFOD, overriding pkg-config
+  DEBUGINFOD_LIBS
+              linker flags for DEBUGINFOD, overriding pkg-config
   YACC        The `Yet Another Compiler Compiler' implementation to use.
               Defaults to the first program found out of: `bison -y', `byacc',
               `yacc'.
@@ -1942,52 +1960,6 @@ $as_echo "$ac_res" >&6; }
 
 } # ac_fn_c_check_func
 
-# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
-# ---------------------------------------------
-# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
-# accordingly.
-ac_fn_c_check_decl ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  as_decl_name=`echo $2|sed 's/ *(.*//'`
-  as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
-$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
-if eval \${$3+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$4
-int
-main ()
-{
-#ifndef $as_decl_name
-#ifdef __cplusplus
-  (void) $as_decl_use;
-#else
-  (void) $as_decl_name;
-#endif
-#endif
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  eval "$3=yes"
-else
-  eval "$3=no"
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-eval ac_res=\$$3
-	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-
-} # ac_fn_c_check_decl
-
 # ac_fn_c_compute_int LINENO EXPR VAR INCLUDES
 # --------------------------------------------
 # Tries to find the compile-time value of EXPR in a program that includes
@@ -2224,6 +2196,52 @@ $as_echo "$ac_res" >&6; }
   eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
 
 } # ac_fn_c_check_type
+
+# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
+# ---------------------------------------------
+# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
+# accordingly.
+ac_fn_c_check_decl ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  as_decl_name=`echo $2|sed 's/ *(.*//'`
+  as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
+$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
+if eval \${$3+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+#ifndef $as_decl_name
+#ifdef __cplusplus
+  (void) $as_decl_use;
+#else
+  (void) $as_decl_name;
+#endif
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$3=yes"
+else
+  eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_decl
 cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
@@ -11533,7 +11551,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11536 "configure"
+#line 11554 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11639,7 +11657,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11642 "configure"
+#line 11660 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12246,7 +12264,127 @@ fi
 
 
 
-# Enable debuginfod
+
+
+
+
+
+
+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
+	if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
+set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_PKG_CONFIG+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $PKG_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+PKG_CONFIG=$ac_cv_path_PKG_CONFIG
+if test -n "$PKG_CONFIG"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
+$as_echo "$PKG_CONFIG" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_path_PKG_CONFIG"; then
+  ac_pt_PKG_CONFIG=$PKG_CONFIG
+  # Extract the first word of "pkg-config", so it can be a program name with args.
+set dummy pkg-config; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $ac_pt_PKG_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG
+if test -n "$ac_pt_PKG_CONFIG"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5
+$as_echo "$ac_pt_PKG_CONFIG" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_pt_PKG_CONFIG" = x; then
+    PKG_CONFIG=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    PKG_CONFIG=$ac_pt_PKG_CONFIG
+  fi
+else
+  PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
+fi
+
+fi
+if test -n "$PKG_CONFIG"; then
+	_pkg_min_version=0.9.0
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5
+$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; }
+	if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+	else
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+		PKG_CONFIG=""
+	fi
+fi
+
+# Handle optional debuginfod support
 
 # Check whether --with-debuginfod was given.
 if test "${with_debuginfod+set}" = set; then :
@@ -12260,72 +12398,93 @@ $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; }
 
-if test "${with_debuginfod}" = no; then
-  { $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;}
-else
-  { $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.  */
+if test "x$with_debuginfod" != xno; then
 
-/* 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
+pkg_failed=no
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libdebuginfod >= 0.179" >&5
+$as_echo_n "checking for libdebuginfod >= 0.179... " >&6; }
+
+if test -n "$DEBUGINFOD_CFLAGS"; then
+    pkg_cv_DEBUGINFOD_CFLAGS="$DEBUGINFOD_CFLAGS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libdebuginfod >= 0.179\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "libdebuginfod >= 0.179") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_DEBUGINFOD_CFLAGS=`$PKG_CONFIG --cflags "libdebuginfod >= 0.179" 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes
 else
-  ac_cv_lib_debuginfod_debuginfod_begin=no
+  pkg_failed=yes
 fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
+ else
+    pkg_failed=untried
+fi
+if test -n "$DEBUGINFOD_LIBS"; then
+    pkg_cv_DEBUGINFOD_LIBS="$DEBUGINFOD_LIBS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libdebuginfod >= 0.179\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "libdebuginfod >= 0.179") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_DEBUGINFOD_LIBS=`$PKG_CONFIG --libs "libdebuginfod >= 0.179" 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes
+else
+  pkg_failed=yes
 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_debuginfod_lib=yes
+ else
+    pkg_failed=untried
 fi
 
-  ac_fn_c_check_decl "$LINENO" "debuginfod_begin" "ac_cv_have_decl_debuginfod_begin" "#include <elfutils/debuginfod.h>
-"
-if test "x$ac_cv_have_decl_debuginfod_begin" = xyes; then :
-  have_debuginfod_h=yes
-fi
 
-  if test "x$have_debuginfod_lib" = "xyes" -a \
-          "x$have_debuginfod_h" = "xyes"; then
 
-$as_echo "#define HAVE_LIBDEBUGINFOD 1" >>confdefs.h
+if test $pkg_failed = yes; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
 
-    LIBDEBUGINFOD="-ldebuginfod"
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+        _pkg_short_errors_supported=yes
+else
+        _pkg_short_errors_supported=no
+fi
+        if test $_pkg_short_errors_supported = yes; then
+	        DEBUGINFOD_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libdebuginfod >= 0.179" 2>&1`
+        else
+	        DEBUGINFOD_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libdebuginfod >= 0.179" 2>&1`
+        fi
+	# Put the nasty error message in config.log where it belongs
+	echo "$DEBUGINFOD_PKG_ERRORS" >&5
 
-  else
+	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
+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
+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; }
 
-    if test "$with_debuginfod" = yes; then
-      as_fn_error $? "debuginfod is missing or unusable" "$LINENO" 5
-    else
-      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: debuginfod is missing or unusable; some features may be unavailable." >&5
-$as_echo "$as_me: WARNING: debuginfod is missing or unusable; some features may be unavailable." >&2;}
-    fi
-  fi
+$as_echo "#define HAVE_LIBDEBUGINFOD 1" >>confdefs.h
+
+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
 
 
diff --git a/binutils/configure.ac b/binutils/configure.ac
index 883f3187e7..3c29df0b66 100644
--- a/binutils/configure.ac
+++ b/binutils/configure.ac
@@ -18,6 +18,7 @@ dnl <http://www.gnu.org/licenses/>.
 dnl
 
 m4_include([../bfd/version.m4])
+m4_include([../config/pkg.m4])
 m4_include([../config/debuginfod.m4])
 AC_INIT([binutils], BFD_VERSION)
 AC_CONFIG_SRCDIR(ar.c)
diff --git a/binutils/doc/Makefile.in b/binutils/doc/Makefile.in
index e925b81e0d..27adfe753b 100644
--- a/binutils/doc/Makefile.in
+++ b/binutils/doc/Makefile.in
@@ -128,7 +128,7 @@ am__aclocal_m4_deps = $(top_srcdir)/../bfd/acinclude.m4 \
 	$(top_srcdir)/../config/zlib.m4 $(top_srcdir)/../libtool.m4 \
 	$(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \
 	$(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \
-	$(top_srcdir)/../bfd/version.m4 \
+	$(top_srcdir)/../bfd/version.m4 $(top_srcdir)/../config/pkg.m4 \
 	$(top_srcdir)/../config/debuginfod.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
@@ -256,6 +256,8 @@ CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DATADIRNAME = @DATADIRNAME@
+DEBUGINFOD_CFLAGS = @DEBUGINFOD_CFLAGS@
+DEBUGINFOD_LIBS = @DEBUGINFOD_LIBS@
 DEFS = @DEFS@
 DEMANGLER_NAME = @DEMANGLER_NAME@
 DEPDIR = @DEPDIR@
@@ -287,7 +289,6 @@ LDFLAGS = @LDFLAGS@
 LEX = @LEX@
 LEXLIB = @LEXLIB@
 LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
-LIBDEBUGINFOD = @LIBDEBUGINFOD@
 LIBICONV = @LIBICONV@
 LIBINTL = @LIBINTL@
 LIBINTL_DEP = @LIBINTL_DEP@
@@ -321,6 +322,9 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
+PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
 POSUB = @POSUB@
 RANLIB = @RANLIB@
 SED = @SED@
diff --git a/config/debuginfod.m4 b/config/debuginfod.m4
index 9979abe89d..2c1bfbdb54 100644
--- a/config/debuginfod.m4
+++ b/config/debuginfod.m4
@@ -1,4 +1,4 @@
-dnl Copyright (C) 1997-2019 Free Software Foundation, Inc.
+dnl Copyright (C) 1997-2020 Free Software Foundation, Inc.
 dnl This file is free software, distributed under the terms of the GNU
 dnl General Public License.  As a special exception to the GNU General
 dnl Public License, this file may be distributed as part of a program
@@ -7,32 +7,22 @@ dnl the same distribution terms as the rest of that program.
 
 AC_DEFUN([AC_DEBUGINFOD],
 [
-# Enable debuginfod
+# Handle optional debuginfod support
 AC_ARG_WITH([debuginfod],
-        AC_HELP_STRING([--with-debuginfod],
-                       [Enable debuginfo lookups with debuginfod (auto/yes/no)]),
-        [], [with_debuginfod=auto])
+  AC_HELP_STRING([--with-debuginfod], [Enable debuginfo lookups with debuginfod (auto/yes/no)]),
+  [], [with_debuginfod=auto])
 AC_MSG_CHECKING([whether to use debuginfod])
 AC_MSG_RESULT([$with_debuginfod])
 
-if test "${with_debuginfod}" = no; then
-  AC_MSG_WARN([debuginfod support disabled; some features may be unavailable.])
+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_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])
 else
-  AC_CHECK_LIB([debuginfod], [debuginfod_begin], [have_debuginfod_lib=yes])
-  AC_CHECK_DECL([debuginfod_begin], [have_debuginfod_h=yes], [],
-                [#include <elfutils/debuginfod.h>])
-  if test "x$have_debuginfod_lib" = "xyes" -a \
-          "x$have_debuginfod_h" = "xyes"; then
-    AC_DEFINE([HAVE_LIBDEBUGINFOD], [1],
-              [Define to 1 if debuginfod is enabled.])
-    AC_SUBST([LIBDEBUGINFOD], ["-ldebuginfod"])
-  else
-    AC_SUBST([LIBDEBUGINFOD], [])
-    if test "$with_debuginfod" = yes; then
-      AC_MSG_ERROR([debuginfod is missing or unusable])
-    else
-      AC_MSG_WARN([debuginfod is missing or unusable; some features may be unavailable.])
-    fi
-  fi
+  AC_MSG_WARN([debuginfod support disabled; some features may be unavailable.])
 fi
 ])
diff --git a/config/pkg.m4 b/config/pkg.m4
new file mode 100644
index 0000000000..13a8890178
--- /dev/null
+++ b/config/pkg.m4
@@ -0,0 +1,275 @@
+# pkg.m4 - Macros to locate and utilise pkg-config.   -*- Autoconf -*-
+# serial 12 (pkg-config-0.29.2)
+
+dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
+dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
+dnl
+dnl This program is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 2 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+dnl General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+dnl 02111-1307, USA.
+dnl
+dnl As a special exception to the GNU General Public License, if you
+dnl distribute this file as part of a program that contains a
+dnl configuration script generated by Autoconf, you may include it under
+dnl the same distribution terms that you use for the rest of that
+dnl program.
+
+dnl PKG_PREREQ(MIN-VERSION)
+dnl -----------------------
+dnl Since: 0.29
+dnl
+dnl Verify that the version of the pkg-config macros are at least
+dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's
+dnl installed version of pkg-config, this checks the developer's version
+dnl of pkg.m4 when generating configure.
+dnl
+dnl To ensure that this macro is defined, also add:
+dnl m4_ifndef([PKG_PREREQ],
+dnl     [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])])
+dnl
+dnl See the "Since" comment for each macro you use to see what version
+dnl of the macros you require.
+m4_defun([PKG_PREREQ],
+[m4_define([PKG_MACROS_VERSION], [0.29.2])
+m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
+    [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
+])dnl PKG_PREREQ
+
+dnl PKG_PROG_PKG_CONFIG([MIN-VERSION])
+dnl ----------------------------------
+dnl Since: 0.16
+dnl
+dnl Search for the pkg-config tool and set the PKG_CONFIG variable to
+dnl first found in the path. Checks that the version of pkg-config found
+dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is
+dnl used since that's the first version where most current features of
+dnl pkg-config existed.
+AC_DEFUN([PKG_PROG_PKG_CONFIG],
+[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
+m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
+m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
+AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
+AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
+AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
+
+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
+	AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
+fi
+if test -n "$PKG_CONFIG"; then
+	_pkg_min_version=m4_default([$1], [0.9.0])
+	AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
+	if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
+		AC_MSG_RESULT([yes])
+	else
+		AC_MSG_RESULT([no])
+		PKG_CONFIG=""
+	fi
+fi[]dnl
+])dnl PKG_PROG_PKG_CONFIG
+
+dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+dnl -------------------------------------------------------------------
+dnl Since: 0.18
+dnl
+dnl Check to see whether a particular set of modules exists. Similar to
+dnl PKG_CHECK_MODULES(), but does not set variables or print errors.
+dnl
+dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+dnl only at the first occurence in configure.ac, so if the first place
+dnl it's called might be skipped (such as if it is within an "if", you
+dnl have to call PKG_CHECK_EXISTS manually
+AC_DEFUN([PKG_CHECK_EXISTS],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+if test -n "$PKG_CONFIG" && \
+    AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
+  m4_default([$2], [:])
+m4_ifvaln([$3], [else
+  $3])dnl
+fi])
+
+dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
+dnl ---------------------------------------------
+dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting
+dnl pkg_failed based on the result.
+m4_define([_PKG_CONFIG],
+[if test -n "$$1"; then
+    pkg_cv_[]$1="$$1"
+ elif test -n "$PKG_CONFIG"; then
+    PKG_CHECK_EXISTS([$3],
+                     [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes ],
+		     [pkg_failed=yes])
+ else
+    pkg_failed=untried
+fi[]dnl
+])dnl _PKG_CONFIG
+
+dnl _PKG_SHORT_ERRORS_SUPPORTED
+dnl ---------------------------
+dnl Internal check to see if pkg-config supports short errors.
+AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+        _pkg_short_errors_supported=yes
+else
+        _pkg_short_errors_supported=no
+fi[]dnl
+])dnl _PKG_SHORT_ERRORS_SUPPORTED
+
+
+dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
+dnl   [ACTION-IF-NOT-FOUND])
+dnl --------------------------------------------------------------
+dnl Since: 0.4.0
+dnl
+dnl Note that if there is a possibility the first call to
+dnl PKG_CHECK_MODULES might not happen, you should be sure to include an
+dnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
+AC_DEFUN([PKG_CHECK_MODULES],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
+AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
+
+pkg_failed=no
+AC_MSG_CHECKING([for $2])
+
+_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
+_PKG_CONFIG([$1][_LIBS], [libs], [$2])
+
+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.])
+
+if test $pkg_failed = yes; then
+        AC_MSG_RESULT([no])
+        _PKG_SHORT_ERRORS_SUPPORTED
+        if test $_pkg_short_errors_supported = yes; then
+	        $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
+        else
+	        $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
+        fi
+	# Put the nasty error message in config.log where it belongs
+	echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
+
+	m4_default([$4], [AC_MSG_ERROR(
+[Package requirements ($2) were not met:
+
+$$1_PKG_ERRORS
+
+Consider adjusting the PKG_CONFIG_PATH environment variable if you
+installed software in a non-standard prefix.
+
+_PKG_TEXT])[]dnl
+        ])
+elif test $pkg_failed = untried; then
+        AC_MSG_RESULT([no])
+	m4_default([$4], [AC_MSG_FAILURE(
+[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.
+
+_PKG_TEXT
+
+To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl
+        ])
+else
+	$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
+	$1[]_LIBS=$pkg_cv_[]$1[]_LIBS
+        AC_MSG_RESULT([yes])
+	$3
+fi[]dnl
+])dnl PKG_CHECK_MODULES
+
+
+dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
+dnl   [ACTION-IF-NOT-FOUND])
+dnl ---------------------------------------------------------------------
+dnl Since: 0.29
+dnl
+dnl Checks for existence of MODULES and gathers its build flags with
+dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags
+dnl and VARIABLE-PREFIX_LIBS from --libs.
+dnl
+dnl Note that if there is a possibility the first call to
+dnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to
+dnl include an explicit call to PKG_PROG_PKG_CONFIG in your
+dnl configure.ac.
+AC_DEFUN([PKG_CHECK_MODULES_STATIC],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+_save_PKG_CONFIG=$PKG_CONFIG
+PKG_CONFIG="$PKG_CONFIG --static"
+PKG_CHECK_MODULES($@)
+PKG_CONFIG=$_save_PKG_CONFIG[]dnl
+])dnl PKG_CHECK_MODULES_STATIC
+
+
+dnl PKG_INSTALLDIR([DIRECTORY])
+dnl -------------------------
+dnl Since: 0.27
+dnl
+dnl Substitutes the variable pkgconfigdir as the location where a module
+dnl should install pkg-config .pc files. By default the directory is
+dnl $libdir/pkgconfig, but the default can be changed by passing
+dnl DIRECTORY. The user can override through the --with-pkgconfigdir
+dnl parameter.
+AC_DEFUN([PKG_INSTALLDIR],
+[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
+m4_pushdef([pkg_description],
+    [pkg-config installation directory @<:@]pkg_default[@:>@])
+AC_ARG_WITH([pkgconfigdir],
+    [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],,
+    [with_pkgconfigdir=]pkg_default)
+AC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
+m4_popdef([pkg_default])
+m4_popdef([pkg_description])
+])dnl PKG_INSTALLDIR
+
+
+dnl PKG_NOARCH_INSTALLDIR([DIRECTORY])
+dnl --------------------------------
+dnl Since: 0.27
+dnl
+dnl Substitutes the variable noarch_pkgconfigdir as the location where a
+dnl module should install arch-independent pkg-config .pc files. By
+dnl default the directory is $datadir/pkgconfig, but the default can be
+dnl changed by passing DIRECTORY. The user can override through the
+dnl --with-noarch-pkgconfigdir parameter.
+AC_DEFUN([PKG_NOARCH_INSTALLDIR],
+[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
+m4_pushdef([pkg_description],
+    [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@])
+AC_ARG_WITH([noarch-pkgconfigdir],
+    [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],,
+    [with_noarch_pkgconfigdir=]pkg_default)
+AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
+m4_popdef([pkg_default])
+m4_popdef([pkg_description])
+])dnl PKG_NOARCH_INSTALLDIR
+
+
+dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
+dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+dnl -------------------------------------------
+dnl Since: 0.28
+dnl
+dnl Retrieves the value of the pkg-config variable for the given module.
+AC_DEFUN([PKG_CHECK_VAR],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
+
+_PKG_CONFIG([$1], [variable="][$3]["], [$2])
+AS_VAR_COPY([$1], [pkg_cv_][$1])
+
+AS_VAR_IF([$1], [""], [$5], [$4])dnl
+])dnl PKG_CHECK_VAR
diff --git a/configure b/configure
index 54d0339ab9..68779feb42 100755
--- a/configure
+++ b/configure
@@ -690,7 +690,6 @@ extra_mpc_gmp_configure_flags
 extra_mpfr_configure_flags
 gmpinc
 gmplibs
-LIBDEBUGINFOD
 do_compare
 GNATMAKE
 GNATBIND
@@ -791,7 +790,6 @@ enable_libssp
 enable_libstdcxx
 enable_liboffloadmic
 enable_bootstrap
-with_debuginfod
 with_mpc
 with_mpc_include
 with_mpc_lib
@@ -1555,8 +1553,6 @@ Optional Packages:
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
   --with-build-libsubdir=DIR  Directory where to find libraries for build system
   --with-system-zlib      use installed libz
-  --with-debuginfod       Enable debuginfo lookups with debuginfod
-                          (auto/yes/no)
   --with-mpc=PATH         specify prefix directory for installed MPC package.
                           Equivalent to --with-mpc-include=PATH/include plus
                           --with-mpc-lib=PATH/lib
@@ -1925,52 +1921,6 @@ fi
   as_fn_set_status $ac_retval
 
 } # ac_fn_c_try_link
-
-# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
-# ---------------------------------------------
-# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
-# accordingly.
-ac_fn_c_check_decl ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  as_decl_name=`echo $2|sed 's/ *(.*//'`
-  as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
-$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
-if eval \${$3+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$4
-int
-main ()
-{
-#ifndef $as_decl_name
-#ifdef __cplusplus
-  (void) $as_decl_use;
-#else
-  (void) $as_decl_name;
-#endif
-#endif
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  eval "$3=yes"
-else
-  eval "$3=no"
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-eval ac_res=\$$3
-	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-
-} # ac_fn_c_check_decl
 cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
@@ -5505,92 +5455,6 @@ gmplibs="-lmpc -lmpfr -lgmp"
 gmpinc=
 have_gmp=no
 
-# Check for debuginfod
-
-
-# Enable debuginfod
-
-# Check whether --with-debuginfod was given.
-if test "${with_debuginfod+set}" = set; then :
-  withval=$with_debuginfod;
-else
-  with_debuginfod=auto
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use debuginfod" >&5
-$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; }
-
-if test "${with_debuginfod}" = no; then
-  { $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;}
-else
-  { $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.  */
-
-/* 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_debuginfod_lib=yes
-fi
-
-  ac_fn_c_check_decl "$LINENO" "debuginfod_begin" "ac_cv_have_decl_debuginfod_begin" "#include <elfutils/debuginfod.h>
-"
-if test "x$ac_cv_have_decl_debuginfod_begin" = xyes; then :
-  have_debuginfod_h=yes
-fi
-
-  if test "x$have_debuginfod_lib" = "xyes" -a \
-          "x$have_debuginfod_h" = "xyes"; then
-
-$as_echo "#define HAVE_LIBDEBUGINFOD 1" >>confdefs.h
-
-    LIBDEBUGINFOD="-ldebuginfod"
-
-  else
-
-    if test "$with_debuginfod" = yes; then
-      as_fn_error $? "debuginfod is missing or unusable" "$LINENO" 5
-    else
-      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: debuginfod is missing or unusable; some features may be unavailable." >&5
-$as_echo "$as_me: WARNING: debuginfod is missing or unusable; some features may be unavailable." >&2;}
-    fi
-  fi
-fi
-
-
 # Specify a location for mpc
 # check for this first so it ends up on the link line before mpfr.
 
@@ -5745,7 +5609,8 @@ if test -d ${srcdir}/gcc && test "x$have_gmp" = xno; then
   # Check for the recommended and required versions of GMP.
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the correct version of gmp.h" >&5
 $as_echo_n "checking for the correct version of gmp.h... " >&6; }
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include "gmp.h"
 int
diff --git a/configure.ac b/configure.ac
index a910c4fd6b..d16a275768 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,7 +23,6 @@ m4_include(config/acx.m4)
 m4_include(config/override.m4)
 m4_include(config/proginstall.m4)
 m4_include(config/elf.m4)
-m4_include(config/debuginfod.m4)
 m4_include([libtool.m4])
 m4_include([ltoptions.m4])
 m4_include([ltsugar.m4])
@@ -1383,9 +1382,6 @@ gmplibs="-lmpc -lmpfr -lgmp"
 gmpinc=
 have_gmp=no
 
-# Check for debuginfod
-AC_DEBUGINFOD
-
 # Specify a location for mpc
 # check for this first so it ends up on the link line before mpfr.
 AC_ARG_WITH(mpc,
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index f30edafdf9..eef4e0df77 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2020-07-16  Aaron Merey  <amerey@redhat.com>
+
+	* Makefile.in: Replace LIBDEBUGINFOD with DEBUGINFOD_LIBS.
+	* configure: Rebuild.
+	* configure.ac: Include pkg.m4.
+
 2020-07-15  Andrew Burgess  <andrew.burgess@embecosm.com>
 
 	* f-typeprint.c (f_type_print_base): Allow for dynamic types not
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 9d48445739..f9bde2b9a9 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -623,7 +623,7 @@ CLIBS = $(SIM) $(READLINE) $(OPCODES) $(LIBCTF) $(BFD) $(ZLIB) \
 	$(LIBEXPAT) $(LIBLZMA) $(LIBBABELTRACE) $(LIBIPT) \
 	$(WIN32LIBS) $(LIBGNU) $(LIBICONV) \
 	$(LIBMPFR) $(SRCHIGH_LIBS) $(LIBXXHASH) $(PTHREAD_LIBS) \
-	@LIBDEBUGINFOD@
+	@DEBUGINFOD_LIBS@
 CDEPS = $(NAT_CDEPS) $(SIM) $(BFD) $(READLINE_DEPS) $(CTF_DEPS) \
 	$(OPCODES) $(INTL_DEPS) $(LIBIBERTY) $(CONFIG_DEPS) $(LIBGNU) \
 	$(LIBSUPPORT)
diff --git a/gdb/configure b/gdb/configure
index e8bfdbc709..a83165e729 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -761,7 +761,11 @@ REPORT_BUGS_TEXI
 REPORT_BUGS_TO
 PKGVERSION
 CODESIGN_CERT
-LIBDEBUGINFOD
+DEBUGINFOD_LIBS
+DEBUGINFOD_CFLAGS
+PKG_CONFIG_LIBDIR
+PKG_CONFIG_PATH
+PKG_CONFIG
 HAVE_NATIVE_GCORE_TARGET
 TARGET_OBS
 subdirs
@@ -939,6 +943,11 @@ CCC
 CPP
 MAKEINFO
 MAKEINFOFLAGS
+PKG_CONFIG
+PKG_CONFIG_PATH
+PKG_CONFIG_LIBDIR
+DEBUGINFOD_CFLAGS
+DEBUGINFOD_LIBS
 YACC
 YFLAGS
 XMKMF'
@@ -1683,6 +1692,15 @@ Some influential environment variables:
   MAKEINFO    Parent configure detects if it is of sufficient version.
   MAKEINFOFLAGS
               Parameters for MAKEINFO.
+  PKG_CONFIG  path to pkg-config utility
+  PKG_CONFIG_PATH
+              directories to add to pkg-config's search path
+  PKG_CONFIG_LIBDIR
+              path overriding pkg-config's built-in search path
+  DEBUGINFOD_CFLAGS
+              C compiler flags for DEBUGINFOD, overriding pkg-config
+  DEBUGINFOD_LIBS
+              linker flags for DEBUGINFOD, overriding pkg-config
   YACC        The `Yet Another Compiler Compiler' implementation to use.
               Defaults to the first program found out of: `bison -y', `byacc',
               `yacc'.
@@ -2273,52 +2291,6 @@ rm -f conftest.val
 
 } # ac_fn_c_compute_int
 
-# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
-# ---------------------------------------------
-# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
-# accordingly.
-ac_fn_c_check_decl ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  as_decl_name=`echo $2|sed 's/ *(.*//'`
-  as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
-$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
-if eval \${$3+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$4
-int
-main ()
-{
-#ifndef $as_decl_name
-#ifdef __cplusplus
-  (void) $as_decl_use;
-#else
-  (void) $as_decl_name;
-#endif
-#endif
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  eval "$3=yes"
-else
-  eval "$3=no"
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-eval ac_res=\$$3
-	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-
-} # ac_fn_c_check_decl
-
 # ac_fn_c_check_func LINENO FUNC VAR
 # ----------------------------------
 # Tests whether FUNC exists, setting the cache variable VAR accordingly
@@ -2440,6 +2412,52 @@ $as_echo "$ac_res" >&6; }
 
 } # ac_fn_c_check_type
 
+# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
+# ---------------------------------------------
+# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
+# accordingly.
+ac_fn_c_check_decl ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  as_decl_name=`echo $2|sed 's/ *(.*//'`
+  as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
+$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
+if eval \${$3+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+#ifndef $as_decl_name
+#ifdef __cplusplus
+  (void) $as_decl_use;
+#else
+  (void) $as_decl_name;
+#endif
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$3=yes"
+else
+  eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_decl
+
 # ac_fn_c_check_member LINENO AGGR MEMBER VAR INCLUDES
 # ----------------------------------------------------
 # Tries to find if the field MEMBER exists in type AGGR, after including
@@ -6844,7 +6862,127 @@ esac
 
 # Handle optional debuginfod support
 
-# Enable debuginfod
+
+
+
+
+
+
+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
+	if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
+set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_PKG_CONFIG+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $PKG_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+PKG_CONFIG=$ac_cv_path_PKG_CONFIG
+if test -n "$PKG_CONFIG"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
+$as_echo "$PKG_CONFIG" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_path_PKG_CONFIG"; then
+  ac_pt_PKG_CONFIG=$PKG_CONFIG
+  # Extract the first word of "pkg-config", so it can be a program name with args.
+set dummy pkg-config; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $ac_pt_PKG_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG
+if test -n "$ac_pt_PKG_CONFIG"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5
+$as_echo "$ac_pt_PKG_CONFIG" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_pt_PKG_CONFIG" = x; then
+    PKG_CONFIG=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    PKG_CONFIG=$ac_pt_PKG_CONFIG
+  fi
+else
+  PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
+fi
+
+fi
+if test -n "$PKG_CONFIG"; then
+	_pkg_min_version=0.9.0
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5
+$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; }
+	if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+	else
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+		PKG_CONFIG=""
+	fi
+fi
+
+# Handle optional debuginfod support
 
 # Check whether --with-debuginfod was given.
 if test "${with_debuginfod+set}" = set; then :
@@ -6858,72 +6996,93 @@ $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; }
 
-if test "${with_debuginfod}" = no; then
-  { $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;}
-else
-  { $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.  */
+if test "x$with_debuginfod" != xno; then
 
-/* 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
+pkg_failed=no
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libdebuginfod >= 0.179" >&5
+$as_echo_n "checking for libdebuginfod >= 0.179... " >&6; }
+
+if test -n "$DEBUGINFOD_CFLAGS"; then
+    pkg_cv_DEBUGINFOD_CFLAGS="$DEBUGINFOD_CFLAGS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libdebuginfod >= 0.179\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "libdebuginfod >= 0.179") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_DEBUGINFOD_CFLAGS=`$PKG_CONFIG --cflags "libdebuginfod >= 0.179" 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes
 else
-  ac_cv_lib_debuginfod_debuginfod_begin=no
+  pkg_failed=yes
 fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
+ else
+    pkg_failed=untried
 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_debuginfod_lib=yes
+if test -n "$DEBUGINFOD_LIBS"; then
+    pkg_cv_DEBUGINFOD_LIBS="$DEBUGINFOD_LIBS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libdebuginfod >= 0.179\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "libdebuginfod >= 0.179") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_DEBUGINFOD_LIBS=`$PKG_CONFIG --libs "libdebuginfod >= 0.179" 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes
+else
+  pkg_failed=yes
 fi
-
-  ac_fn_c_check_decl "$LINENO" "debuginfod_begin" "ac_cv_have_decl_debuginfod_begin" "#include <elfutils/debuginfod.h>
-"
-if test "x$ac_cv_have_decl_debuginfod_begin" = xyes; then :
-  have_debuginfod_h=yes
+ else
+    pkg_failed=untried
 fi
 
-  if test "x$have_debuginfod_lib" = "xyes" -a \
-          "x$have_debuginfod_h" = "xyes"; then
 
-$as_echo "#define HAVE_LIBDEBUGINFOD 1" >>confdefs.h
 
-    LIBDEBUGINFOD="-ldebuginfod"
+if test $pkg_failed = yes; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
 
-  else
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+        _pkg_short_errors_supported=yes
+else
+        _pkg_short_errors_supported=no
+fi
+        if test $_pkg_short_errors_supported = yes; then
+	        DEBUGINFOD_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libdebuginfod >= 0.179" 2>&1`
+        else
+	        DEBUGINFOD_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libdebuginfod >= 0.179" 2>&1`
+        fi
+	# Put the nasty error message in config.log where it belongs
+	echo "$DEBUGINFOD_PKG_ERRORS" >&5
 
-    if test "$with_debuginfod" = yes; then
-      as_fn_error $? "debuginfod is missing or unusable" "$LINENO" 5
-    else
-      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: debuginfod is missing or unusable; some features may be unavailable." >&5
-$as_echo "$as_me: WARNING: debuginfod is missing or unusable; some features may be unavailable." >&2;}
-    fi
-  fi
+	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
+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
+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 "#define HAVE_LIBDEBUGINFOD 1" >>confdefs.h
+
+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
 
 
diff --git a/gdb/configure.ac b/gdb/configure.ac
index b975cec84f..eacd9b019f 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -18,7 +18,8 @@ dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 dnl Process this file with autoconf to produce a configure script.
 
-m4_include(../config/debuginfod.m4)
+m4_include([../config/pkg.m4])
+m4_include([../config/debuginfod.m4])
 
 AC_INIT(main.c)
 AC_CONFIG_HEADERS(config.h:config.in, [echo > stamp-h])
-- 
2.25.4


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH] config/debuginfod.m4: Use PKG_CHECK_MODULES
  2020-07-16 22:37       ` Aaron Merey
@ 2020-07-19 15:43         ` Simon Marchi
  2020-07-21 15:20           ` Tom Tromey
  0 siblings, 1 reply; 37+ messages in thread
From: Simon Marchi @ 2020-07-19 15:43 UTC (permalink / raw)
  To: Aaron Merey, Tom Tromey
  Cc: Aaron Merey via Binutils, Jeff Law, gcc-patches, gdb-patches

On 2020-07-16 6:37 p.m., Aaron Merey wrote:
> On Fri, May 8, 2020 at 4:56 PM Tom Tromey <tom@tromey.com> wrote:
>>
>>>>>>> "Aaron" == Aaron Merey via Binutils <binutils@sourceware.org> writes:
>>
>> Aaron>         * Makefile.in: Replace LIBDEBUGINFOD with DEBUGINFOD_LIBS.
>> Aaron>         * aclocal.m4: Rebuild.
>>
>> Instead of inlining pkg.m4 into aclocal.m4, how about making
>> config/pkg.m4 and then using m4_include from gdb/acinclude.m4?
>> That's what gdb does for other shared m4 code.
> 
> Resending the patch for this since my last attempt didn't seem to
> properly reply to
> Tom's email.
> 

Since it's debuginfo.m4 that is using PKG_CHECK_MODULES, can you put the include
of pkg.m4 in debuginfo.m4, instead of in {binutils,gdb}/configure.ac?

Otherwise, from GDB's point of view I think it looks good, unless Tom has some things to add.

Simon

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH] config/debuginfod.m4: Use PKG_CHECK_MODULES
  2020-07-19 15:43         ` Simon Marchi
@ 2020-07-21 15:20           ` Tom Tromey
  2020-07-21 18:11             ` Aaron Merey
  0 siblings, 1 reply; 37+ messages in thread
From: Tom Tromey @ 2020-07-21 15:20 UTC (permalink / raw)
  To: Simon Marchi
  Cc: Aaron Merey, Tom Tromey, Aaron Merey via Binutils, Jeff Law,
	gcc-patches, gdb-patches

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.

Tom

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH] config/debuginfod.m4: Use PKG_CHECK_MODULES
  2020-07-21 15:20           ` Tom Tromey
@ 2020-07-21 18:11             ` Aaron Merey
  2020-07-24 20:03               ` Aaron Merey
  0 siblings, 1 reply; 37+ messages in thread
From: Aaron Merey @ 2020-07-21 18:11 UTC (permalink / raw)
  To: Tom Tromey
  Cc: Simon Marchi, Aaron Merey via Binutils, Jeff Law, gcc-patches,
	gdb-patches

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?

Aaron


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH] config/debuginfod.m4: Use PKG_CHECK_MODULES
  2020-07-21 18:11             ` Aaron Merey
@ 2020-07-24 20:03               ` Aaron Merey
  2020-07-25 16:01                 ` H.J. Lu
  0 siblings, 1 reply; 37+ messages in thread
From: Aaron Merey @ 2020-07-24 20:03 UTC (permalink / raw)
  To: Tom Tromey
  Cc: Simon Marchi, Aaron Merey via Binutils, Jeff Law, gcc-patches,
	gdb-patches

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.

Aaron


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH] config/debuginfod.m4: Use PKG_CHECK_MODULES
  2020-07-24 20:03               ` Aaron Merey
@ 2020-07-25 16:01                 ` H.J. Lu
  2020-07-27 15:31                   ` [PATCH] config/debuginfod.m4: Restore AC_CHECK_LIB check H.J. Lu
  0 siblings, 1 reply; 37+ messages in thread
From: H.J. Lu @ 2020-07-25 16:01 UTC (permalink / raw)
  To: Aaron Merey
  Cc: Tom Tromey, Simon Marchi, GCC Patches, Aaron Merey via Binutils, GDB

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

-- 
H.J.

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [PATCH] config/debuginfod.m4: Restore AC_CHECK_LIB check
  2020-07-25 16:01                 ` H.J. Lu
@ 2020-07-27 15:31                   ` H.J. Lu
  2020-07-27 16:11                     ` Aaron Merey
  0 siblings, 1 reply; 37+ messages in thread
From: H.J. Lu @ 2020-07-27 15:31 UTC (permalink / raw)
  To: Aaron Merey
  Cc: Tom Tromey, Simon Marchi, GCC Patches, Aaron Merey via Binutils, GDB

[-- 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


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH] config/debuginfod.m4: Restore AC_CHECK_LIB check
  2020-07-27 15:31                   ` [PATCH] config/debuginfod.m4: Restore AC_CHECK_LIB check H.J. Lu
@ 2020-07-27 16:11                     ` Aaron Merey
  2020-07-27 19:14                       ` [PATCH] PKG_CHECK_MODULES: Check if $pkg_cv_[]$1[]_LIBS works H.J. Lu
  0 siblings, 1 reply; 37+ messages in thread
From: Aaron Merey @ 2020-07-27 16:11 UTC (permalink / raw)
  To: H.J. Lu
  Cc: Tom Tromey, Simon Marchi, GCC Patches, Aaron Merey via Binutils, GDB

On Mon, Jul 27, 2020 at 11:32 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Sat, Jul 25, 2020 at 9:01 AM H.J. Lu <hjl.tools@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.

Aaron


^ permalink raw reply	[flat|nested] 37+ messages in thread

* [PATCH] PKG_CHECK_MODULES: Check if $pkg_cv_[]$1[]_LIBS works
  2020-07-27 16:11                     ` Aaron Merey
@ 2020-07-27 19:14                       ` H.J. Lu
  2020-07-27 19:32                         ` V2 " H.J. Lu
  0 siblings, 1 reply; 37+ messages in thread
From: H.J. Lu @ 2020-07-27 19:14 UTC (permalink / raw)
  To: Aaron Merey
  Cc: Tom Tromey, Simon Marchi, GCC Patches, Aaron Merey via Binutils, GDB

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

On Mon, Jul 27, 2020 at 9:11 AM Aaron Merey <amerey@redhat.com> wrote:
>
> On Mon, Jul 27, 2020 at 11:32 AM H.J. Lu <hjl.tools@gmail.com> wrote:
> >
> > On Sat, Jul 25, 2020 at 9:01 AM H.J. Lu <hjl.tools@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?


-- 
H.J.

[-- Attachment #2: 0001-PKG_CHECK_MODULES-Check-if-pkg_cv_-1-_LIBS-works.patch --]
[-- Type: text/x-patch, Size: 8330 bytes --]

From 42d49b1444ad6c8475672f6a6a16810d9e7c15ef 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] 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.  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): Always define HAVE_LIBDEBUGINFOD
	to 0 or 1.
	* 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   | 38 +++++++++++++++++++++++++++++++++-----
 config/debuginfod.m4 |  9 +++++++--
 config/pkg.m4        |  6 ++++++
 gdb/configure        | 38 +++++++++++++++++++++++++++++++++-----
 4 files changed, 79 insertions(+), 12 deletions(-)

diff --git a/binutils/configure b/binutils/configure
index c9fc5108e0..3f9ac88990 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
@@ -12439,6 +12440,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
@@ -12458,7 +12481,8 @@ fi
 	# Put the nasty error message in config.log where it belongs
 	echo "$DEBUGINFOD_PKG_ERRORS" >&5
 
-	if test "x$with_debuginfod" = xyes; then
+	have_libdebuginfod=0
+     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
@@ -12467,7 +12491,8 @@ $as_echo "$as_me: WARNING: libdebuginfod is missing or unusable; some features m
 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
+	have_libdebuginfod=0
+     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
@@ -12478,15 +12503,18 @@ else
 	DEBUGINFOD_LIBS=$pkg_cv_DEBUGINFOD_LIBS
         { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
-
-$as_echo "#define HAVE_LIBDEBUGINFOD 1" >>confdefs.h
-
+	have_libdebuginfod=1
 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..aec05104be 100644
--- a/config/debuginfod.m4
+++ b/config/debuginfod.m4
@@ -16,10 +16,12 @@ 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
+    [have_libdebuginfod=1],
+    [have_libdebuginfod=0
+     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.])
@@ -27,4 +29,7 @@ if test "x$with_debuginfod" != xno; then
 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/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..747605aaa2 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
@@ -7037,6 +7038,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
@@ -7056,7 +7079,8 @@ fi
 	# Put the nasty error message in config.log where it belongs
 	echo "$DEBUGINFOD_PKG_ERRORS" >&5
 
-	if test "x$with_debuginfod" = xyes; then
+	have_libdebuginfod=0
+     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
@@ -7065,7 +7089,8 @@ $as_echo "$as_me: WARNING: libdebuginfod is missing or unusable; some features m
 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
+	have_libdebuginfod=0
+     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
@@ -7076,15 +7101,18 @@ else
 	DEBUGINFOD_LIBS=$pkg_cv_DEBUGINFOD_LIBS
         { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
-
-$as_echo "#define HAVE_LIBDEBUGINFOD 1" >>confdefs.h
-
+	have_libdebuginfod=1
 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


^ permalink raw reply	[flat|nested] 37+ messages in thread

* V2 [PATCH] PKG_CHECK_MODULES: Check if $pkg_cv_[]$1[]_LIBS works
  2020-07-27 19:14                       ` [PATCH] PKG_CHECK_MODULES: Check if $pkg_cv_[]$1[]_LIBS works H.J. Lu
@ 2020-07-27 19:32                         ` H.J. Lu
  2020-07-28 10:45                           ` H.J. Lu
  2020-07-28 12:54                           ` Mark Wielaard
  0 siblings, 2 replies; 37+ messages in thread
From: H.J. Lu @ 2020-07-27 19:32 UTC (permalink / raw)
  To: Aaron Merey
  Cc: Tom Tromey, Simon Marchi, GCC Patches, Aaron Merey via Binutils, GDB

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

On Mon, Jul 27, 2020 at 12:14 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Mon, Jul 27, 2020 at 9:11 AM Aaron Merey <amerey@redhat.com> wrote:
> >
> > On Mon, Jul 27, 2020 at 11:32 AM H.J. Lu <hjl.tools@gmail.com> wrote:
> > >
> > > On Sat, Jul 25, 2020 at 9:01 AM H.J. Lu <hjl.tools@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.

[-- Attachment #2: 0001-PKG_CHECK_MODULES-Check-if-pkg_cv_-1-_LIBS-works.patch --]
[-- Type: text/x-patch, Size: 2673 bytes --]

From 44682ce298a8ce2b795303d4054ec532847bfcae 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] 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


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: V2 [PATCH] PKG_CHECK_MODULES: Check if $pkg_cv_[]$1[]_LIBS works
  2020-07-27 19:32                         ` V2 " H.J. Lu
@ 2020-07-28 10:45                           ` H.J. Lu
  2020-07-28 12:46                             ` Simon Marchi
  2020-07-28 12:54                           ` Mark Wielaard
  1 sibling, 1 reply; 37+ messages in thread
From: H.J. Lu @ 2020-07-28 10:45 UTC (permalink / raw)
  To: Aaron Merey
  Cc: Tom Tromey, Simon Marchi, GCC Patches, Aaron Merey via Binutils, GDB

On Mon, Jul 27, 2020 at 12:32 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Mon, Jul 27, 2020 at 12:14 PM H.J. Lu <hjl.tools@gmail.com> wrote:
> >
> > On Mon, Jul 27, 2020 at 9:11 AM Aaron Merey <amerey@redhat.com> wrote:
> > >
> > > On Mon, Jul 27, 2020 at 11:32 AM H.J. Lu <hjl.tools@gmail.com> wrote:
> > > >
> > > > On Sat, Jul 25, 2020 at 9:01 AM H.J. Lu <hjl.tools@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.
>

I am checking it in.

-- 
H.J.

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: V2 [PATCH] PKG_CHECK_MODULES: Check if $pkg_cv_[]$1[]_LIBS works
  2020-07-28 10:45                           ` H.J. Lu
@ 2020-07-28 12:46                             ` Simon Marchi
  2020-07-28 13:33                               ` H.J. Lu
  0 siblings, 1 reply; 37+ messages in thread
From: Simon Marchi @ 2020-07-28 12:46 UTC (permalink / raw)
  To: H.J. Lu, Aaron Merey
  Cc: Tom Tromey, GCC Patches, Aaron Merey via Binutils, GDB

On 2020-07-28 6:45 a.m., H.J. Lu wrote:
> On Mon, Jul 27, 2020 at 12:32 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>>
>> On Mon, Jul 27, 2020 at 12:14 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>>>
>>> On Mon, Jul 27, 2020 at 9:11 AM Aaron Merey <amerey@redhat.com> wrote:
>>>>
>>>> On Mon, Jul 27, 2020 at 11:32 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>>>>>
>>>>> On Sat, Jul 25, 2020 at 9:01 AM H.J. Lu <hjl.tools@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.
>>
> 
> I am checking it in.
> 
> -- 
> H.J.
> 

You said that you are not cross-compiling, but technically I'd say you are cross compiling, since
you are building for a different architecture than what the compiler is running.  You are probably
configuring with --host=i686-something-something?

Anyway regardless of vocabulary, I don't think there was a problem to begin with (not that I blame
you, it's not made in an intuitive way).  The problem is that you were using pkg-config as
configured to look up x86_64 packages.  It looks up .pc files in (amongst others)
/usr/lib64/pkgconfig, which provides information about x86_64 packages, which are in turn obviously
not suitable not suitable to build a i686 program.  Just like you cross-compile "for real" (say,
for an ARM host), you need to set PKG_CONFIG or the PKG_CONFIG_* variables to returns packages for
the --host architecture.  That means searching in /usr/lib/pkgconfig instead of /usr/lib64/pkgconfig.

You could for example set the PKG_CONFIG_LIBDIR variable to /usr/lib/pkgconfig:/usr/share/pkgconfig

This way, if you don't install the elfutils-debuginfod-client-devel.i686 package, your binutils won't
try to link with libdebuginfod (because pkg-config won't find it).  If you install it, then your
binutils will be built against the i686 libdebuginfod.

Ideally, distros would ship a i686-something-something-pkg-config that automatically searchs in paths
that make sense for that architecture (just like you have arm-linux-gnueabihf-pkg-config when cross
compiling for ARM), but that doesn't seem to exist.  But this is just like you have to explicitly set
CC="gcc -m32" instead of using some i686-something-something-gcc.

You can always make it yourself, create, say, a `i686-pc-linux-gnu-pkg-config` file somewhere in $PATH,
with:

  export PKG_CONFIG_LIBDIR=/usr/lib/pkgconfig:/usr/share/pkgconfig
  exec pkg-config $*

Then, when you configure with --host=i686-pc-linux-gnu, AC_PATH_TOOL will automatically pick up that as
the pkg-config to use, and everything will work seamlessly.

So, I concede that it's not intuitive, but I think your patch is not right because it just hides the
mis-configuration.  If `pkg-config` says a lib exists but we are not able to link with it, there is a
bigger problem than "lib not found".  I think it should be a hard error (abort configure) and tell the
user about it: "pkg-config says that libfoo is available but we can't link with it, are you maybe using
the wrong pkg-config, or a wrong pkg-config path?".

Finally, the file you modified is maintained upstream here:

  https://cgit.freedesktop.org/pkg-config/tree/pkg.m4.in

Do you intend to submit your changes there?  Otherwise, they will be overwritten next time we sync with
upstream.

Simon

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: V2 [PATCH] PKG_CHECK_MODULES: Check if $pkg_cv_[]$1[]_LIBS works
  2020-07-27 19:32                         ` V2 " H.J. Lu
  2020-07-28 10:45                           ` H.J. Lu
@ 2020-07-28 12:54                           ` Mark Wielaard
  2020-07-28 13:27                             ` [PATCH] PKG_CHECK_MODULES: Properly check " H.J. Lu
  1 sibling, 1 reply; 37+ messages in thread
From: Mark Wielaard @ 2020-07-28 12:54 UTC (permalink / raw)
  To: H.J. Lu, Aaron Merey
  Cc: Simon Marchi, Tom Tromey, GCC Patches, Aaron Merey via Binutils, GDB

Hi,

On Mon, 2020-07-27 at 12:32 -0700, H.J. Lu via Binutils wrote:
> 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.])

This hunk seems wrong. You are testing whether the $pkg_cv_[]$1[]_LIBS
flags work, but they might be empty if the library wasn't found
(pkg_failed=yes). Then the AC_TRY_LINK will obviously succeed, and then
you set pkg_failed=no. But that indicates that the library was found.

Cheers,

Mark

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [PATCH] PKG_CHECK_MODULES: Properly check if $pkg_cv_[]$1[]_LIBS works
  2020-07-28 12:54                           ` Mark Wielaard
@ 2020-07-28 13:27                             ` H.J. Lu
  0 siblings, 0 replies; 37+ messages in thread
From: H.J. Lu @ 2020-07-28 13:27 UTC (permalink / raw)
  To: Mark Wielaard
  Cc: Aaron Merey, Simon Marchi, Tom Tromey, GCC Patches,
	Aaron Merey via Binutils, GDB

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

On Tue, Jul 28, 2020 at 5:54 AM Mark Wielaard <mark@klomp.org> wrote:
>
> Hi,
>
> On Mon, 2020-07-27 at 12:32 -0700, H.J. Lu via Binutils wrote:
> > 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.])
>
> This hunk seems wrong. You are testing whether the $pkg_cv_[]$1[]_LIBS
> flags work, but they might be empty if the library wasn't found
> (pkg_failed=yes). Then the AC_TRY_LINK will obviously succeed, and then
> you set pkg_failed=no. But that indicates that the library was found.
>

This fixes it.

Thanks.

-- 
H.J.

[-- Attachment #2: 0001-PKG_CHECK_MODULES-Properly-check-if-pkg_cv_-1-_LIBS-.patch --]
[-- Type: text/x-patch, Size: 3036 bytes --]

From cd63fb898517cedf3366871f546375cf5e25c734 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Tue, 28 Jul 2020 06:18:50 -0700
Subject: [PATCH] PKG_CHECK_MODULES: Properly check if $pkg_cv_[]$1[]_LIBS
 works

There is no need to check $pkg_cv_[]$1[]_LIBS works if package check
failed.

config/

	PR binutils/26301
	* pkg.m4 (PKG_CHECK_MODULES): Use AC_TRY_LINK only if
	$pkg_failed = no.

binutils/

	PR binutils/26301
	* configure: Regenerated.

gdb/

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

diff --git a/binutils/configure b/binutils/configure
index 4620a6b105..18316b7696 100755
--- a/binutils/configure
+++ b/binutils/configure
@@ -12439,27 +12439,29 @@ fi
     pkg_failed=untried
 fi
 
-pkg_save_LDFLAGS="$LDFLAGS"
-LDFLAGS="$LDFLAGS $pkg_cv_DEBUGINFOD_LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+if test $pkg_failed = no; then
+  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
+  LDFLAGS=$pkg_save_LDFLAGS
+fi
 
 
 
diff --git a/config/pkg.m4 b/config/pkg.m4
index 45587e97c8..7ebf517cd6 100644
--- a/config/pkg.m4
+++ b/config/pkg.m4
@@ -148,10 +148,12 @@ _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
+if test $pkg_failed = no; then
+  pkg_save_LDFLAGS="$LDFLAGS"
+  LDFLAGS="$LDFLAGS $pkg_cv_[]$1[]_LIBS"
+  AC_TRY_LINK([],[], [], [pkg_failed=yes])
+  LDFLAGS=$pkg_save_LDFLAGS
+fi
 
 m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
 and $1[]_LIBS to avoid the need to call pkg-config.
diff --git a/gdb/configure b/gdb/configure
index eb38aaacfc..5ef85e8c86 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -7037,27 +7037,29 @@ fi
     pkg_failed=untried
 fi
 
-pkg_save_LDFLAGS="$LDFLAGS"
-LDFLAGS="$LDFLAGS $pkg_cv_DEBUGINFOD_LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+if test $pkg_failed = no; then
+  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
+  LDFLAGS=$pkg_save_LDFLAGS
+fi
 
 
 
-- 
2.26.2


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: V2 [PATCH] PKG_CHECK_MODULES: Check if $pkg_cv_[]$1[]_LIBS works
  2020-07-28 12:46                             ` Simon Marchi
@ 2020-07-28 13:33                               ` H.J. Lu
  2020-07-28 13:51                                 ` Andreas Schwab
                                                   ` (2 more replies)
  0 siblings, 3 replies; 37+ messages in thread
From: H.J. Lu @ 2020-07-28 13:33 UTC (permalink / raw)
  To: Simon Marchi
  Cc: Aaron Merey, Tom Tromey, GCC Patches, Aaron Merey via Binutils, GDB

On Tue, Jul 28, 2020 at 5:46 AM Simon Marchi <simark@simark.ca> wrote:
>
> On 2020-07-28 6:45 a.m., H.J. Lu wrote:
> > On Mon, Jul 27, 2020 at 12:32 PM H.J. Lu <hjl.tools@gmail.com> wrote:
> >>
> >> On Mon, Jul 27, 2020 at 12:14 PM H.J. Lu <hjl.tools@gmail.com> wrote:
> >>>
> >>> On Mon, Jul 27, 2020 at 9:11 AM Aaron Merey <amerey@redhat.com> wrote:
> >>>>
> >>>> On Mon, Jul 27, 2020 at 11:32 AM H.J. Lu <hjl.tools@gmail.com> wrote:
> >>>>>
> >>>>> On Sat, Jul 25, 2020 at 9:01 AM H.J. Lu <hjl.tools@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.
> >>
> >
> > I am checking it in.
> >
> > --
> > H.J.
> >
>
> You said that you are not cross-compiling, but technically I'd say you are cross compiling, since
> you are building for a different architecture than what the compiler is running.  You are probably
> configuring with --host=i686-something-something?

On x86, the native GCC can support -m32 and -m64.  "gcc -m32" or "gcc -m64"
 are not cross compiling.

> Anyway regardless of vocabulary, I don't think there was a problem to begin with (not that I blame
> you, it's not made in an intuitive way).  The problem is that you were using pkg-config as
> configured to look up x86_64 packages.  It looks up .pc files in (amongst others)
> /usr/lib64/pkgconfig, which provides information about x86_64 packages, which are in turn obviously
> not suitable not suitable to build a i686 program.  Just like you cross-compile "for real" (say,
> for an ARM host), you need to set PKG_CONFIG or the PKG_CONFIG_* variables to returns packages for
> the --host architecture.  That means searching in /usr/lib/pkgconfig instead of /usr/lib64/pkgconfig.
>
> You could for example set the PKG_CONFIG_LIBDIR variable to /usr/lib/pkgconfig:/usr/share/pkgconfig

I didn't set PKG_CONFIG_LIBDIR and I don't want to set it.

> This way, if you don't install the elfutils-debuginfod-client-devel.i686 package, your binutils won't
> try to link with libdebuginfod (because pkg-config won't find it).  If you install it, then your
> binutils will be built against the i686 libdebuginfod.
>
> Ideally, distros would ship a i686-something-something-pkg-config that automatically searchs in paths
> that make sense for that architecture (just like you have arm-linux-gnueabihf-pkg-config when cross
> compiling for ARM), but that doesn't seem to exist.  But this is just like you have to explicitly set
> CC="gcc -m32" instead of using some i686-something-something-gcc.
>
> You can always make it yourself, create, say, a `i686-pc-linux-gnu-pkg-config` file somewhere in $PATH,
> with:
>
>   export PKG_CONFIG_LIBDIR=/usr/lib/pkgconfig:/usr/share/pkgconfig
>   exec pkg-config $*

I don't want to do it.  PKG_CHECK_MODULES should check if the library
really works.
Otherwise we can use remove it and use the library directly without checking.

> Then, when you configure with --host=i686-pc-linux-gnu, AC_PATH_TOOL will automatically pick up that as
> the pkg-config to use, and everything will work seamlessly.
>
> So, I concede that it's not intuitive, but I think your patch is not right because it just hides the
> mis-configuration.  If `pkg-config` says a lib exists but we are not able to link with it, there is a
> bigger problem than "lib not found".  I think it should be a hard error (abort configure) and tell the
> user about it: "pkg-config says that libfoo is available but we can't link with it, are you maybe using
> the wrong pkg-config, or a wrong pkg-config path?".
>
> Finally, the file you modified is maintained upstream here:
>
>   https://cgit.freedesktop.org/pkg-config/tree/pkg.m4.in
>
> Do you intend to submit your changes there?  Otherwise, they will be overwritten next time we sync with
> upstream.
>

Will do.

-- 
H.J.

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: V2 [PATCH] PKG_CHECK_MODULES: Check if $pkg_cv_[]$1[]_LIBS works
  2020-07-28 13:33                               ` H.J. Lu
@ 2020-07-28 13:51                                 ` Andreas Schwab
  2020-07-28 13:56                                   ` H.J. Lu
  2020-07-28 13:53                                 ` H.J. Lu
  2020-07-28 13:54                                 ` Simon Marchi
  2 siblings, 1 reply; 37+ messages in thread
From: Andreas Schwab @ 2020-07-28 13:51 UTC (permalink / raw)
  To: H.J. Lu via Binutils
  Cc: Simon Marchi, H.J. Lu, Tom Tromey, GCC Patches, GDB, Aaron Merey

On Jul 28 2020, H.J. Lu via Binutils wrote:

> On x86, the native GCC can support -m32 and -m64.  "gcc -m32" or "gcc -m64"
>  are not cross compiling.

You cannot link -m64 and -m32 together.

> I didn't set PKG_CONFIG_LIBDIR and I don't want to set it.

Then use the correct pkg-config for your target.  If you think
pkg-config is broken, then fix _that_.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: V2 [PATCH] PKG_CHECK_MODULES: Check if $pkg_cv_[]$1[]_LIBS works
  2020-07-28 13:33                               ` H.J. Lu
  2020-07-28 13:51                                 ` Andreas Schwab
@ 2020-07-28 13:53                                 ` H.J. Lu
  2020-07-28 13:54                                 ` Simon Marchi
  2 siblings, 0 replies; 37+ messages in thread
From: H.J. Lu @ 2020-07-28 13:53 UTC (permalink / raw)
  To: Simon Marchi
  Cc: Aaron Merey, Tom Tromey, GCC Patches, Aaron Merey via Binutils, GDB

On Tue, Jul 28, 2020 at 6:33 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Tue, Jul 28, 2020 at 5:46 AM Simon Marchi <simark@simark.ca> wrote:
> >
> > On 2020-07-28 6:45 a.m., H.J. Lu wrote:
> > > On Mon, Jul 27, 2020 at 12:32 PM H.J. Lu <hjl.tools@gmail.com> wrote:
> > >>
> > >> On Mon, Jul 27, 2020 at 12:14 PM H.J. Lu <hjl.tools@gmail.com> wrote:
> > >>>
> > >>> On Mon, Jul 27, 2020 at 9:11 AM Aaron Merey <amerey@redhat.com> wrote:
> > >>>>
> > >>>> On Mon, Jul 27, 2020 at 11:32 AM H.J. Lu <hjl.tools@gmail.com> wrote:
> > >>>>>
> > >>>>> On Sat, Jul 25, 2020 at 9:01 AM H.J. Lu <hjl.tools@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.
> > >>
> > >
> > > I am checking it in.
> > >
> > > --
> > > H.J.
> > >
> >
> > You said that you are not cross-compiling, but technically I'd say you are cross compiling, since
> > you are building for a different architecture than what the compiler is running.  You are probably
> > configuring with --host=i686-something-something?
>
> On x86, the native GCC can support -m32 and -m64.  "gcc -m32" or "gcc -m64"
>  are not cross compiling.
>
> > Anyway regardless of vocabulary, I don't think there was a problem to begin with (not that I blame
> > you, it's not made in an intuitive way).  The problem is that you were using pkg-config as
> > configured to look up x86_64 packages.  It looks up .pc files in (amongst others)
> > /usr/lib64/pkgconfig, which provides information about x86_64 packages, which are in turn obviously
> > not suitable not suitable to build a i686 program.  Just like you cross-compile "for real" (say,
> > for an ARM host), you need to set PKG_CONFIG or the PKG_CONFIG_* variables to returns packages for
> > the --host architecture.  That means searching in /usr/lib/pkgconfig instead of /usr/lib64/pkgconfig.
> >
> > You could for example set the PKG_CONFIG_LIBDIR variable to /usr/lib/pkgconfig:/usr/share/pkgconfig
>
> I didn't set PKG_CONFIG_LIBDIR and I don't want to set it.
>
> > This way, if you don't install the elfutils-debuginfod-client-devel.i686 package, your binutils won't
> > try to link with libdebuginfod (because pkg-config won't find it).  If you install it, then your
> > binutils will be built against the i686 libdebuginfod.
> >
> > Ideally, distros would ship a i686-something-something-pkg-config that automatically searchs in paths
> > that make sense for that architecture (just like you have arm-linux-gnueabihf-pkg-config when cross
> > compiling for ARM), but that doesn't seem to exist.  But this is just like you have to explicitly set
> > CC="gcc -m32" instead of using some i686-something-something-gcc.
> >
> > You can always make it yourself, create, say, a `i686-pc-linux-gnu-pkg-config` file somewhere in $PATH,
> > with:
> >
> >   export PKG_CONFIG_LIBDIR=/usr/lib/pkgconfig:/usr/share/pkgconfig
> >   exec pkg-config $*
>
> I don't want to do it.  PKG_CHECK_MODULES should check if the library
> really works.
> Otherwise we can use remove it and use the library directly without checking.
>
> > Then, when you configure with --host=i686-pc-linux-gnu, AC_PATH_TOOL will automatically pick up that as
> > the pkg-config to use, and everything will work seamlessly.
> >
> > So, I concede that it's not intuitive, but I think your patch is not right because it just hides the
> > mis-configuration.  If `pkg-config` says a lib exists but we are not able to link with it, there is a
> > bigger problem than "lib not found".  I think it should be a hard error (abort configure) and tell the
> > user about it: "pkg-config says that libfoo is available but we can't link with it, are you maybe using
> > the wrong pkg-config, or a wrong pkg-config path?".
> >
> > Finally, the file you modified is maintained upstream here:
> >
> >   https://cgit.freedesktop.org/pkg-config/tree/pkg.m4.in
> >
> > Do you intend to submit your changes there?  Otherwise, they will be overwritten next time we sync with
> > upstream.
> >
>
> Will do.
>
> --
> H.J.

https://gitlab.freedesktop.org/pkg-config/pkg-config/-/merge_requests/6

-- 
H.J.

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: V2 [PATCH] PKG_CHECK_MODULES: Check if $pkg_cv_[]$1[]_LIBS works
  2020-07-28 13:33                               ` H.J. Lu
  2020-07-28 13:51                                 ` Andreas Schwab
  2020-07-28 13:53                                 ` H.J. Lu
@ 2020-07-28 13:54                                 ` Simon Marchi
  2 siblings, 0 replies; 37+ messages in thread
From: Simon Marchi @ 2020-07-28 13:54 UTC (permalink / raw)
  To: H.J. Lu
  Cc: Aaron Merey, Tom Tromey, GCC Patches, Aaron Merey via Binutils, GDB

On 2020-07-28 9:33 a.m., H.J. Lu wrote:
> On x86, the native GCC can support -m32 and -m64.  "gcc -m32" or "gcc -m64"
>  are not cross compiling.

And how does that make it not cross-compîling?

>> Anyway regardless of vocabulary, I don't think there was a problem to begin with (not that I blame
>> you, it's not made in an intuitive way).  The problem is that you were using pkg-config as
>> configured to look up x86_64 packages.  It looks up .pc files in (amongst others)
>> /usr/lib64/pkgconfig, which provides information about x86_64 packages, which are in turn obviously
>> not suitable not suitable to build a i686 program.  Just like you cross-compile "for real" (say,
>> for an ARM host), you need to set PKG_CONFIG or the PKG_CONFIG_* variables to returns packages for
>> the --host architecture.  That means searching in /usr/lib/pkgconfig instead of /usr/lib64/pkgconfig.
>>
>> You could for example set the PKG_CONFIG_LIBDIR variable to /usr/lib/pkgconfig:/usr/share/pkgconfig
> 
> I didn't set PKG_CONFIG_LIBDIR and I don't want to set it.

Why are you fine adjusting CC="gcc -m32" but not PKG_CONFIG*?

> 
>> This way, if you don't install the elfutils-debuginfod-client-devel.i686 package, your binutils won't
>> try to link with libdebuginfod (because pkg-config won't find it).  If you install it, then your
>> binutils will be built against the i686 libdebuginfod.
>>
>> Ideally, distros would ship a i686-something-something-pkg-config that automatically searchs in paths
>> that make sense for that architecture (just like you have arm-linux-gnueabihf-pkg-config when cross
>> compiling for ARM), but that doesn't seem to exist.  But this is just like you have to explicitly set
>> CC="gcc -m32" instead of using some i686-something-something-gcc.
>>
>> You can always make it yourself, create, say, a `i686-pc-linux-gnu-pkg-config` file somewhere in $PATH,
>> with:
>>
>>   export PKG_CONFIG_LIBDIR=/usr/lib/pkgconfig:/usr/share/pkgconfig
>>   exec pkg-config $*
> 
> I don't want to do it.  PKG_CHECK_MODULES should check if the library
> really works.
> Otherwise we can use remove it and use the library directly without checking.

We could, but that would have its own disadvantages.

Simon

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: V2 [PATCH] PKG_CHECK_MODULES: Check if $pkg_cv_[]$1[]_LIBS works
  2020-07-28 13:51                                 ` Andreas Schwab
@ 2020-07-28 13:56                                   ` H.J. Lu
  2020-07-28 14:01                                     ` Simon Marchi
  0 siblings, 1 reply; 37+ messages in thread
From: H.J. Lu @ 2020-07-28 13:56 UTC (permalink / raw)
  To: Andreas Schwab
  Cc: H.J. Lu via Binutils, Simon Marchi, Tom Tromey, GCC Patches, GDB,
	Aaron Merey

On Tue, Jul 28, 2020 at 6:51 AM Andreas Schwab <schwab@linux-m68k.org> wrote:
>
> On Jul 28 2020, H.J. Lu via Binutils wrote:
>
> > On x86, the native GCC can support -m32 and -m64.  "gcc -m32" or "gcc -m64"
> >  are not cross compiling.
>
> You cannot link -m64 and -m32 together.
>
> > I didn't set PKG_CONFIG_LIBDIR and I don't want to set it.
>
> Then use the correct pkg-config for your target.  If you think
> pkg-config is broken, then fix _that_.
>

I did:

RUNTESTFLAGS="--target_board 'unix{-m32}'" CC="gcc -m32 -fno-lto
-fcf-protection"
 CXX="g++ -fno-lto -m32 -fcf-protection" /exp
ort/gnu/import/git/gitlab/x86-binutils/configure \
--enable-targets=x86_64-linux \
i686-linux \
--enable-plugins --disable-gdb --disable-gdbserver --disable-libdecnumbe
r --disable-readline --disable-sim --with-sysroot=/ --with-system-zlib \
--prefix=/usr/local \
--with-local-prefix=/usr/local
configure: WARNING: you should use --build, --host, --target
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu

pkg.m4 should handle the system pkg-config, broken or not.

-- 
H.J.

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: V2 [PATCH] PKG_CHECK_MODULES: Check if $pkg_cv_[]$1[]_LIBS works
  2020-07-28 13:56                                   ` H.J. Lu
@ 2020-07-28 14:01                                     ` Simon Marchi
  2020-07-28 14:11                                       ` H.J. Lu
  0 siblings, 1 reply; 37+ messages in thread
From: Simon Marchi @ 2020-07-28 14:01 UTC (permalink / raw)
  To: H.J. Lu, Andreas Schwab
  Cc: H.J. Lu via Binutils, Tom Tromey, GCC Patches, GDB, Aaron Merey

On 2020-07-28 9:56 a.m., H.J. Lu wrote:
> On Tue, Jul 28, 2020 at 6:51 AM Andreas Schwab <schwab@linux-m68k.org> wrote:
>>
>> On Jul 28 2020, H.J. Lu via Binutils wrote:
>>
>>> On x86, the native GCC can support -m32 and -m64.  "gcc -m32" or "gcc -m64"
>>>  are not cross compiling.
>>
>> You cannot link -m64 and -m32 together.
>>
>>> I didn't set PKG_CONFIG_LIBDIR and I don't want to set it.
>>
>> Then use the correct pkg-config for your target.  If you think
>> pkg-config is broken, then fix _that_.
>>
> 
> I did:
> 
> RUNTESTFLAGS="--target_board 'unix{-m32}'" CC="gcc -m32 -fno-lto
> -fcf-protection"
>  CXX="g++ -fno-lto -m32 -fcf-protection" /exp
> ort/gnu/import/git/gitlab/x86-binutils/configure \
> --enable-targets=x86_64-linux \
> i686-linux \
> --enable-plugins --disable-gdb --disable-gdbserver --disable-libdecnumbe
> r --disable-readline --disable-sim --with-sysroot=/ --with-system-zlib \
> --prefix=/usr/local \
> --with-local-prefix=/usr/local
> configure: WARNING: you should use --build, --host, --target
> checking build system type... i686-pc-linux-gnu
> checking host system type... i686-pc-linux-gnu
> checking target system type... i686-pc-linux-gnu

So... is your build system a 32-bit one?  Why does the above say i686-pc-linux-gnu
and not x86_64-something?

Simon

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: V2 [PATCH] PKG_CHECK_MODULES: Check if $pkg_cv_[]$1[]_LIBS works
  2020-07-28 14:01                                     ` Simon Marchi
@ 2020-07-28 14:11                                       ` H.J. Lu
  2020-07-28 14:34                                         ` Simon Marchi
  2020-07-28 14:54                                         ` Andreas Schwab
  0 siblings, 2 replies; 37+ messages in thread
From: H.J. Lu @ 2020-07-28 14:11 UTC (permalink / raw)
  To: Simon Marchi
  Cc: Andreas Schwab, H.J. Lu via Binutils, Tom Tromey, GCC Patches,
	GDB, Aaron Merey

On Tue, Jul 28, 2020 at 7:01 AM Simon Marchi <simark@simark.ca> wrote:
>
> On 2020-07-28 9:56 a.m., H.J. Lu wrote:
> > On Tue, Jul 28, 2020 at 6:51 AM Andreas Schwab <schwab@linux-m68k.org> wrote:
> >>
> >> On Jul 28 2020, H.J. Lu via Binutils wrote:
> >>
> >>> On x86, the native GCC can support -m32 and -m64.  "gcc -m32" or "gcc -m64"
> >>>  are not cross compiling.
> >>
> >> You cannot link -m64 and -m32 together.
> >>
> >>> I didn't set PKG_CONFIG_LIBDIR and I don't want to set it.
> >>
> >> Then use the correct pkg-config for your target.  If you think
> >> pkg-config is broken, then fix _that_.
> >>
> >
> > I did:
> >
> > RUNTESTFLAGS="--target_board 'unix{-m32}'" CC="gcc -m32 -fno-lto
> > -fcf-protection"
> >  CXX="g++ -fno-lto -m32 -fcf-protection" /exp
> > ort/gnu/import/git/gitlab/x86-binutils/configure \
> > --enable-targets=x86_64-linux \
> > i686-linux \
> > --enable-plugins --disable-gdb --disable-gdbserver --disable-libdecnumbe
> > r --disable-readline --disable-sim --with-sysroot=/ --with-system-zlib \
> > --prefix=/usr/local \
> > --with-local-prefix=/usr/local
> > configure: WARNING: you should use --build, --host, --target
> > checking build system type... i686-pc-linux-gnu
> > checking host system type... i686-pc-linux-gnu
> > checking target system type... i686-pc-linux-gnu
>
> So... is your build system a 32-bit one?  Why does the above say i686-pc-linux-gnu
> and not x86_64-something?
>

My system supports both -m32 and -m64.  Depending on CC, configure
selects i686 or x86-64 target.

-- 
H.J.

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: V2 [PATCH] PKG_CHECK_MODULES: Check if $pkg_cv_[]$1[]_LIBS works
  2020-07-28 14:11                                       ` H.J. Lu
@ 2020-07-28 14:34                                         ` Simon Marchi
  2020-07-28 15:05                                           ` H.J. Lu
  2020-07-28 14:54                                         ` Andreas Schwab
  1 sibling, 1 reply; 37+ messages in thread
From: Simon Marchi @ 2020-07-28 14:34 UTC (permalink / raw)
  To: H.J. Lu
  Cc: Andreas Schwab, H.J. Lu via Binutils, Tom Tromey, GCC Patches,
	GDB, Aaron Merey

On 2020-07-28 10:11 a.m., H.J. Lu wrote:
> On Tue, Jul 28, 2020 at 7:01 AM Simon Marchi <simark@simark.ca> wrote:
>>
>> On 2020-07-28 9:56 a.m., H.J. Lu wrote:
>>> On Tue, Jul 28, 2020 at 6:51 AM Andreas Schwab <schwab@linux-m68k.org> wrote:
>>>>
>>>> On Jul 28 2020, H.J. Lu via Binutils wrote:
>>>>
>>>>> On x86, the native GCC can support -m32 and -m64.  "gcc -m32" or "gcc -m64"
>>>>>  are not cross compiling.
>>>>
>>>> You cannot link -m64 and -m32 together.
>>>>
>>>>> I didn't set PKG_CONFIG_LIBDIR and I don't want to set it.
>>>>
>>>> Then use the correct pkg-config for your target.  If you think
>>>> pkg-config is broken, then fix _that_.
>>>>
>>>
>>> I did:
>>>
>>> RUNTESTFLAGS="--target_board 'unix{-m32}'" CC="gcc -m32 -fno-lto
>>> -fcf-protection"
>>>  CXX="g++ -fno-lto -m32 -fcf-protection" /exp
>>> ort/gnu/import/git/gitlab/x86-binutils/configure \
>>> --enable-targets=x86_64-linux \
>>> i686-linux \
>>> --enable-plugins --disable-gdb --disable-gdbserver --disable-libdecnumbe
>>> r --disable-readline --disable-sim --with-sysroot=/ --with-system-zlib \
>>> --prefix=/usr/local \
>>> --with-local-prefix=/usr/local
>>> configure: WARNING: you should use --build, --host, --target
>>> checking build system type... i686-pc-linux-gnu
>>> checking host system type... i686-pc-linux-gnu
>>> checking target system type... i686-pc-linux-gnu
>>
>> So... is your build system a 32-bit one?  Why does the above say i686-pc-linux-gnu
>> and not x86_64-something?
>>
> 
> My system supports both -m32 and -m64.  Depending on CC, configure
> selects i686 or x86-64 target.

Can you clarify how this magic works, is this standard autoconf?  Because I am trying this
on Fedora, so pretty much the same setup as you, and I don't see this behavior:

$ /home/simark/src/binutils-gdb/configure CC="gcc -m32" CXX="g++ -m32"
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
...


And even if it worked, why would it set "build" to i686, it doesn't make sense.  The gcc you
compile with, and its environment, is still x86_64, not i686.

So *if* it works, it would be a shortcut for setting --host=i686-something, maybe.  So
regardless of how that above works, that doesn't remove the need to configure pkg-config
correctly for the host system.

If you don't want to learn about with pkg-config and deal with it, then please say "I think
we should not use pkg-config", and ideally give supporting points.  Please don't unilaterally
push patches just to paper over your own problems.  You just make it so that somebody will
need to untangle more mess later.

Simon

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: V2 [PATCH] PKG_CHECK_MODULES: Check if $pkg_cv_[]$1[]_LIBS works
  2020-07-28 14:11                                       ` H.J. Lu
  2020-07-28 14:34                                         ` Simon Marchi
@ 2020-07-28 14:54                                         ` Andreas Schwab
  1 sibling, 0 replies; 37+ messages in thread
From: Andreas Schwab @ 2020-07-28 14:54 UTC (permalink / raw)
  To: H.J. Lu
  Cc: Simon Marchi, H.J. Lu via Binutils, Tom Tromey, GCC Patches, GDB,
	Aaron Merey

On Jul 28 2020, H.J. Lu wrote:

> My system supports both -m32 and -m64.

My system also supports m68k.  That doesn't make it "native".

$ file hello.m68k 
hello.m68k: ELF 32-bit MSB executable, Motorola m68k, 68020, version 1 (SYSV), dynamically linked, interpreter /lib/ld., for GNU/Linux 2.6.32, BuildID[sha1]=becec3e5b8309f88c861d0a1725586cbdc5ecfc9, with debug_info, not stripped
$ ./hello.m68k
Hello World!

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: V2 [PATCH] PKG_CHECK_MODULES: Check if $pkg_cv_[]$1[]_LIBS works
  2020-07-28 14:34                                         ` Simon Marchi
@ 2020-07-28 15:05                                           ` H.J. Lu
  2020-07-28 15:13                                             ` Simon Marchi
  0 siblings, 1 reply; 37+ messages in thread
From: H.J. Lu @ 2020-07-28 15:05 UTC (permalink / raw)
  To: Simon Marchi
  Cc: Andreas Schwab, H.J. Lu via Binutils, Tom Tromey, GCC Patches,
	GDB, Aaron Merey

On Tue, Jul 28, 2020 at 7:34 AM Simon Marchi <simark@simark.ca> wrote:
>
> On 2020-07-28 10:11 a.m., H.J. Lu wrote:
> > On Tue, Jul 28, 2020 at 7:01 AM Simon Marchi <simark@simark.ca> wrote:
> >>
> >> On 2020-07-28 9:56 a.m., H.J. Lu wrote:
> >>> On Tue, Jul 28, 2020 at 6:51 AM Andreas Schwab <schwab@linux-m68k.org> wrote:
> >>>>
> >>>> On Jul 28 2020, H.J. Lu via Binutils wrote:
> >>>>
> >>>>> On x86, the native GCC can support -m32 and -m64.  "gcc -m32" or "gcc -m64"
> >>>>>  are not cross compiling.
> >>>>
> >>>> You cannot link -m64 and -m32 together.
> >>>>
> >>>>> I didn't set PKG_CONFIG_LIBDIR and I don't want to set it.
> >>>>
> >>>> Then use the correct pkg-config for your target.  If you think
> >>>> pkg-config is broken, then fix _that_.
> >>>>
> >>>
> >>> I did:
> >>>
> >>> RUNTESTFLAGS="--target_board 'unix{-m32}'" CC="gcc -m32 -fno-lto
> >>> -fcf-protection"
> >>>  CXX="g++ -fno-lto -m32 -fcf-protection" /exp
> >>> ort/gnu/import/git/gitlab/x86-binutils/configure \
> >>> --enable-targets=x86_64-linux \
> >>> i686-linux \
> >>> --enable-plugins --disable-gdb --disable-gdbserver --disable-libdecnumbe
> >>> r --disable-readline --disable-sim --with-sysroot=/ --with-system-zlib \
> >>> --prefix=/usr/local \
> >>> --with-local-prefix=/usr/local
> >>> configure: WARNING: you should use --build, --host, --target
> >>> checking build system type... i686-pc-linux-gnu
> >>> checking host system type... i686-pc-linux-gnu
> >>> checking target system type... i686-pc-linux-gnu
> >>
> >> So... is your build system a 32-bit one?  Why does the above say i686-pc-linux-gnu
> >> and not x86_64-something?
> >>
> >
> > My system supports both -m32 and -m64.  Depending on CC, configure
> > selects i686 or x86-64 target.
>
> Can you clarify how this magic works, is this standard autoconf?  Because I am trying this
> on Fedora, so pretty much the same setup as you, and I don't see this behavior:
>
> $ /home/simark/src/binutils-gdb/configure CC="gcc -m32" CXX="g++ -m32"
> checking build system type... x86_64-pc-linux-gnu
> checking host system type... x86_64-pc-linux-gnu
> checking target system type... x86_64-pc-linux-gnu
> ...
>

I checked it again.  I also passed i686-linux, not  --host=,  to configure.

>
> And even if it worked, why would it set "build" to i686, it doesn't make sense.  The gcc you
> compile with, and its environment, is still x86_64, not i686.
>
> So *if* it works, it would be a shortcut for setting --host=i686-something, maybe.  So
> regardless of how that above works, that doesn't remove the need to configure pkg-config
> correctly for the host system.
>
> If you don't want to learn about with pkg-config and deal with it, then please say "I think
> we should not use pkg-config", and ideally give supporting points.  Please don't unilaterally
> push patches just to paper over your own problems.  You just make it so that somebody will
> need to untangle more mess later.

I am OK to remove pkg.m4.

-- 
H.J.

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: V2 [PATCH] PKG_CHECK_MODULES: Check if $pkg_cv_[]$1[]_LIBS works
  2020-07-28 15:05                                           ` H.J. Lu
@ 2020-07-28 15:13                                             ` Simon Marchi
  2020-07-28 16:07                                               ` H.J. Lu
  0 siblings, 1 reply; 37+ messages in thread
From: Simon Marchi @ 2020-07-28 15:13 UTC (permalink / raw)
  To: H.J. Lu
  Cc: GCC Patches, H.J. Lu via Binutils, Aaron Merey, Andreas Schwab,
	Tom Tromey, GDB

On 2020-07-28 11:05 a.m., H.J. Lu via Gdb-patches wrote:
>> Can you clarify how this magic works, is this standard autoconf?  Because I am trying this
>> on Fedora, so pretty much the same setup as you, and I don't see this behavior:
>>
>> $ /home/simark/src/binutils-gdb/configure CC="gcc -m32" CXX="g++ -m32"
>> checking build system type... x86_64-pc-linux-gnu
>> checking host system type... x86_64-pc-linux-gnu
>> checking target system type... x86_64-pc-linux-gnu
>> ...
>>
> 
> I checked it again.  I also passed i686-linux, not  --host=,  to configure.

Ok I see, the configure line you pasted was wrapped by your email client so was not very readable.

Doing `./configure <triplet>` looks like a deprecated way to set all build/host/target, as the
warning message it shows implies:

  configure: WARNING: you should use --build, --host, --target

Anyway, my point still stands: the problem is you not using a pkg-config configured properly for
the cross compilation you are attempting, not pkg.m4.

>>
>> And even if it worked, why would it set "build" to i686, it doesn't make sense.  The gcc you
>> compile with, and its environment, is still x86_64, not i686.
>>
>> So *if* it works, it would be a shortcut for setting --host=i686-something, maybe.  So
>> regardless of how that above works, that doesn't remove the need to configure pkg-config
>> correctly for the host system.
>>
>> If you don't want to learn about with pkg-config and deal with it, then please say "I think
>> we should not use pkg-config", and ideally give supporting points.  Please don't unilaterally
>> push patches just to paper over your own problems.  You just make it so that somebody will
>> need to untangle more mess later.
> 
> I am OK to remove pkg.m4.

Well I am not.  I find it quite handy to avoid having to hardcode necessary CFLAGS and LDFLAGS
required to build against a library, so I think it's better to use pkg-config if the libraries
we want to use provide a .pc file.

I propose that we revert the patch for now to go back to the pristing pkg.m4 version.

Simon

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: V2 [PATCH] PKG_CHECK_MODULES: Check if $pkg_cv_[]$1[]_LIBS works
  2020-07-28 15:13                                             ` Simon Marchi
@ 2020-07-28 16:07                                               ` H.J. Lu
  2020-07-28 16:28                                                 ` Simon Marchi
  0 siblings, 1 reply; 37+ messages in thread
From: H.J. Lu @ 2020-07-28 16:07 UTC (permalink / raw)
  To: Simon Marchi
  Cc: GCC Patches, H.J. Lu via Binutils, Aaron Merey, Andreas Schwab,
	Tom Tromey, GDB

On Tue, Jul 28, 2020 at 8:13 AM Simon Marchi <simark@simark.ca> wrote:
>
> On 2020-07-28 11:05 a.m., H.J. Lu via Gdb-patches wrote:
> >> Can you clarify how this magic works, is this standard autoconf?  Because I am trying this
> >> on Fedora, so pretty much the same setup as you, and I don't see this behavior:
> >>
> >> $ /home/simark/src/binutils-gdb/configure CC="gcc -m32" CXX="g++ -m32"
> >> checking build system type... x86_64-pc-linux-gnu
> >> checking host system type... x86_64-pc-linux-gnu
> >> checking target system type... x86_64-pc-linux-gnu
> >> ...
> >>
> >
> > I checked it again.  I also passed i686-linux, not  --host=,  to configure.
>
> Ok I see, the configure line you pasted was wrapped by your email client so was not very readable.
>
> Doing `./configure <triplet>` looks like a deprecated way to set all build/host/target, as the
> warning message it shows implies:
>
>   configure: WARNING: you should use --build, --host, --target
>
> Anyway, my point still stands: the problem is you not using a pkg-config configured properly for
> the cross compilation you are attempting, not pkg.m4.
>
> >>
> >> And even if it worked, why would it set "build" to i686, it doesn't make sense.  The gcc you
> >> compile with, and its environment, is still x86_64, not i686.
> >>
> >> So *if* it works, it would be a shortcut for setting --host=i686-something, maybe.  So
> >> regardless of how that above works, that doesn't remove the need to configure pkg-config
> >> correctly for the host system.
> >>
> >> If you don't want to learn about with pkg-config and deal with it, then please say "I think
> >> we should not use pkg-config", and ideally give supporting points.  Please don't unilaterally
> >> push patches just to paper over your own problems.  You just make it so that somebody will
> >> need to untangle more mess later.
> >
> > I am OK to remove pkg.m4.
>
> Well I am not.  I find it quite handy to avoid having to hardcode necessary CFLAGS and LDFLAGS
> required to build against a library, so I think it's better to use pkg-config if the libraries
> we want to use provide a .pc file.
>
> I propose that we revert the patch for now to go back to the pristing pkg.m4 version.
>

What doesn't work with my pkg.m4 change?


-- 
H.J.

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: V2 [PATCH] PKG_CHECK_MODULES: Check if $pkg_cv_[]$1[]_LIBS works
  2020-07-28 16:07                                               ` H.J. Lu
@ 2020-07-28 16:28                                                 ` Simon Marchi
  2020-07-28 17:26                                                   ` H.J. Lu
  0 siblings, 1 reply; 37+ messages in thread
From: Simon Marchi @ 2020-07-28 16:28 UTC (permalink / raw)
  To: H.J. Lu
  Cc: Andreas Schwab, H.J. Lu via Binutils, Aaron Merey, GCC Patches,
	Tom Tromey, GDB

On 2020-07-28 12:07 p.m., H.J. Lu via Gdb-patches wrote:
> What doesn't work with my pkg.m4 change?

(1) It deviates from upstream.  I don't think we should do this unless
    absolutely needed.  That's not the case here, the change is just there
    because you don't want to set up pkg-config properly for cross-compiling.

(2) I don't think it's necessarily bad to try to do a link to confirm the lib
    is indeed there, but as I said earlier I don't think that doing as if the
    package was not there is the right response.  This can happen if you have
    a mis-configured pkg-config (like you have) or a broken installation (for
    example, the .pc is there but the lib is not).  In either case, there's
    something wrong with the build environment and I think it's more useful
    to abort and tell the user rather than silently failing.

Point 2 should be discussed upstream anyway, there's no point making a decision
local to binutils-gdb.

Simon


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: V2 [PATCH] PKG_CHECK_MODULES: Check if $pkg_cv_[]$1[]_LIBS works
  2020-07-28 16:28                                                 ` Simon Marchi
@ 2020-07-28 17:26                                                   ` H.J. Lu
  2020-07-28 17:43                                                     ` Simon Marchi
  0 siblings, 1 reply; 37+ messages in thread
From: H.J. Lu @ 2020-07-28 17:26 UTC (permalink / raw)
  To: Simon Marchi
  Cc: Andreas Schwab, H.J. Lu via Binutils, Aaron Merey, GCC Patches,
	Tom Tromey, GDB

On Tue, Jul 28, 2020 at 9:28 AM Simon Marchi <simark@simark.ca> wrote:
>
> On 2020-07-28 12:07 p.m., H.J. Lu via Gdb-patches wrote:
> > What doesn't work with my pkg.m4 change?
>
> (1) It deviates from upstream.  I don't think we should do this unless
>     absolutely needed.  That's not the case here, the change is just there
>     because you don't want to set up pkg-config properly for cross-compiling.

Since when binutils can't fix issues in other packages?

> (2) I don't think it's necessarily bad to try to do a link to confirm the lib
>     is indeed there, but as I said earlier I don't think that doing as if the
>     package was not there is the right response.  This can happen if you have
>     a mis-configured pkg-config (like you have) or a broken installation (for
>     example, the .pc is there but the lib is not).  In either case, there's
>     something wrong with the build environment and I think it's more useful
>     to abort and tell the user rather than silently failing.
>
> Point 2 should be discussed upstream anyway, there's no point making a decision
> local to binutils-gdb.
>

Unlike gdb, binutils should have as few external depecies as possible.
debuginfod brings in some so many external depecies.

--
H.J.

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: V2 [PATCH] PKG_CHECK_MODULES: Check if $pkg_cv_[]$1[]_LIBS works
  2020-07-28 17:26                                                   ` H.J. Lu
@ 2020-07-28 17:43                                                     ` Simon Marchi
  2020-07-28 18:31                                                       ` H.J. Lu
  0 siblings, 1 reply; 37+ messages in thread
From: Simon Marchi @ 2020-07-28 17:43 UTC (permalink / raw)
  To: H.J. Lu
  Cc: Andreas Schwab, H.J. Lu via Binutils, Aaron Merey, GCC Patches,
	Tom Tromey, GDB

On 2020-07-28 1:26 p.m., H.J. Lu wrote:
> On Tue, Jul 28, 2020 at 9:28 AM Simon Marchi <simark@simark.ca> wrote:
>>
>> On 2020-07-28 12:07 p.m., H.J. Lu via Gdb-patches wrote:
>>> What doesn't work with my pkg.m4 change?
>>
>> (1) It deviates from upstream.  I don't think we should do this unless
>>     absolutely needed.  That's not the case here, the change is just there
>>     because you don't want to set up pkg-config properly for cross-compiling.
> 
> Since when binutils can't fix issues in other packages?

Like I said, we can make local changes if necessary, to fix issues.  But there is
no issue to fix here, all is needed is to have a proper build environment.

Doing an unnecessary local change just adds burden on the next person who
will sync this file with upstream, so it should not be taken lightly.
> Unlike gdb, binutils should have as few external depecies as possible.
> debuginfod brings in some so many external depecies.

I'm not a binutils maintainer, so that's not my role to decide about that
tradeoff... but we are talking about having an optional (only needed when
enabling support for libdebuginfod) *build* dependency on a quite standard
tool.  That's not very demanding.

If you don't want to deal with libdebuginfod, you can also just build with
--without-debuginfod.

Simon

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: V2 [PATCH] PKG_CHECK_MODULES: Check if $pkg_cv_[]$1[]_LIBS works
  2020-07-28 17:43                                                     ` Simon Marchi
@ 2020-07-28 18:31                                                       ` H.J. Lu
  2020-07-28 18:47                                                         ` Simon Marchi
  0 siblings, 1 reply; 37+ messages in thread
From: H.J. Lu @ 2020-07-28 18:31 UTC (permalink / raw)
  To: Simon Marchi
  Cc: Andreas Schwab, H.J. Lu via Binutils, Aaron Merey, GCC Patches,
	Tom Tromey, GDB

On Tue, Jul 28, 2020 at 10:43 AM Simon Marchi <simark@simark.ca> wrote:
>
> On 2020-07-28 1:26 p.m., H.J. Lu wrote:
> > On Tue, Jul 28, 2020 at 9:28 AM Simon Marchi <simark@simark.ca> wrote:
> >>
> >> On 2020-07-28 12:07 p.m., H.J. Lu via Gdb-patches wrote:
> >>> What doesn't work with my pkg.m4 change?
> >>
> >> (1) It deviates from upstream.  I don't think we should do this unless
> >>     absolutely needed.  That's not the case here, the change is just there
> >>     because you don't want to set up pkg-config properly for cross-compiling.
> >
> > Since when binutils can't fix issues in other packages?
>
> Like I said, we can make local changes if necessary, to fix issues.  But there is
> no issue to fix here, all is needed is to have a proper build environment.
>
> Doing an unnecessary local change just adds burden on the next person who
> will sync this file with upstream, so it should not be taken lightly.

I have submitted a merge request to fix it upstream.

> > Unlike gdb, binutils should have as few external depecies as possible.
> > debuginfod brings in some so many external depecies.
>
> I'm not a binutils maintainer, so that's not my role to decide about that
> tradeoff... but we are talking about having an optional (only needed when
> enabling support for libdebuginfod) *build* dependency on a quite standard
> tool.  That's not very demanding.
>
> If you don't want to deal with libdebuginfod, you can also just build with
> --without-debuginfod.

My binutils script had been working fine until pkg.m4 was added.  Can it
be moved to gdb directory?

-- 
H.J.

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: V2 [PATCH] PKG_CHECK_MODULES: Check if $pkg_cv_[]$1[]_LIBS works
  2020-07-28 18:31                                                       ` H.J. Lu
@ 2020-07-28 18:47                                                         ` Simon Marchi
  2020-07-28 18:57                                                           ` H.J. Lu
  0 siblings, 1 reply; 37+ messages in thread
From: Simon Marchi @ 2020-07-28 18:47 UTC (permalink / raw)
  To: H.J. Lu
  Cc: Andreas Schwab, H.J. Lu via Binutils, Aaron Merey, GCC Patches,
	Tom Tromey, GDB

On 2020-07-28 2:31 p.m., H.J. Lu wrote:
>>> Unlike gdb, binutils should have as few external depecies as possible.
>>> debuginfod brings in some so many external depecies.
>>
>> I'm not a binutils maintainer, so that's not my role to decide about that
>> tradeoff... but we are talking about having an optional (only needed when
>> enabling support for libdebuginfod) *build* dependency on a quite standard
>> tool.  That's not very demanding.
>>
>> If you don't want to deal with libdebuginfod, you can also just build with
>> --without-debuginfod.
> 
> My binutils script had been working fine until pkg.m4 was added

Ok but... that doesn't mean anything.  I think we made it quite clear that the
issue is with your build environment, not the build system (pkg.m4).

>Can it be moved to gdb directory?

It can, but I don't think it would be a good idea.  It would just be confusing
for binutils and GDB to both use libdebuginfod but use different methods of
finding it.  Somebody building binutils + GDB with libdebuginfod support against
a libdebuginfod in a non-default location would have to specify the location of
the library in two different ways.

Simon

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: V2 [PATCH] PKG_CHECK_MODULES: Check if $pkg_cv_[]$1[]_LIBS works
  2020-07-28 18:47                                                         ` Simon Marchi
@ 2020-07-28 18:57                                                           ` H.J. Lu
  0 siblings, 0 replies; 37+ messages in thread
From: H.J. Lu @ 2020-07-28 18:57 UTC (permalink / raw)
  To: Simon Marchi
  Cc: Andreas Schwab, H.J. Lu via Binutils, Aaron Merey, GCC Patches,
	Tom Tromey, GDB

On Tue, Jul 28, 2020 at 11:47 AM Simon Marchi <simark@simark.ca> wrote:
>
> On 2020-07-28 2:31 p.m., H.J. Lu wrote:
> >>> Unlike gdb, binutils should have as few external depecies as possible.
> >>> debuginfod brings in some so many external depecies.
> >>
> >> I'm not a binutils maintainer, so that's not my role to decide about that
> >> tradeoff... but we are talking about having an optional (only needed when
> >> enabling support for libdebuginfod) *build* dependency on a quite standard
> >> tool.  That's not very demanding.
> >>
> >> If you don't want to deal with libdebuginfod, you can also just build with
> >> --without-debuginfod.
> >
> > My binutils script had been working fine until pkg.m4 was added
>
> Ok but... that doesn't mean anything.  I think we made it quite clear that the
> issue is with your build environment, not the build system (pkg.m4).

Binutils configure script is supposed to detect if a feature is usable.
In my perspective, pkg.m4 failed on my build environment.

> >Can it be moved to gdb directory?
>
> It can, but I don't think it would be a good idea.  It would just be confusing
> for binutils and GDB to both use libdebuginfod but use different methods of
> finding it.  Somebody building binutils + GDB with libdebuginfod support against
> a libdebuginfod in a non-default location would have to specify the location of
> the library in two different ways.
>
> Simon



-- 
H.J.

^ permalink raw reply	[flat|nested] 37+ messages in thread

end of thread, other threads:[~2020-07-28 18:57 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-02  2:29 [PATCH] config/debuginfod.m4: Use PKG_CHECK_MODULES Aaron Merey
2020-05-05 16:41 ` Jeff Law
2020-05-05 21:23   ` Aaron Merey
2020-05-08 20:56     ` Tom Tromey
2020-07-16 22:17       ` Aaron Merey
2020-07-16 22:37       ` Aaron Merey
2020-07-19 15:43         ` Simon Marchi
2020-07-21 15:20           ` Tom Tromey
2020-07-21 18:11             ` Aaron Merey
2020-07-24 20:03               ` Aaron Merey
2020-07-25 16:01                 ` H.J. Lu
2020-07-27 15:31                   ` [PATCH] config/debuginfod.m4: Restore AC_CHECK_LIB check H.J. Lu
2020-07-27 16:11                     ` Aaron Merey
2020-07-27 19:14                       ` [PATCH] PKG_CHECK_MODULES: Check if $pkg_cv_[]$1[]_LIBS works H.J. Lu
2020-07-27 19:32                         ` V2 " H.J. Lu
2020-07-28 10:45                           ` H.J. Lu
2020-07-28 12:46                             ` Simon Marchi
2020-07-28 13:33                               ` H.J. Lu
2020-07-28 13:51                                 ` Andreas Schwab
2020-07-28 13:56                                   ` H.J. Lu
2020-07-28 14:01                                     ` Simon Marchi
2020-07-28 14:11                                       ` H.J. Lu
2020-07-28 14:34                                         ` Simon Marchi
2020-07-28 15:05                                           ` H.J. Lu
2020-07-28 15:13                                             ` Simon Marchi
2020-07-28 16:07                                               ` H.J. Lu
2020-07-28 16:28                                                 ` Simon Marchi
2020-07-28 17:26                                                   ` H.J. Lu
2020-07-28 17:43                                                     ` Simon Marchi
2020-07-28 18:31                                                       ` H.J. Lu
2020-07-28 18:47                                                         ` Simon Marchi
2020-07-28 18:57                                                           ` H.J. Lu
2020-07-28 14:54                                         ` Andreas Schwab
2020-07-28 13:53                                 ` H.J. Lu
2020-07-28 13:54                                 ` Simon Marchi
2020-07-28 12:54                           ` Mark Wielaard
2020-07-28 13:27                             ` [PATCH] PKG_CHECK_MODULES: Properly check " H.J. Lu

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).