[v2,0/6] Move gdbsupport to top level

Message ID 78d5599b-9773-954f-ea06-86f65a1c6842@redhat.com
State New, archived
Headers

Commit Message

Pedro Alves Jan. 16, 2020, 2:29 p.m. UTC
  On 1/16/20 4:23 AM, Simon Marchi wrote:
> On 2020-01-15 4:35 p.m., Pedro Alves wrote:
>> Here's an improved version, which fixes gdbserver's standalone
>> build, simplifies gdbsupport's config.h (there's no need for
>> #ifdef GDBSERVER stuff since gdbserver doesn't use gdbsupport 
>> as a library yet), and adds copyright/intro comments.
> 
> I have to admit I'm a bit lost in the spaghetti of config.h inclusion.  I don't
> understand, for example, why GDB needs to include gdbsupport's config.  All the
> features that GDB needs are checked by its own configure script, aren't they?

Good question.  I guess the idea is that instead of having all of gdb, gdbserver,
and gdbsupport share tests via gdbsupport/common.m4, having run them more
than once, we can run the tests only once by gdbsupport's configure, and then
include the support-config.h file.

I've given this another thought, and went through the process of thinking
that this more complicated patch isn't really necessary, and then concluded
that having it makes things more normalized between all the dirs.  But
we can simplify it -- don't need to generate the "trampoline" config.h.

My initial thought that led to the more complicated patch was to make
sure that that "#include <config.h>" in gnulib's libc-config.h picks up
gnulib config.h.  But it's really harmless if that picks some other config.h
instead as long as we're sure that the gnulib config.h is also included
somehow.  Which we are sure of, from the fact that common-defs.h
is always included as first thing in every .c file.

So while we're building gdbsupport, we don't have any config.h in the
include path other than the BFD one, and we hit the problem.  We could
add an empty gdbsupport/config/config.h file in the
source and add -Igdbsupport/config/ to gdbsupport's Makefile, or,
add gnulib's build dir to the include path, like in my original patch.

So the original solution of adding the gnulib dir to the include path
isn't that bad, though I call it a hack.

The gdbsupport/config/config.h approach is pedantically less of a hack
and more in line with the "solution" that we happen to have in gdb
and gdbserver's dirs currently, by chance.

OK, so I tried that.  And then, I realized, well, if we have that
new config.h file, then we could as well move the gnulib config.h inclusion
to that file, like I was doing in the complicated patch.  Essentially
it's the same as the complicated patch, except the "trampoline" config.h
isn't generated in the build dir, but instead is put in the source tree.
We'd do the same to gdb and gdbserver, for consistency.

(I actually named the new dirs "config.h", as there's already a config
dir under gdb.  It's more to the point, anyway.)

> 
> I noticed that build/gdb/config.h doesn't get automatically regenerated from
> src/gdb/config.in whenever the latter changes.  It could use a Makefile rule that
> uses config.status to re-generate it, like there is for some other files.

Indeed.  I also noticed that I missed regenerating gdbsupport/Makefile.in ...

> 
> There's also the variable "generated_files" in the Makefile, should gdb-support.h
> be in there?

Yeah, I guess so.

> The gdb-config.h above should be gdbserver-config.h.
Here's v2.  WDYT?  Which of all the approaches discussed would
you prefer?

(If we go this route, I should probably generalize the intro comments
a bit so that the multiple versions have the exact same comment.)

From a50c9d27d8aba77bc3cf619fc029776ea8658dbf Mon Sep 17 00:00:00 2001
From: Pedro Alves <palves@redhat.com>
Date: Wed, 15 Jan 2020 17:49:01 +0000
Subject: [PATCH v2] config.h

---
 gdb/Makefile.in                                  |  9 +--
 gdb/config.h/config.h                            | 40 +++++++++++
 gdb/configure                                    |  6 +-
 gdb/configure.ac                                 |  2 +-
 gdb/{config.in => gdb-config.in}                 |  0
 gdb/gdbserver/Makefile.in                        |  2 +-
 gdb/gdbserver/config.h/config.h                  | 32 +++++++++
 gdb/gdbserver/configure                          |  6 +-
 gdb/gdbserver/configure.ac                       |  2 +-
 gdb/gdbserver/{config.in => gdbserver-config.in} |  0
 gdb/unittests/scoped_fd-selftests.c              |  1 -
 gdb/unittests/scoped_mmap-selftests.c            |  1 -
 gdbsupport/Makefile.am                           |  2 +-
 gdbsupport/Makefile.in                           |  8 +--
 gdbsupport/common-defs.h                         | 24 -------
 gdbsupport/config.h/config.h                     | 32 +++++++++
 gdbsupport/configure                             | 92 ++++++++++++------------
 gdbsupport/configure.ac                          |  2 +-
 gdbsupport/{config.in => support-config.in}      |  0
 19 files changed, 170 insertions(+), 91 deletions(-)
 create mode 100644 gdb/config.h/config.h
 rename gdb/{config.in => gdb-config.in} (100%)
 create mode 100644 gdb/gdbserver/config.h/config.h
 rename gdb/gdbserver/{config.in => gdbserver-config.in} (100%)
 create mode 100644 gdbsupport/config.h/config.h
 rename gdbsupport/{config.in => support-config.in} (100%)


base-commit: aad09917e04b33da463f1703aab8d057cfe3f54e
  

Comments

Simon Marchi Jan. 17, 2020, 11:54 a.m. UTC | #1
On 2020-01-16 9:29 a.m., Pedro Alves wrote:
> On 1/16/20 4:23 AM, Simon Marchi wrote:
>> On 2020-01-15 4:35 p.m., Pedro Alves wrote:
>>> Here's an improved version, which fixes gdbserver's standalone
>>> build, simplifies gdbsupport's config.h (there's no need for
>>> #ifdef GDBSERVER stuff since gdbserver doesn't use gdbsupport 
>>> as a library yet), and adds copyright/intro comments.
>>
>> I have to admit I'm a bit lost in the spaghetti of config.h inclusion.  I don't
>> understand, for example, why GDB needs to include gdbsupport's config.  All the
>> features that GDB needs are checked by its own configure script, aren't they?
> 
> Good question.  I guess the idea is that instead of having all of gdb, gdbserver,
> and gdbsupport share tests via gdbsupport/common.m4, having run them more
> than once, we can run the tests only once by gdbsupport's configure, and then
> include the support-config.h file.

Ok, but that's not what is done today, that's a possibility for the future, right?
common.m4 defines a macro used by all three configure scripts, so each configure
script ends up doing its own checks.

> 
> I've given this another thought, and went through the process of thinking
> that this more complicated patch isn't really necessary, and then concluded
> that having it makes things more normalized between all the dirs.  But
> we can simplify it -- don't need to generate the "trampoline" config.h.
> 
> My initial thought that led to the more complicated patch was to make
> sure that that "#include <config.h>" in gnulib's libc-config.h picks up
> gnulib config.h.  But it's really harmless if that picks some other config.h
> instead as long as we're sure that the gnulib config.h is also included
> somehow.  Which we are sure of, from the fact that common-defs.h
> is always included as first thing in every .c file.
> 
> So while we're building gdbsupport, we don't have any config.h in the
> include path other than the BFD one, and we hit the problem.  We could
> add an empty gdbsupport/config/config.h file in the
> source and add -Igdbsupport/config/ to gdbsupport's Makefile, or,
> add gnulib's build dir to the include path, like in my original patch.
> 
> So the original solution of adding the gnulib dir to the include path
> isn't that bad, though I call it a hack.

I would have to see it, but it sounds like the simplest solution.

> The gdbsupport/config/config.h approach is pedantically less of a hack
> and more in line with the "solution" that we happen to have in gdb
> and gdbserver's dirs currently, by chance.
> 
> OK, so I tried that.  And then, I realized, well, if we have that
> new config.h file, then we could as well move the gnulib config.h inclusion
> to that file, like I was doing in the complicated patch.  Essentially
> it's the same as the complicated patch, except the "trampoline" config.h
> isn't generated in the build dir, but instead is put in the source tree.
> We'd do the same to gdb and gdbserver, for consistency.
> 
> (I actually named the new dirs "config.h", as there's already a config
> dir under gdb.  It's more to the point, anyway.)

I think it's a bit confusing to have directories named "config.h", but not
really a big deal.

>> The gdb-config.h above should be gdbserver-config.h.
> Here's v2.  WDYT?  Which of all the approaches discussed would
> you prefer?

Probably the solution that involves the least files and indirections.  But
the one proposed in the latest patch is fine with me too.  It's set and
forget, once it builds again we won't think about it, at least until the
next time it breaks.

The buildbot is struggling with this (sending many breakage emails), so I
think you should choose one and push it.  Then we can cancel all the builds
on the master branch until that commit.

Simon
  

Patch

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 45d1586e85e..b5e973f4cf5 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -563,7 +563,7 @@  CONFIG_DEP_SUBDIR = $(addsuffix /$(DEPDIR),$(CONFIG_SRC_SUBDIR))
 # your system doesn't have fcntl.h in /usr/include (which is where it
 # should be according to Posix).
 DEFS = @DEFS@
-GDB_CFLAGS = -I. -I$(srcdir) -I$(srcdir)/config \
+GDB_CFLAGS = -I$(srcdir)/config.h -I. -I$(srcdir) -I$(srcdir)/config \
 	-DLOCALEDIR="\"$(localedir)\"" $(DEFS)
 
 # MH_CFLAGS, if defined, has host-dependent CFLAGS from the config directory.
@@ -1574,6 +1574,7 @@  DISTSTUFF = $(YYFILES)
 generated_files = \
 	ada-lex.c \
 	config.h \
+	gdb-config.h \
 	jit-reader.h \
 	$(NAT_GENERATED_FILES) \
 	$(NM_H)
@@ -1974,9 +1975,9 @@  gdb-gdb.py: $(srcdir)/gdb-gdb.py.in
 gdb-gdb.gdb: $(srcdir)/gdb-gdb.gdb.in
 	$(SHELL) config.status $@
 
-config.h: stamp-h ; @true
-stamp-h: $(srcdir)/config.in config.status
-	$(SHELL) config.status config.h
+gdb-config.h: stamp-h ; @true
+stamp-h: $(srcdir)/gdb-config.in config.status
+	$(SHELL) config.status gdb-config.h
 
 nm.h: stamp-nmh ; @true
 stamp-nmh: config.status
diff --git a/gdb/config.h/config.h b/gdb/config.h/config.h
new file mode 100644
index 00000000000..f0c6cda4e00
--- /dev/null
+++ b/gdb/config.h/config.h
@@ -0,0 +1,40 @@ 
+/* config.h for GDB, the GNU debugger.
+   Copyright (C) 2020 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* This file exists so that "#include <config.h>" in header files
+   (including gnulib headers), includes this file, which then includes
+   our real config.h (which is called gdb-config.h), along with
+   gnulib's config.h and gdbsupport's config.h.  */
+
+#include "gnulib/config.h"
+
+#undef PACKAGE_NAME
+#undef PACKAGE
+#undef PACKAGE_VERSION
+#undef PACKAGE_STRING
+#undef PACKAGE_TARNAME
+
+#include <gdbsupport/support-config.h>
+
+#undef PACKAGE_NAME
+#undef PACKAGE
+#undef PACKAGE_VERSION
+#undef PACKAGE_STRING
+#undef PACKAGE_TARNAME
+
+#include "gdb-config.h"
diff --git a/gdb/configure b/gdb/configure
index 72ffad8d37b..1f2f3ab5f6d 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -2945,7 +2945,7 @@  ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 
-ac_config_headers="$ac_config_headers config.h:config.in"
+ac_config_headers="$ac_config_headers gdb-config.h:gdb-config.in"
 
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5
@@ -19729,7 +19729,7 @@  cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 for ac_config_target in $ac_config_targets
 do
   case $ac_config_target in
-    "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;;
+    "gdb-config.h") CONFIG_HEADERS="$CONFIG_HEADERS gdb-config.h:gdb-config.in" ;;
     "depdir") CONFIG_COMMANDS="$CONFIG_COMMANDS depdir" ;;
     "jit-reader.h") CONFIG_FILES="$CONFIG_FILES jit-reader.h:jit-reader.in" ;;
     "nm.h") CONFIG_LINKS="$CONFIG_LINKS nm.h:$GDB_NM_FILE" ;;
@@ -20365,7 +20365,7 @@  $as_echo "$as_me: executing $ac_file commands" >&6;}
 
 
   case $ac_file$ac_mode in
-    "config.h":H) echo > stamp-h ;;
+    "gdb-config.h":H) echo > stamp-h ;;
     "depdir":C) $SHELL $ac_aux_dir/mkinstalldirs $DEPDIR ;;
     "nm.h":L) echo > stamp-nmh ;;
     "gcore":F) chmod +x gcore ;;
diff --git a/gdb/configure.ac b/gdb/configure.ac
index 0ca169101b3..6627693a85d 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -19,7 +19,7 @@  dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
 dnl Process this file with autoconf to produce a configure script.
 
 AC_INIT(main.c)
-AC_CONFIG_HEADERS(config.h:config.in, [echo > stamp-h])
+AC_CONFIG_HEADERS(gdb-config.h:gdb-config.in, [echo > stamp-h])
 AM_MAINTAINER_MODE
 
 # Set the 'development' global.
diff --git a/gdb/config.in b/gdb/gdb-config.in
similarity index 100%
rename from gdb/config.in
rename to gdb/gdb-config.in
diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in
index 38f30a02770..f53e6ef5737 100644
--- a/gdb/gdbserver/Makefile.in
+++ b/gdb/gdbserver/Makefile.in
@@ -120,7 +120,7 @@  INCSUPPORT = -I$(srcdir)/../.. -I../..
 # in those directories should be included with the subdirectory.
 # e.g.: "target/wait.h".
 #
-INCLUDE_CFLAGS = -I. -I${srcdir} \
+INCLUDE_CFLAGS = -I$(srcdir)/config.h -I. -I${srcdir} \
 	-I$(srcdir)/../regformats -I$(srcdir)/.. -I$(INCLUDE_DIR) \
 	$(INCGNU) $(INCSUPPORT)
 
diff --git a/gdb/gdbserver/config.h/config.h b/gdb/gdbserver/config.h/config.h
new file mode 100644
index 00000000000..ed4340eca3d
--- /dev/null
+++ b/gdb/gdbserver/config.h/config.h
@@ -0,0 +1,32 @@ 
+/* config.h for the remote server for GDB.
+   Copyright (C) 2020 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* This exists so that "#include <config.h>" in header files
+   (including gnulib headers), includes this file, which then includes
+   our real config.h (which is called gdbserver-config.h), along with
+   gnulib's config.h.  */
+
+#include <build-gnulib-gdbserver/config.h>
+
+#undef PACKAGE_NAME
+#undef PACKAGE
+#undef PACKAGE_VERSION
+#undef PACKAGE_STRING
+#undef PACKAGE_TARNAME
+
+#include "gdbserver-config.h"
diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure
index 0bdc2145098..f44c3661637 100755
--- a/gdb/gdbserver/configure
+++ b/gdb/gdbserver/configure
@@ -2695,7 +2695,7 @@  ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 
-ac_config_headers="$ac_config_headers config.h:config.in"
+ac_config_headers="$ac_config_headers gdbserver-config.h:gdbserver-config.in"
 
 
 
@@ -11438,7 +11438,7 @@  cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 for ac_config_target in $ac_config_targets
 do
   case $ac_config_target in
-    "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;;
+    "gdbserver-config.h") CONFIG_HEADERS="$CONFIG_HEADERS gdbserver-config.h:gdbserver-config.in" ;;
     "depdir") CONFIG_COMMANDS="$CONFIG_COMMANDS depdir" ;;
     "gdbdepdir") CONFIG_COMMANDS="$CONFIG_COMMANDS gdbdepdir" ;;
     "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
@@ -11997,7 +11997,7 @@  $as_echo "$as_me: executing $ac_file commands" >&6;}
 
 
   case $ac_file$ac_mode in
-    "config.h":H) echo > stamp-h ;;
+    "gdbserver-config.h":H) echo > stamp-h ;;
     "depdir":C) $SHELL $ac_aux_dir/mkinstalldirs $DEPDIR ;;
     "gdbdepdir":C)
   for subdir in ${CONFIG_SRC_SUBDIR}
diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac
index 969354308c7..ed6e3dacdd4 100644
--- a/gdb/gdbserver/configure.ac
+++ b/gdb/gdbserver/configure.ac
@@ -19,7 +19,7 @@  dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
 dnl Process this file with autoconf to produce a configure script.
 
 AC_INIT(server.c)
-AC_CONFIG_HEADERS(config.h:config.in, [echo > stamp-h])
+AC_CONFIG_HEADERS(gdbserver-config.h:gdbserver-config.in, [echo > stamp-h])
 
 AM_MAINTAINER_MODE
 
diff --git a/gdb/gdbserver/config.in b/gdb/gdbserver/gdbserver-config.in
similarity index 100%
rename from gdb/gdbserver/config.in
rename to gdb/gdbserver/gdbserver-config.in
diff --git a/gdb/unittests/scoped_fd-selftests.c b/gdb/unittests/scoped_fd-selftests.c
index 3f024764245..96ca9bf7f63 100644
--- a/gdb/unittests/scoped_fd-selftests.c
+++ b/gdb/unittests/scoped_fd-selftests.c
@@ -21,7 +21,6 @@ 
 
 #include "gdbsupport/filestuff.h"
 #include "gdbsupport/scoped_fd.h"
-#include "config.h"
 #include "gdbsupport/selftest.h"
 
 namespace selftests {
diff --git a/gdb/unittests/scoped_mmap-selftests.c b/gdb/unittests/scoped_mmap-selftests.c
index fa963d1b47f..7e479e2bc06 100644
--- a/gdb/unittests/scoped_mmap-selftests.c
+++ b/gdb/unittests/scoped_mmap-selftests.c
@@ -21,7 +21,6 @@ 
 
 #include "gdbsupport/filestuff.h"
 #include "gdbsupport/scoped_mmap.h"
-#include "config.h"
 
 #if defined(HAVE_SYS_MMAN_H)
 
diff --git a/gdbsupport/Makefile.am b/gdbsupport/Makefile.am
index 1a001a00817..3180ddebd4d 100644
--- a/gdbsupport/Makefile.am
+++ b/gdbsupport/Makefile.am
@@ -20,7 +20,7 @@ 
 AUTOMAKE_OPTIONS = no-dist foreign
 ACLOCAL_AMFLAGS = -I . -I ../config
 
-AM_CPPFLAGS = -I$(srcdir)/../include -I$(srcdir)/../gdb \
+AM_CPPFLAGS = -I$(srcdir)/config.h -I$(srcdir)/../include -I$(srcdir)/../gdb \
     -I../gnulib/import -I$(srcdir)/../gnulib/import \
     -I.. -I$(srcdir)/.. $(INCINTL) -I../bfd -I$(srcdir)/../bfd
 
diff --git a/gdbsupport/Makefile.in b/gdbsupport/Makefile.in
index 5723ae5e97e..f9931e1f102 100644
--- a/gdbsupport/Makefile.in
+++ b/gdbsupport/Makefile.in
@@ -195,7 +195,7 @@  am__can_run_installinfo = \
     *) (install-info --version) >/dev/null 2>&1;; \
   esac
 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \
-	$(LISP)config.in
+	$(LISP)support-config.in
 # Read a list of newline-separated strings from the standard input,
 # and print each of them once, without duplicates.  Input order is
 # *not* preserved.
@@ -346,7 +346,7 @@  top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 AUTOMAKE_OPTIONS = no-dist foreign
 ACLOCAL_AMFLAGS = -I . -I ../config
-AM_CPPFLAGS = -I$(srcdir)/../include -I$(srcdir)/../gdb \
+AM_CPPFLAGS = -I$(srcdir)/config.h -I$(srcdir)/../include -I$(srcdir)/../gdb \
     -I../gnulib/import -I$(srcdir)/../gnulib/import \
     -I.. -I$(srcdir)/.. $(INCINTL) -I../bfd -I$(srcdir)/../bfd
 
@@ -431,10 +431,10 @@  support-config.h: stamp-h1
 	@test -f $@ || rm -f stamp-h1
 	@test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1
 
-stamp-h1: $(srcdir)/config.in $(top_builddir)/config.status
+stamp-h1: $(srcdir)/support-config.in $(top_builddir)/config.status
 	@rm -f stamp-h1
 	cd $(top_builddir) && $(SHELL) ./config.status support-config.h
-$(srcdir)/config.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) 
+$(srcdir)/support-config.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) 
 	($(am__cd) $(top_srcdir) && $(AUTOHEADER))
 	rm -f stamp-h1
 	touch $@
diff --git a/gdbsupport/common-defs.h b/gdbsupport/common-defs.h
index d823c41607c..d6fc62be413 100644
--- a/gdbsupport/common-defs.h
+++ b/gdbsupport/common-defs.h
@@ -20,32 +20,8 @@ 
 #ifndef COMMON_COMMON_DEFS_H
 #define COMMON_COMMON_DEFS_H
 
-#ifdef GDBSERVER
-
-#include <build-gnulib-gdbserver/config.h>
-
-#undef PACKAGE_NAME
-#undef PACKAGE
-#undef PACKAGE_VERSION
-#undef PACKAGE_STRING
-#undef PACKAGE_TARNAME
-
 #include <config.h>
 
-#else  /* GDBSERVER */
-
-#include <gdbsupport/support-config.h>
-
-#undef PACKAGE_NAME
-#undef PACKAGE
-#undef PACKAGE_VERSION
-#undef PACKAGE_STRING
-#undef PACKAGE_TARNAME
-
-#include "gnulib/config.h"
-
-#endif	/* GDBSERVER */
-
 /* From:
     https://www.gnu.org/software/gnulib/manual/html_node/stdint_002eh.html
 
diff --git a/gdbsupport/config.h/config.h b/gdbsupport/config.h/config.h
new file mode 100644
index 00000000000..e0b95221767
--- /dev/null
+++ b/gdbsupport/config.h/config.h
@@ -0,0 +1,32 @@ 
+/* config.h for gdbsupport.
+   Copyright (C) 2020 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* This exists so that "#include <config.h>" in header files
+   (including gnulib headers), includes this file, which then includes
+   our real config.h (which is called support-config.h), along with
+   gnulib's config.h.  */
+
+#include "gnulib/config.h"
+
+#undef PACKAGE_NAME
+#undef PACKAGE
+#undef PACKAGE_VERSION
+#undef PACKAGE_STRING
+#undef PACKAGE_TARNAME
+
+#include <gdbsupport/support-config.h>
diff --git a/gdbsupport/configure b/gdbsupport/configure
index a0df06bbd53..b5eb64b7837 100755
--- a/gdbsupport/configure
+++ b/gdbsupport/configure
@@ -2713,7 +2713,7 @@  ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 
-ac_config_headers="$ac_config_headers support-config.h:config.in"
+ac_config_headers="$ac_config_headers support-config.h:support-config.in"
 
 ac_aux_dir=
 for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
@@ -9687,7 +9687,7 @@  ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sigsetjmp" >&5
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sigsetjmp" >&5
 $as_echo_n "checking for sigsetjmp... " >&6; }
 if ${gdb_cv_func_sigsetjmp+:} false; then :
   $as_echo_n "(cached) " >&6
@@ -9695,7 +9695,7 @@  else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-#include <setjmp.h>
+  #include <setjmp.h>
 
 int
 main ()
@@ -9714,11 +9714,11 @@  rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdb_cv_func_sigsetjmp" >&5
 $as_echo "$gdb_cv_func_sigsetjmp" >&6; }
-if test "$gdb_cv_func_sigsetjmp" = "yes"; then
+  if test "$gdb_cv_func_sigsetjmp" = "yes"; then
 
 $as_echo "#define HAVE_SIGSETJMP 1" >>confdefs.h
 
-fi
+  fi
 
 
 # Check whether --with-intel_pt was given.
@@ -9728,23 +9728,23 @@  else
   with_intel_pt=auto
 fi
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use intel pt" >&5
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use intel pt" >&5
 $as_echo_n "checking whether to use intel pt... " >&6; }
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_intel_pt" >&5
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_intel_pt" >&5
 $as_echo "$with_intel_pt" >&6; }
 
-if test "${with_intel_pt}" = no; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Intel Processor Trace support disabled; some features may be unavailable." >&5
+  if test "${with_intel_pt}" = no; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Intel Processor Trace support disabled; some features may be unavailable." >&5
 $as_echo "$as_me: WARNING: Intel Processor Trace support disabled; some features may be unavailable." >&2;}
-  HAVE_LIBIPT=no
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+    HAVE_LIBIPT=no
+  else
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-#include <linux/perf_event.h>
-#ifndef PERF_ATTR_SIZE_VER5
-# error
-#endif
+  #include <linux/perf_event.h>
+  #ifndef PERF_ATTR_SIZE_VER5
+  # error
+  #endif
 
 _ACEOF
 if ac_fn_c_try_cpp "$LINENO"; then :
@@ -9753,14 +9753,14 @@  else
   perf_event=no
 fi
 rm -f conftest.err conftest.i conftest.$ac_ext
-  if test "$perf_event" != yes; then
-    if test "$with_intel_pt" = yes; then
-      as_fn_error $? "linux/perf_event.h missing or too old" "$LINENO" 5
-    else
-      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: linux/perf_event.h missing or too old; some features may be unavailable." >&5
+    if test "$perf_event" != yes; then
+      if test "$with_intel_pt" = yes; then
+	as_fn_error $? "linux/perf_event.h missing or too old" "$LINENO" 5
+      else
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: linux/perf_event.h missing or too old; some features may be unavailable." >&5
 $as_echo "$as_me: WARNING: linux/perf_event.h missing or too old; some features may be unavailable." >&2;}
+      fi
     fi
-  fi
 
 
 
@@ -10224,17 +10224,17 @@  $as_echo "$LIBIPT" >&6; }
 
 
 
-  if test "$HAVE_LIBIPT" != yes; then
-    if test "$with_intel_pt" = yes; then
-      as_fn_error $? "libipt is missing or unusable" "$LINENO" 5
-    else
-      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libipt is missing or unusable; some features may be unavailable." >&5
+    if test "$HAVE_LIBIPT" != yes; then
+      if test "$with_intel_pt" = yes; then
+	as_fn_error $? "libipt is missing or unusable" "$LINENO" 5
+      else
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libipt is missing or unusable; some features may be unavailable." >&5
 $as_echo "$as_me: WARNING: libipt is missing or unusable; some features may be unavailable." >&2;}
-    fi
-  else
-    save_LIBS=$LIBS
-    LIBS="$LIBS $LIBIPT"
-    for ac_func in pt_insn_event
+      fi
+    else
+      save_LIBS=$LIBS
+      LIBS="$LIBS $LIBIPT"
+      for ac_func in pt_insn_event
 do :
   ac_fn_c_check_func "$LINENO" "pt_insn_event" "ac_cv_func_pt_insn_event"
 if test "x$ac_cv_func_pt_insn_event" = xyes; then :
@@ -10245,7 +10245,7 @@  _ACEOF
 fi
 done
 
-    ac_fn_c_check_member "$LINENO" "struct pt_insn" "enabled" "ac_cv_member_struct_pt_insn_enabled" "#include <intel-pt.h>
+      ac_fn_c_check_member "$LINENO" "struct pt_insn" "enabled" "ac_cv_member_struct_pt_insn_enabled" "#include <intel-pt.h>
 "
 if test "x$ac_cv_member_struct_pt_insn_enabled" = xyes; then :
 
@@ -10266,12 +10266,12 @@  _ACEOF
 
 fi
 
-    LIBS=$save_LIBS
+      LIBS=$save_LIBS
+    fi
   fi
-fi
 
-if test "$ac_cv_header_sys_procfs_h" = yes; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gregset_t in sys/procfs.h" >&5
+  if test "$ac_cv_header_sys_procfs_h" = yes; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gregset_t in sys/procfs.h" >&5
 $as_echo_n "checking for gregset_t in sys/procfs.h... " >&6; }
  if ${bfd_cv_have_sys_procfs_type_gregset_t+:} false; then :
   $as_echo_n "(cached) " >&6
@@ -10308,7 +10308,7 @@  $as_echo "#define HAVE_GREGSET_T 1" >>confdefs.h
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $bfd_cv_have_sys_procfs_type_gregset_t" >&5
 $as_echo "$bfd_cv_have_sys_procfs_type_gregset_t" >&6; }
 
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fpregset_t in sys/procfs.h" >&5
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fpregset_t in sys/procfs.h" >&5
 $as_echo_n "checking for fpregset_t in sys/procfs.h... " >&6; }
  if ${bfd_cv_have_sys_procfs_type_fpregset_t+:} false; then :
   $as_echo_n "(cached) " >&6
@@ -10345,7 +10345,7 @@  $as_echo "#define HAVE_FPREGSET_T 1" >>confdefs.h
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $bfd_cv_have_sys_procfs_type_fpregset_t" >&5
 $as_echo "$bfd_cv_have_sys_procfs_type_fpregset_t" >&6; }
 
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for prgregset_t in sys/procfs.h" >&5
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for prgregset_t in sys/procfs.h" >&5
 $as_echo_n "checking for prgregset_t in sys/procfs.h... " >&6; }
  if ${bfd_cv_have_sys_procfs_type_prgregset_t+:} false; then :
   $as_echo_n "(cached) " >&6
@@ -10382,7 +10382,7 @@  $as_echo "#define HAVE_PRGREGSET_T 1" >>confdefs.h
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $bfd_cv_have_sys_procfs_type_prgregset_t" >&5
 $as_echo "$bfd_cv_have_sys_procfs_type_prgregset_t" >&6; }
 
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for prfpregset_t in sys/procfs.h" >&5
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for prfpregset_t in sys/procfs.h" >&5
 $as_echo_n "checking for prfpregset_t in sys/procfs.h... " >&6; }
  if ${bfd_cv_have_sys_procfs_type_prfpregset_t+:} false; then :
   $as_echo_n "(cached) " >&6
@@ -10419,7 +10419,7 @@  $as_echo "#define HAVE_PRFPREGSET_T 1" >>confdefs.h
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $bfd_cv_have_sys_procfs_type_prfpregset_t" >&5
 $as_echo "$bfd_cv_have_sys_procfs_type_prfpregset_t" >&6; }
 
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for prgregset32_t in sys/procfs.h" >&5
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for prgregset32_t in sys/procfs.h" >&5
 $as_echo_n "checking for prgregset32_t in sys/procfs.h... " >&6; }
  if ${bfd_cv_have_sys_procfs_type_prgregset32_t+:} false; then :
   $as_echo_n "(cached) " >&6
@@ -10456,7 +10456,7 @@  $as_echo "#define HAVE_PRGREGSET32_T 1" >>confdefs.h
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $bfd_cv_have_sys_procfs_type_prgregset32_t" >&5
 $as_echo "$bfd_cv_have_sys_procfs_type_prgregset32_t" >&6; }
 
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for lwpid_t in sys/procfs.h" >&5
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for lwpid_t in sys/procfs.h" >&5
 $as_echo_n "checking for lwpid_t in sys/procfs.h... " >&6; }
  if ${bfd_cv_have_sys_procfs_type_lwpid_t+:} false; then :
   $as_echo_n "(cached) " >&6
@@ -10493,7 +10493,7 @@  $as_echo "#define HAVE_LWPID_T 1" >>confdefs.h
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $bfd_cv_have_sys_procfs_type_lwpid_t" >&5
 $as_echo "$bfd_cv_have_sys_procfs_type_lwpid_t" >&6; }
 
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for psaddr_t in sys/procfs.h" >&5
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for psaddr_t in sys/procfs.h" >&5
 $as_echo_n "checking for psaddr_t in sys/procfs.h... " >&6; }
  if ${bfd_cv_have_sys_procfs_type_psaddr_t+:} false; then :
   $as_echo_n "(cached) " >&6
@@ -10530,7 +10530,7 @@  $as_echo "#define HAVE_PSADDR_T 1" >>confdefs.h
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $bfd_cv_have_sys_procfs_type_psaddr_t" >&5
 $as_echo "$bfd_cv_have_sys_procfs_type_psaddr_t" >&6; }
 
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for elf_fpregset_t in sys/procfs.h" >&5
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for elf_fpregset_t in sys/procfs.h" >&5
 $as_echo_n "checking for elf_fpregset_t in sys/procfs.h... " >&6; }
  if ${bfd_cv_have_sys_procfs_type_elf_fpregset_t+:} false; then :
   $as_echo_n "(cached) " >&6
@@ -10567,7 +10567,7 @@  $as_echo "#define HAVE_ELF_FPREGSET_T 1" >>confdefs.h
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $bfd_cv_have_sys_procfs_type_elf_fpregset_t" >&5
 $as_echo "$bfd_cv_have_sys_procfs_type_elf_fpregset_t" >&6; }
 
-fi
+  fi
 
 
 # Check whether we will enable the inclusion of unit tests when
@@ -11563,7 +11563,7 @@  cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 for ac_config_target in $ac_config_targets
 do
   case $ac_config_target in
-    "support-config.h") CONFIG_HEADERS="$CONFIG_HEADERS support-config.h:config.in" ;;
+    "support-config.h") CONFIG_HEADERS="$CONFIG_HEADERS support-config.h:support-config.in" ;;
     "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
     "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
 
diff --git a/gdbsupport/configure.ac b/gdbsupport/configure.ac
index af14d7bb92d..ffa0f836027 100644
--- a/gdbsupport/configure.ac
+++ b/gdbsupport/configure.ac
@@ -18,7 +18,7 @@  dnl Process this file with autoconf to produce a configure script.
 
 AC_INIT([gdbsupport], 1.0)
 AC_CONFIG_SRCDIR(common-defs.h)
-AC_CONFIG_HEADER(support-config.h:config.in)
+AC_CONFIG_HEADER(support-config.h:support-config.in)
 AC_CANONICAL_SYSTEM
 AM_MAINTAINER_MODE
 AC_CONFIG_AUX_DIR(..)
diff --git a/gdbsupport/config.in b/gdbsupport/support-config.in
similarity index 100%
rename from gdbsupport/config.in
rename to gdbsupport/support-config.in