Change gdbserver to use existing gnulib and libiberty

Message ID 20200207225313.31092-1-tom@tromey.com
State New, archived
Headers

Commit Message

Tom Tromey Feb. 7, 2020, 10:53 p.m. UTC
  This changes gdbserver so that it no longer builds its own gnulib and
libiberty.  Instead, it now relies on the ones that were already built
at the top level.

gdbsupport is still built specially for gdbserver.  This is more
complicated and will be tackled in a subsequent patch.

ChangeLog
2020-02-07  Tom Tromey  <tom@tromey.com>

	* Makefile.in: Rebuild.
	* Makefile.def: Make gdbserver require gnulib and libiberty.

gdbserver/ChangeLog
2020-02-07  Tom Tromey  <tom@tromey.com>

	* Makefile.in (LIBIBERTY_BUILDDIR, GNULIB_BUILDDIR): Update.
	(SUBDIRS, CLEANDIRS, REQUIRED_SUBDIRS): Remove.
	(all, install-only, uninstall, clean-info, clean)
	(maintainer-clean): Don't recurse.
	(subdir_do, all-lib): Remove.
	($(LIBGNU) $(LIBIBERTY) $(GNULIB_H)): Remove rule.
	(GNULIB_H): Remove.
	(generated_files): Update.
	($(GNULIB_BUILDDIR)/Makefile): Remove rule.
	* configure: Rebuild.
	* configure.ac: Don't configure gnulib or libiberty.
	(GNULIB): Update.

gdbsupport/ChangeLog
2020-02-07  Tom Tromey  <tom@tromey.com>

	* common-defs.h: Change path to gnulib/config.h.

Change-Id: I469cbbf5db2ab37109c058e9e3a1e4f4dabdfc98
---
 ChangeLog                |   5 +
 Makefile.def             |   5 +
 Makefile.in              |   4 +
 gdbserver/ChangeLog      |  15 +++
 gdbserver/Makefile.in    |  59 +----------
 gdbserver/configure      | 219 +--------------------------------------
 gdbserver/configure.ac   |  18 +---
 gdbsupport/ChangeLog     |   4 +
 gdbsupport/common-defs.h |   2 +-
 9 files changed, 40 insertions(+), 291 deletions(-)
  

Comments

Eli Zaretskii Feb. 8, 2020, 7:41 a.m. UTC | #1
> From: Tom Tromey <tom@tromey.com>
> Cc: Tom Tromey <tom@tromey.com>
> Date: Fri,  7 Feb 2020 15:53:13 -0700
> 
> This changes gdbserver so that it no longer builds its own gnulib and
> libiberty.  Instead, it now relies on the ones that were already built
> at the top level.

Thank you very much for doing this.  These duplicate builds have been
a long-time annoyance to me.
  
Tom Tromey Feb. 14, 2020, 9:27 p.m. UTC | #2
>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:

Tom> This changes gdbserver so that it no longer builds its own gnulib and
Tom> libiberty.  Instead, it now relies on the ones that were already built
Tom> at the top level.

Tom> gdbsupport is still built specially for gdbserver.  This is more
Tom> complicated and will be tackled in a subsequent patch.

I'm going to check this in now.

Tom
  
Tamar Christina Feb. 24, 2020, 2:16 p.m. UTC | #3
Hi Tom,

We're having trouble building cross toolchains after this change.

Before this we were able to build gdb running on HOST but build gdbserver running on TARGET.

After this change we can no longer do this since you can't link objects from different architectures.

Is this not a supported workflow anymore? Any suggestions how to do this after these changes?

Thanks,
Tamar

> -----Original Message-----
> From: gdb-patches-owner@sourceware.org <gdb-patches-
> owner@sourceware.org> On Behalf Of Tom Tromey
> Sent: Friday, February 7, 2020 10:53 PM
> To: gdb-patches@sourceware.org
> Cc: Tom Tromey <tom@tromey.com>
> Subject: [PATCH] Change gdbserver to use existing gnulib and libiberty
> 
> This changes gdbserver so that it no longer builds its own gnulib and libiberty.
> Instead, it now relies on the ones that were already built at the top level.
> 
> gdbsupport is still built specially for gdbserver.  This is more complicated and
> will be tackled in a subsequent patch.
> 
> ChangeLog
> 2020-02-07  Tom Tromey  <tom@tromey.com>
> 
> 	* Makefile.in: Rebuild.
> 	* Makefile.def: Make gdbserver require gnulib and libiberty.
> 
> gdbserver/ChangeLog
> 2020-02-07  Tom Tromey  <tom@tromey.com>
> 
> 	* Makefile.in (LIBIBERTY_BUILDDIR, GNULIB_BUILDDIR): Update.
> 	(SUBDIRS, CLEANDIRS, REQUIRED_SUBDIRS): Remove.
> 	(all, install-only, uninstall, clean-info, clean)
> 	(maintainer-clean): Don't recurse.
> 	(subdir_do, all-lib): Remove.
> 	($(LIBGNU) $(LIBIBERTY) $(GNULIB_H)): Remove rule.
> 	(GNULIB_H): Remove.
> 	(generated_files): Update.
> 	($(GNULIB_BUILDDIR)/Makefile): Remove rule.
> 	* configure: Rebuild.
> 	* configure.ac: Don't configure gnulib or libiberty.
> 	(GNULIB): Update.
> 
> gdbsupport/ChangeLog
> 2020-02-07  Tom Tromey  <tom@tromey.com>
> 
> 	* common-defs.h: Change path to gnulib/config.h.
> 
> Change-Id: I469cbbf5db2ab37109c058e9e3a1e4f4dabdfc98
> ---
>  ChangeLog                |   5 +
>  Makefile.def             |   5 +
>  Makefile.in              |   4 +
>  gdbserver/ChangeLog      |  15 +++
>  gdbserver/Makefile.in    |  59 +----------
>  gdbserver/configure      | 219 +--------------------------------------
>  gdbserver/configure.ac   |  18 +---
>  gdbsupport/ChangeLog     |   4 +
>  gdbsupport/common-defs.h |   2 +-
>  9 files changed, 40 insertions(+), 291 deletions(-)
> 
> diff --git a/Makefile.def b/Makefile.def index 72cb133a09a..2fe8204366c
> 100644
> --- a/Makefile.def
> +++ b/Makefile.def
> @@ -410,6 +410,11 @@ dependencies = { module=all-gdb; on=all-
> libdecnumber; };  dependencies = { module=all-gdb; on=all-libtermcap; };
> dependencies = { module=all-gdb; on=all-libctf; };
> 
> +// Host modules specific to gdbserver.
> +dependencies = { module=configure-gdbserver; on=all-gnulib; };
> +dependencies = { module=all-gdbserver; on=all-gnulib; }; dependencies =
> +{ module=all-gdbserver; on=all-libiberty; };
> +
>  dependencies = { module=configure-libgui; on=configure-tcl; };
> dependencies = { module=configure-libgui; on=configure-tk; };
> dependencies = { module=all-libgui; on=all-tcl; }; diff --git a/Makefile.in
> b/Makefile.in index 80fa458d8d0..be38b34e9bf 100644
> --- a/Makefile.in
> +++ b/Makefile.in
> @@ -51976,6 +51976,8 @@ all-gdb: maybe-all-readline
>  all-gdb: maybe-all-build-bison
>  all-gdb: maybe-all-sim
>  all-gdb: maybe-all-libtermcap
> +configure-gdbserver: maybe-all-gnulib
> +all-gdbserver: maybe-all-gnulib
>  configure-libgui: maybe-configure-tcl
>  configure-libgui: maybe-configure-tk
>  all-libgui: maybe-all-tcl
> @@ -52427,6 +52429,7 @@ configure-gnattools: stage_last
>  configure-libcc1: stage_last
>  configure-utils: stage_last
>  configure-gdb: stage_last
> +configure-gdbserver: stage_last
>  configure-gdbsupport: stage_last
>  configure-gprof: stage_last
>  configure-sid: stage_last
> @@ -52450,6 +52453,7 @@ all-gdb: maybe-all-libiconv
>  all-gdb: maybe-all-opcodes
>  all-gdb: maybe-all-libdecnumber
>  all-gdb: maybe-all-libctf
> +all-gdbserver: maybe-all-libiberty
>  configure-gdbsupport: maybe-configure-bfd
>  all-gdbsupport: maybe-all-bfd
>  configure-gprof: maybe-configure-intl
> diff --git a/gdbserver/Makefile.in b/gdbserver/Makefile.in index
> 60a52d3412b..e0f50d2f3e4 100644
> --- a/gdbserver/Makefile.in
> +++ b/gdbserver/Makefile.in
> @@ -97,7 +97,7 @@ CC_LD = $(CXX) $(CXX_DIALECT)  INCLUDE_DIR =
> ${srcdir}/../include  INCLUDE_DEP = $$(INCLUDE_DIR)
> 
> -LIBIBERTY_BUILDDIR = build-libiberty-gdbserver
> +LIBIBERTY_BUILDDIR = ../libiberty
>  LIBIBERTY = $(LIBIBERTY_BUILDDIR)/libiberty.a
> 
>  # Where is ust?  These will be empty if ust was not available.
> @@ -105,14 +105,10 @@ ustlibs = @ustlibs@  ustinc = @ustinc@
> 
>  # gnulib
> -GNULIB_BUILDDIR = build-gnulib-gdbserver
> +GNULIB_BUILDDIR = ../gnulib
>  LIBGNU = $(GNULIB_BUILDDIR)/import/libgnu.a
>  INCGNU = -I$(srcdir)/../gnulib/import -I$(GNULIB_BUILDDIR)/import
> 
> -# Generated headers in the gnulib directory.  These must be listed -# so that
> they are generated before other files are compiled.
> -GNULIB_H = $(GNULIB_BUILDDIR)/import/string.h @GNULIB_STDINT_H@
> -
>  INCSUPPORT = -I$(srcdir)/.. -I..
> 
>  # All the includes used for CFLAGS and for lint.
> @@ -329,15 +325,6 @@ XML_BUILTIN = @srv_xmlbuiltin@  IPA_DEPFILES =
> @IPA_DEPFILES@  extra_libraries = @extra_libraries@
> 
> -SUBDIRS = $(GNULIB_BUILDDIR) $(LIBIBERTY_BUILDDIR) -CLEANDIRS =
> $(SUBDIRS)
> -
> -# List of subdirectories in the build tree that must exist.
> -# This is used to force build failures in existing trees when -# a new directory
> is added.
> -# The format here is for the `case' shell command.
> -REQUIRED_SUBDIRS = $(GNULIB_BUILDDIR) | $(LIBIBERTY_BUILDDIR)
> -
>  FLAGS_TO_PASS = \
>  	"prefix=$(prefix)" \
>  	"exec_prefix=$(exec_prefix)" \
> @@ -371,10 +358,9 @@ FLAGS_TO_PASS = \
>  	"RUNTESTFLAGS=$(RUNTESTFLAGS)"
> 
>  # All generated files which can be included by another file.
> -generated_files = config.h $(GNULIB_H)
> +generated_files = config.h
> 
>  all: gdbserver$(EXEEXT) gdbreplay$(EXEEXT) $(extra_libraries)
> -	@$(MAKE) $(FLAGS_TO_PASS) DO=$@ "DODIRS=$(SUBDIRS)"
> subdir_do
> 
>  # Traditionally "install" depends on "all".  But it may be useful  # not to; for
> example, if the user has made some trivial change to a @@ -393,10 +379,6
> @@ install-only:
>  	fi; \
>  	$(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(bindir); \
>  	$(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM)
> gdbserver$(EXEEXT) $(DESTDIR)$(bindir)/$$n$(EXEEXT)
> -	# Note that we run install and not install-only, as the latter
> -	# is not part of GNU standards and in particular not provided
> -	# in libiberty.
> -	@$(MAKE) $(FLAGS_TO_PASS) DO=install "DODIRS=$(SUBDIRS)"
> subdir_do
> 
>  install-strip:
>  	$(MAKE) $(FLAGS_TO_PASS)
> INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ @@ -408,7 +390,6
> @@ uninstall: force
>  	n=`echo gdbserver | sed '$(program_transform_name)'`; \
>  	if [ x$$n = x ]; then n=gdbserver; else true; fi; \
>  	rm -f $(DESTDIR)/$(bindir)/$$n$(EXEEXT)
> $(DESTDIR)$(man1dir)/$$n.1
> -	@$(MAKE) $(FLAGS_TO_PASS) DO=$@ "DODIRS=$(SUBDIRS)"
> subdir_do
> 
>  installcheck:
>  check:
> @@ -417,8 +398,7 @@ install-info:
>  install-pdf:
>  html:
>  install-html:
> -clean-info: force
> -	@$(MAKE) $(FLAGS_TO_PASS) DO=$@ "DODIRS=$(SUBDIRS)"
> subdir_do
> +clean-info:
> 
>  gdbserver$(EXEEXT): $(sort $(OBS)) ${CDEPS} $(LIBGNU) $(LIBIBERTY)
>  	$(SILENCE) rm -f gdbserver$(EXEEXT)
> @@ -426,11 +406,6 @@ gdbserver$(EXEEXT): $(sort $(OBS)) ${CDEPS}
> $(LIBGNU) $(LIBIBERTY)
>  		-o gdbserver$(EXEEXT) $(OBS) $(LIBGNU) $(LIBIBERTY) \
>  		$(GDBSERVER_LIBS) $(XM_CLIBS)
> 
> -$(LIBGNU) $(LIBIBERTY) $(GNULIB_H): all-lib
> -all-lib: $(GNULIB_BUILDDIR)/Makefile $(LIBIBERTY_BUILDDIR)/Makefile
> -	@$(MAKE) $(FLAGS_TO_PASS) DO=all DODIRS="$(SUBDIRS)"
> subdir_do
> -.PHONY: all-lib
> -
>  gdbreplay$(EXEEXT): $(sort $(GDBREPLAY_OBS)) $(LIBGNU) $(LIBIBERTY)
>  	$(SILENCE) rm -f gdbreplay$(EXEEXT)
>  	$(ECHO_CXXLD) $(CC_LD) $(INTERNAL_CFLAGS)
> $(INTERNAL_LDFLAGS) \ @@ -488,33 +463,14 @@ clean:
>  		rm -f $$i/*.o;	\
>  		rm -f $$i/$(DEPDIR)/*; \
>  	done
> -	@$(MAKE) $(FLAGS_TO_PASS) DO=$@ "DODIRS=$(SUBDIRS)"
> subdir_do
> 
>  maintainer-clean realclean distclean: clean
> -	@$(MAKE) $(FLAGS_TO_PASS) DO=$@ "DODIRS=$(SUBDIRS)"
> subdir_do
> -	rm -rf $(GNULIB_BUILDDIR)
>  	rm -f Makefile config.status config.h stamp-h config.log
>  	rm -f Makefile
>  	for i in $(CONFIG_SRC_SUBDIR); do \
>  		rmdir $$i/$(DEPDIR); \
>  	done
> 
> -subdir_do: force
> -	@for i in $(DODIRS); do \
> -		case $$i in \
> -		$(REQUIRED_SUBDIRS)) \
> -			if [ ! -f ./$$i/Makefile ] ; then \
> -				echo "Missing $$i/Makefile" >&2 ; \
> -				exit 1 ; \
> -			fi ;; \
> -		esac ; \
> -		if [ -f ./$$i/Makefile ] ; then \
> -			if (cd ./$$i; \
> -				$(MAKE) $(FLAGS_TO_PASS) $(DO)) ; then
> true ; \
> -			else exit 1 ; fi ; \
> -		else true ; fi ; \
> -	done
> -
>  config.h: stamp-h ; @true
>  stamp-h: config.in config.status
>  	$(SHELL) ./config.status config.h
> @@ -522,13 +478,6 @@ stamp-h: config.in config.status
>  Makefile: Makefile.in config.status
>  	$(SHELL) ./config.status $@
> 
> -$(GNULIB_BUILDDIR)/Makefile: $(srcdir)/../gnulib/Makefile.in config.status
> -	  @cd $(GNULIB_BUILDDIR); CONFIG_FILES="Makefile" \
> -	  CONFIG_COMMANDS="depfiles" \
> -	  CONFIG_HEADERS= \
> -	  CONFIG_LINKS= \
> -	  $(SHELL) config.status
> -
>  config.status: configure configure.srv $(srcdir)/../bfd/development.sh
>  	$(SHELL) ./config.status --recheck
> 
> diff --git a/gdbserver/configure b/gdbserver/configure index
> 4b9d7e3718f..eb8aa80c2c5 100755
> --- a/gdbserver/configure
> +++ b/gdbserver/configure
> @@ -6243,223 +6243,6 @@ else
> CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type
>  fi
> 
> 
> -gnulib_extra_configure_args=
> -# If large-file support is disabled, make sure gnulib does the same.
> -if test "$enable_largefile" = no; then
> -gnulib_extra_configure_args="$gnulib_extra_configure_args --disable-
> largefile"
> -fi
> -
> -# Configure gnulib.  We can't use AC_CONFIG_SUBDIRS as that'd expect -#
> to find the the source subdir to be configured directly under -# gdbserver/.
> We need to build gnulib under some other directory not -# "gnulib", to avoid
> the problem of both GDB and GDBserver wanting to -# build it in the same
> directory, when building in the source dir.
> -
> -  in_src="../gnulib"
> -  in_build="build-gnulib-gdbserver"
> -  in_extra_args="$gnulib_extra_configure_args"
> -
> -  # Remove --cache-file, --srcdir, and --disable-option-checking arguments
> -  # so they do not pile up.
> -  ac_sub_configure_args=
> -  ac_prev=
> -  eval "set x $ac_configure_args"
> -  shift
> -  for ac_arg
> -  do
> -    if test -n "$ac_prev"; then
> -      ac_prev=
> -      continue
> -    fi
> -    case $ac_arg in
> -    -cache-file | --cache-file | --cache-fil | --cache-fi \
> -    | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
> -      ac_prev=cache_file ;;
> -    -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
> -    | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* \
> -    | --c=*)
> -      ;;
> -    --config-cache | -C)
> -      ;;
> -    -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
> -      ac_prev=srcdir ;;
> -    -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
> -      ;;
> -    -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
> -      ac_prev=prefix ;;
> -    -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
> -      ;;
> -    --disable-option-checking)
> -      ;;
> -    *)
> -      case $ac_arg in
> -      *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
> -      esac
> -      as_fn_append ac_sub_configure_args " '$ac_arg'" ;;
> -    esac
> -  done
> -
> -  # Always prepend --prefix to ensure using the same prefix
> -  # in subdir configurations.
> -  ac_arg="--prefix=$prefix"
> -  case $ac_arg in
> -  *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
> -  esac
> -  ac_sub_configure_args="'$ac_arg' $ac_sub_configure_args"
> -
> -  # Pass --silent
> -  if test "$silent" = yes; then
> -    ac_sub_configure_args="--silent $ac_sub_configure_args"
> -  fi
> -
> -  # Always prepend --disable-option-checking to silence warnings, since
> -  # different subdirs can have different --enable and --with options.
> -  ac_sub_configure_args="--disable-option-checking
> $ac_sub_configure_args"
> -
> -  ac_popdir=`pwd`
> -  ac_dir=$in_build
> -
> -  ac_msg="=== configuring in $ac_dir (`pwd`/$ac_dir)"
> -  $as_echo "$as_me:${as_lineno-$LINENO}: $ac_msg" >&5
> -  $as_echo "$ac_msg" >&6
> -  as_dir="$ac_dir"; as_fn_mkdir_p
> -
> -  case $srcdir in
> -  [\\/]* | ?:[\\/]* )
> -    ac_srcdir=$srcdir/$in_src ;;
> -  *) # Relative name.
> -    ac_srcdir=../$srcdir/$in_src ;;
> -  esac
> -
> -  cd "$ac_dir"
> -
> -  ac_sub_configure=$ac_srcdir/configure
> -
> -  # Make the cache file name correct relative to the subdirectory.
> -  case $cache_file in
> -  [\\/]* | ?:[\\/]* ) ac_sub_cache_file=$cache_file ;;
> -  *) # Relative name.
> -    ac_sub_cache_file=$ac_top_build_prefix$cache_file ;;
> -  esac
> -
> -  if test -n "$in_extra_args"; then
> -    # Add the extra args at the end.
> -    ac_sub_configure_args="$ac_sub_configure_args $in_extra_args"
> -  fi
> -
> -  { $as_echo "$as_me:${as_lineno-$LINENO}: running $SHELL
> $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file
> --srcdir=$ac_srcdir" >&5 -$as_echo "$as_me: running $SHELL
> $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file
> --srcdir=$ac_srcdir" >&6;}
> -  # The eval makes quoting arguments work.
> -  eval "\$SHELL \"\$ac_sub_configure\" $ac_sub_configure_args \
> -       --cache-file=\"\$ac_sub_cache_file\" --srcdir=\"\$ac_srcdir\"" ||
> -    as_fn_error $? "$ac_sub_configure failed for $ac_dir" "$LINENO" 5
> -
> -  cd "$ac_popdir"
> -
> -
> -
> -  in_src="../libiberty"
> -  in_build="build-libiberty-gdbserver"
> -  in_extra_args=
> -
> -  # Remove --cache-file, --srcdir, and --disable-option-checking arguments
> -  # so they do not pile up.
> -  ac_sub_configure_args=
> -  ac_prev=
> -  eval "set x $ac_configure_args"
> -  shift
> -  for ac_arg
> -  do
> -    if test -n "$ac_prev"; then
> -      ac_prev=
> -      continue
> -    fi
> -    case $ac_arg in
> -    -cache-file | --cache-file | --cache-fil | --cache-fi \
> -    | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
> -      ac_prev=cache_file ;;
> -    -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
> -    | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* \
> -    | --c=*)
> -      ;;
> -    --config-cache | -C)
> -      ;;
> -    -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
> -      ac_prev=srcdir ;;
> -    -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
> -      ;;
> -    -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
> -      ac_prev=prefix ;;
> -    -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
> -      ;;
> -    --disable-option-checking)
> -      ;;
> -    *)
> -      case $ac_arg in
> -      *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
> -      esac
> -      as_fn_append ac_sub_configure_args " '$ac_arg'" ;;
> -    esac
> -  done
> -
> -  # Always prepend --prefix to ensure using the same prefix
> -  # in subdir configurations.
> -  ac_arg="--prefix=$prefix"
> -  case $ac_arg in
> -  *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
> -  esac
> -  ac_sub_configure_args="'$ac_arg' $ac_sub_configure_args"
> -
> -  # Pass --silent
> -  if test "$silent" = yes; then
> -    ac_sub_configure_args="--silent $ac_sub_configure_args"
> -  fi
> -
> -  # Always prepend --disable-option-checking to silence warnings, since
> -  # different subdirs can have different --enable and --with options.
> -  ac_sub_configure_args="--disable-option-checking
> $ac_sub_configure_args"
> -
> -  ac_popdir=`pwd`
> -  ac_dir=$in_build
> -
> -  ac_msg="=== configuring in $ac_dir (`pwd`/$ac_dir)"
> -  $as_echo "$as_me:${as_lineno-$LINENO}: $ac_msg" >&5
> -  $as_echo "$ac_msg" >&6
> -  as_dir="$ac_dir"; as_fn_mkdir_p
> -
> -  case $srcdir in
> -  [\\/]* | ?:[\\/]* )
> -    ac_srcdir=$srcdir/$in_src ;;
> -  *) # Relative name.
> -    ac_srcdir=../$srcdir/$in_src ;;
> -  esac
> -
> -  cd "$ac_dir"
> -
> -  ac_sub_configure=$ac_srcdir/configure
> -
> -  # Make the cache file name correct relative to the subdirectory.
> -  case $cache_file in
> -  [\\/]* | ?:[\\/]* ) ac_sub_cache_file=$cache_file ;;
> -  *) # Relative name.
> -    ac_sub_cache_file=$ac_top_build_prefix$cache_file ;;
> -  esac
> -
> -  if test -n "$in_extra_args"; then
> -    # Add the extra args at the end.
> -    ac_sub_configure_args="$ac_sub_configure_args $in_extra_args"
> -  fi
> -
> -  { $as_echo "$as_me:${as_lineno-$LINENO}: running $SHELL
> $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file
> --srcdir=$ac_srcdir" >&5 -$as_echo "$as_me: running $SHELL
> $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file
> --srcdir=$ac_srcdir" >&6;}
> -  # The eval makes quoting arguments work.
> -  eval "\$SHELL \"\$ac_sub_configure\" $ac_sub_configure_args \
> -       --cache-file=\"\$ac_sub_cache_file\" --srcdir=\"\$ac_srcdir\"" ||
> -    as_fn_error $? "$ac_sub_configure failed for $ac_dir" "$LINENO" 5
> -
> -  cd "$ac_popdir"
> -
> -
>  for ac_header in termios.h sys/reg.h string.h 		 sys/procfs.h
> linux/elf.h 		 fcntl.h signal.h sys/file.h 		 sys/ioctl.h
> netinet/in.h sys/socket.h netdb.h 		 netinet/tcp.h arpa/inet.h
>  do :
>    as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` @@ -
> 10838,7 +10621,7 @@ fi
> 
> 
> 
> -GNULIB=build-gnulib-gdbserver/import
> +GNULIB=../gnulib/import
> 
>  GNULIB_STDINT_H=
>  if test x"$STDINT_H" != x; then
> diff --git a/gdbserver/configure.ac b/gdbserver/configure.ac index
> 285a297a1c6..cbd12ea2ed0 100644
> --- a/gdbserver/configure.ac
> +++ b/gdbserver/configure.ac
> @@ -69,22 +69,6 @@ AC_CONFIG_COMMANDS([gdbdepdir],[
> 
>  ZW_PROG_COMPILER_DEPENDENCIES([CC])
> 
> -gnulib_extra_configure_args=
> -# If large-file support is disabled, make sure gnulib does the same.
> -if test "$enable_largefile" = no; then
> -gnulib_extra_configure_args="$gnulib_extra_configure_args --disable-
> largefile"
> -fi
> -
> -# Configure gnulib.  We can't use AC_CONFIG_SUBDIRS as that'd expect -#
> to find the the source subdir to be configured directly under -# gdbserver/.
> We need to build gnulib under some other directory not -# "gnulib", to avoid
> the problem of both GDB and GDBserver wanting to -# build it in the same
> directory, when building in the source dir.
> -ACX_CONFIGURE_DIR(["../gnulib"], ["build-gnulib-gdbserver"],
> -                  ["$gnulib_extra_configure_args"])
> -
> -ACX_CONFIGURE_DIR(["../libiberty"], ["build-libiberty-gdbserver"])
> -
>  AC_CHECK_HEADERS(termios.h sys/reg.h string.h dnl
>  		 sys/procfs.h linux/elf.h dnl
>  		 fcntl.h signal.h sys/file.h dnl
> @@ -432,7 +416,7 @@ AC_SUBST(srv_xmlfiles)
>  AC_SUBST(IPA_DEPFILES)
>  AC_SUBST(extra_libraries)
> 
> -GNULIB=build-gnulib-gdbserver/import
> +GNULIB=../gnulib/import
> 
>  GNULIB_STDINT_H=
>  if test x"$STDINT_H" != x; then
> diff --git a/gdbsupport/common-defs.h b/gdbsupport/common-defs.h index
> 027bf099c1a..a5c57de2f27 100644
> --- a/gdbsupport/common-defs.h
> +++ b/gdbsupport/common-defs.h
> @@ -22,7 +22,7 @@
> 
>  #ifdef GDBSERVER
> 
> -#include <build-gnulib-gdbserver/config.h>
> +#include <gnulib/config.h>
> 
>  #undef PACKAGE_NAME
>  #undef PACKAGE
> --
> 2.17.2
  
Simon Marchi Feb. 24, 2020, 7:46 p.m. UTC | #4
On 2020-02-24 9:16 a.m., Tamar Christina wrote:
> Hi Tom,
> 
> We're having trouble building cross toolchains after this change.
> 
> Before this we were able to build gdb running on HOST but build gdbserver running on TARGET.
> 
> After this change we can no longer do this since you can't link objects from different architectures.
> 
> Is this not a supported workflow anymore? Any suggestions how to do this after these changes?
> 
> Thanks,
> Tamar

Hi Tamar,

When you were building gdb running on HOST and gdbserver running on TARGET, I presume
you were running two configure scripts, like this?

$ .../binutils-gdb/configure --host=x86-foo --target=arm-bar

and in another directory

$ .../binutils-gdb/gdb/gdbserver/configure --host=arm-bar

Now, gdbserver being a proper top-level project (just like gdb and binutils
are), you can do:

$ .../binutils-gdb/configure --host=x86-foo --target=arm-bar

... to configure GDB, and:

$ .../binutils-gdb/configure --target=arm-bar

... to configure GDBserver.

In fact, these commands set up build directories to build the entire
binutils-gdb repository.  You could either pass a bunch of --disable-*
options to configure in order to disable the projects you don't want
to build, or build using "make all-gdb" / "make all-gdbserver" to only
build gdb or gdbserver respectively.

Hope that helps.

Simon
  
Tamar Christina Feb. 26, 2020, 9:50 p.m. UTC | #5
Hi Simon,

Thanks, I'm giving this a try now.

Cheers,
Tamar

> -----Original Message-----

> From: Simon Marchi <simark@simark.ca>

> Sent: Monday, February 24, 2020 7:46 PM

> To: Tamar Christina <Tamar.Christina@arm.com>; Tom Tromey

> <tom@tromey.com>; gdb-patches@sourceware.org

> Cc: nd <nd@arm.com>

> Subject: Re: [PATCH] Change gdbserver to use existing gnulib and libiberty

> 

> On 2020-02-24 9:16 a.m., Tamar Christina wrote:

> > Hi Tom,

> >

> > We're having trouble building cross toolchains after this change.

> >

> > Before this we were able to build gdb running on HOST but build gdbserver

> running on TARGET.

> >

> > After this change we can no longer do this since you can't link objects from

> different architectures.

> >

> > Is this not a supported workflow anymore? Any suggestions how to do this

> after these changes?

> >

> > Thanks,

> > Tamar

> 

> Hi Tamar,

> 

> When you were building gdb running on HOST and gdbserver running on

> TARGET, I presume you were running two configure scripts, like this?

> 

> $ .../binutils-gdb/configure --host=x86-foo --target=arm-bar

> 

> and in another directory

> 

> $ .../binutils-gdb/gdb/gdbserver/configure --host=arm-bar

> 

> Now, gdbserver being a proper top-level project (just like gdb and binutils

> are), you can do:

> 

> $ .../binutils-gdb/configure --host=x86-foo --target=arm-bar

> 

> ... to configure GDB, and:

> 

> $ .../binutils-gdb/configure --target=arm-bar

> 

> ... to configure GDBserver.

> 

> In fact, these commands set up build directories to build the entire binutils-

> gdb repository.  You could either pass a bunch of --disable-* options to

> configure in order to disable the projects you don't want to build, or build

> using "make all-gdb" / "make all-gdbserver" to only build gdb or gdbserver

> respectively.

> 

> Hope that helps.

> 

> Simon
  
Pedro Alves Feb. 27, 2020, 3:30 p.m. UTC | #6
On 2/24/20 7:46 PM, Simon Marchi wrote:

> $ .../binutils-gdb/configure --target=arm-bar
> 
> ... to configure GDBserver.

Should be:

$ .../binutils-gdb/configure --host=arm-bar

... to configure GDBserver.

Thanks,
Pedro Alves
  
Simon Marchi Feb. 27, 2020, 4:36 p.m. UTC | #7
On 2020-02-27 10:30 a.m., Pedro Alves wrote:
> On 2/24/20 7:46 PM, Simon Marchi wrote:
> 
>> $ .../binutils-gdb/configure --target=arm-bar
>>
>> ... to configure GDBserver.
> 
> Should be:
> 
> $ .../binutils-gdb/configure --host=arm-bar
> 
> ... to configure GDBserver.

Oops, yes of course.

Simon
  

Patch

diff --git a/Makefile.def b/Makefile.def
index 72cb133a09a..2fe8204366c 100644
--- a/Makefile.def
+++ b/Makefile.def
@@ -410,6 +410,11 @@  dependencies = { module=all-gdb; on=all-libdecnumber; };
 dependencies = { module=all-gdb; on=all-libtermcap; };
 dependencies = { module=all-gdb; on=all-libctf; };
 
+// Host modules specific to gdbserver.
+dependencies = { module=configure-gdbserver; on=all-gnulib; };
+dependencies = { module=all-gdbserver; on=all-gnulib; };
+dependencies = { module=all-gdbserver; on=all-libiberty; };
+
 dependencies = { module=configure-libgui; on=configure-tcl; };
 dependencies = { module=configure-libgui; on=configure-tk; };
 dependencies = { module=all-libgui; on=all-tcl; };
diff --git a/Makefile.in b/Makefile.in
index 80fa458d8d0..be38b34e9bf 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -51976,6 +51976,8 @@  all-gdb: maybe-all-readline
 all-gdb: maybe-all-build-bison
 all-gdb: maybe-all-sim
 all-gdb: maybe-all-libtermcap
+configure-gdbserver: maybe-all-gnulib
+all-gdbserver: maybe-all-gnulib
 configure-libgui: maybe-configure-tcl
 configure-libgui: maybe-configure-tk
 all-libgui: maybe-all-tcl
@@ -52427,6 +52429,7 @@  configure-gnattools: stage_last
 configure-libcc1: stage_last
 configure-utils: stage_last
 configure-gdb: stage_last
+configure-gdbserver: stage_last
 configure-gdbsupport: stage_last
 configure-gprof: stage_last
 configure-sid: stage_last
@@ -52450,6 +52453,7 @@  all-gdb: maybe-all-libiconv
 all-gdb: maybe-all-opcodes
 all-gdb: maybe-all-libdecnumber
 all-gdb: maybe-all-libctf
+all-gdbserver: maybe-all-libiberty
 configure-gdbsupport: maybe-configure-bfd
 all-gdbsupport: maybe-all-bfd
 configure-gprof: maybe-configure-intl
diff --git a/gdbserver/Makefile.in b/gdbserver/Makefile.in
index 60a52d3412b..e0f50d2f3e4 100644
--- a/gdbserver/Makefile.in
+++ b/gdbserver/Makefile.in
@@ -97,7 +97,7 @@  CC_LD = $(CXX) $(CXX_DIALECT)
 INCLUDE_DIR = ${srcdir}/../include
 INCLUDE_DEP = $$(INCLUDE_DIR)
 
-LIBIBERTY_BUILDDIR = build-libiberty-gdbserver
+LIBIBERTY_BUILDDIR = ../libiberty
 LIBIBERTY = $(LIBIBERTY_BUILDDIR)/libiberty.a
 
 # Where is ust?  These will be empty if ust was not available.
@@ -105,14 +105,10 @@  ustlibs = @ustlibs@
 ustinc = @ustinc@
 
 # gnulib
-GNULIB_BUILDDIR = build-gnulib-gdbserver
+GNULIB_BUILDDIR = ../gnulib
 LIBGNU = $(GNULIB_BUILDDIR)/import/libgnu.a
 INCGNU = -I$(srcdir)/../gnulib/import -I$(GNULIB_BUILDDIR)/import
 
-# Generated headers in the gnulib directory.  These must be listed
-# so that they are generated before other files are compiled.
-GNULIB_H = $(GNULIB_BUILDDIR)/import/string.h @GNULIB_STDINT_H@
-
 INCSUPPORT = -I$(srcdir)/.. -I..
 
 # All the includes used for CFLAGS and for lint.
@@ -329,15 +325,6 @@  XML_BUILTIN = @srv_xmlbuiltin@
 IPA_DEPFILES = @IPA_DEPFILES@
 extra_libraries = @extra_libraries@
 
-SUBDIRS = $(GNULIB_BUILDDIR) $(LIBIBERTY_BUILDDIR)
-CLEANDIRS = $(SUBDIRS)
-
-# List of subdirectories in the build tree that must exist.
-# This is used to force build failures in existing trees when
-# a new directory is added.
-# The format here is for the `case' shell command.
-REQUIRED_SUBDIRS = $(GNULIB_BUILDDIR) | $(LIBIBERTY_BUILDDIR)
-
 FLAGS_TO_PASS = \
 	"prefix=$(prefix)" \
 	"exec_prefix=$(exec_prefix)" \
@@ -371,10 +358,9 @@  FLAGS_TO_PASS = \
 	"RUNTESTFLAGS=$(RUNTESTFLAGS)"
 
 # All generated files which can be included by another file.
-generated_files = config.h $(GNULIB_H)
+generated_files = config.h
 
 all: gdbserver$(EXEEXT) gdbreplay$(EXEEXT) $(extra_libraries)
-	@$(MAKE) $(FLAGS_TO_PASS) DO=$@ "DODIRS=$(SUBDIRS)" subdir_do
 
 # Traditionally "install" depends on "all".  But it may be useful
 # not to; for example, if the user has made some trivial change to a
@@ -393,10 +379,6 @@  install-only:
 	fi; \
 	$(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(bindir); \
 	$(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) gdbserver$(EXEEXT) $(DESTDIR)$(bindir)/$$n$(EXEEXT)
-	# Note that we run install and not install-only, as the latter
-	# is not part of GNU standards and in particular not provided
-	# in libiberty.
-	@$(MAKE) $(FLAGS_TO_PASS) DO=install "DODIRS=$(SUBDIRS)" subdir_do
 
 install-strip:
 	$(MAKE) $(FLAGS_TO_PASS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
@@ -408,7 +390,6 @@  uninstall: force
 	n=`echo gdbserver | sed '$(program_transform_name)'`; \
 	if [ x$$n = x ]; then n=gdbserver; else true; fi; \
 	rm -f $(DESTDIR)/$(bindir)/$$n$(EXEEXT) $(DESTDIR)$(man1dir)/$$n.1
-	@$(MAKE) $(FLAGS_TO_PASS) DO=$@ "DODIRS=$(SUBDIRS)" subdir_do
 
 installcheck:
 check:
@@ -417,8 +398,7 @@  install-info:
 install-pdf:
 html:
 install-html:
-clean-info: force
-	@$(MAKE) $(FLAGS_TO_PASS) DO=$@ "DODIRS=$(SUBDIRS)" subdir_do
+clean-info:
 
 gdbserver$(EXEEXT): $(sort $(OBS)) ${CDEPS} $(LIBGNU) $(LIBIBERTY)
 	$(SILENCE) rm -f gdbserver$(EXEEXT)
@@ -426,11 +406,6 @@  gdbserver$(EXEEXT): $(sort $(OBS)) ${CDEPS} $(LIBGNU) $(LIBIBERTY)
 		-o gdbserver$(EXEEXT) $(OBS) $(LIBGNU) $(LIBIBERTY) \
 		$(GDBSERVER_LIBS) $(XM_CLIBS)
 
-$(LIBGNU) $(LIBIBERTY) $(GNULIB_H): all-lib
-all-lib: $(GNULIB_BUILDDIR)/Makefile $(LIBIBERTY_BUILDDIR)/Makefile
-	@$(MAKE) $(FLAGS_TO_PASS) DO=all DODIRS="$(SUBDIRS)" subdir_do
-.PHONY: all-lib
-
 gdbreplay$(EXEEXT): $(sort $(GDBREPLAY_OBS)) $(LIBGNU) $(LIBIBERTY)
 	$(SILENCE) rm -f gdbreplay$(EXEEXT)
 	$(ECHO_CXXLD) $(CC_LD) $(INTERNAL_CFLAGS) $(INTERNAL_LDFLAGS) \
@@ -488,33 +463,14 @@  clean:
 		rm -f $$i/*.o;	\
 		rm -f $$i/$(DEPDIR)/*; \
 	done
-	@$(MAKE) $(FLAGS_TO_PASS) DO=$@ "DODIRS=$(SUBDIRS)" subdir_do
 
 maintainer-clean realclean distclean: clean
-	@$(MAKE) $(FLAGS_TO_PASS) DO=$@ "DODIRS=$(SUBDIRS)" subdir_do
-	rm -rf $(GNULIB_BUILDDIR)
 	rm -f Makefile config.status config.h stamp-h config.log
 	rm -f Makefile
 	for i in $(CONFIG_SRC_SUBDIR); do \
 		rmdir $$i/$(DEPDIR); \
 	done
 
-subdir_do: force
-	@for i in $(DODIRS); do \
-		case $$i in \
-		$(REQUIRED_SUBDIRS)) \
-			if [ ! -f ./$$i/Makefile ] ; then \
-				echo "Missing $$i/Makefile" >&2 ; \
-				exit 1 ; \
-			fi ;; \
-		esac ; \
-		if [ -f ./$$i/Makefile ] ; then \
-			if (cd ./$$i; \
-				$(MAKE) $(FLAGS_TO_PASS) $(DO)) ; then true ; \
-			else exit 1 ; fi ; \
-		else true ; fi ; \
-	done
-
 config.h: stamp-h ; @true
 stamp-h: config.in config.status
 	$(SHELL) ./config.status config.h
@@ -522,13 +478,6 @@  stamp-h: config.in config.status
 Makefile: Makefile.in config.status
 	$(SHELL) ./config.status $@
 
-$(GNULIB_BUILDDIR)/Makefile: $(srcdir)/../gnulib/Makefile.in config.status
-	  @cd $(GNULIB_BUILDDIR); CONFIG_FILES="Makefile" \
-	  CONFIG_COMMANDS="depfiles" \
-	  CONFIG_HEADERS= \
-	  CONFIG_LINKS= \
-	  $(SHELL) config.status
-
 config.status: configure configure.srv $(srcdir)/../bfd/development.sh
 	$(SHELL) ./config.status --recheck
 
diff --git a/gdbserver/configure b/gdbserver/configure
index 4b9d7e3718f..eb8aa80c2c5 100755
--- a/gdbserver/configure
+++ b/gdbserver/configure
@@ -6243,223 +6243,6 @@  else CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type
 fi
 
 
-gnulib_extra_configure_args=
-# If large-file support is disabled, make sure gnulib does the same.
-if test "$enable_largefile" = no; then
-gnulib_extra_configure_args="$gnulib_extra_configure_args --disable-largefile"
-fi
-
-# Configure gnulib.  We can't use AC_CONFIG_SUBDIRS as that'd expect
-# to find the the source subdir to be configured directly under
-# gdbserver/.  We need to build gnulib under some other directory not
-# "gnulib", to avoid the problem of both GDB and GDBserver wanting to
-# build it in the same directory, when building in the source dir.
-
-  in_src="../gnulib"
-  in_build="build-gnulib-gdbserver"
-  in_extra_args="$gnulib_extra_configure_args"
-
-  # Remove --cache-file, --srcdir, and --disable-option-checking arguments
-  # so they do not pile up.
-  ac_sub_configure_args=
-  ac_prev=
-  eval "set x $ac_configure_args"
-  shift
-  for ac_arg
-  do
-    if test -n "$ac_prev"; then
-      ac_prev=
-      continue
-    fi
-    case $ac_arg in
-    -cache-file | --cache-file | --cache-fil | --cache-fi \
-    | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
-      ac_prev=cache_file ;;
-    -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
-    | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* \
-    | --c=*)
-      ;;
-    --config-cache | -C)
-      ;;
-    -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
-      ac_prev=srcdir ;;
-    -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
-      ;;
-    -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
-      ac_prev=prefix ;;
-    -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
-      ;;
-    --disable-option-checking)
-      ;;
-    *)
-      case $ac_arg in
-      *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
-      esac
-      as_fn_append ac_sub_configure_args " '$ac_arg'" ;;
-    esac
-  done
-
-  # Always prepend --prefix to ensure using the same prefix
-  # in subdir configurations.
-  ac_arg="--prefix=$prefix"
-  case $ac_arg in
-  *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
-  esac
-  ac_sub_configure_args="'$ac_arg' $ac_sub_configure_args"
-
-  # Pass --silent
-  if test "$silent" = yes; then
-    ac_sub_configure_args="--silent $ac_sub_configure_args"
-  fi
-
-  # Always prepend --disable-option-checking to silence warnings, since
-  # different subdirs can have different --enable and --with options.
-  ac_sub_configure_args="--disable-option-checking $ac_sub_configure_args"
-
-  ac_popdir=`pwd`
-  ac_dir=$in_build
-
-  ac_msg="=== configuring in $ac_dir (`pwd`/$ac_dir)"
-  $as_echo "$as_me:${as_lineno-$LINENO}: $ac_msg" >&5
-  $as_echo "$ac_msg" >&6
-  as_dir="$ac_dir"; as_fn_mkdir_p
-
-  case $srcdir in
-  [\\/]* | ?:[\\/]* )
-    ac_srcdir=$srcdir/$in_src ;;
-  *) # Relative name.
-    ac_srcdir=../$srcdir/$in_src ;;
-  esac
-
-  cd "$ac_dir"
-
-  ac_sub_configure=$ac_srcdir/configure
-
-  # Make the cache file name correct relative to the subdirectory.
-  case $cache_file in
-  [\\/]* | ?:[\\/]* ) ac_sub_cache_file=$cache_file ;;
-  *) # Relative name.
-    ac_sub_cache_file=$ac_top_build_prefix$cache_file ;;
-  esac
-
-  if test -n "$in_extra_args"; then
-    # Add the extra args at the end.
-    ac_sub_configure_args="$ac_sub_configure_args $in_extra_args"
-  fi
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: running $SHELL $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir" >&5
-$as_echo "$as_me: running $SHELL $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir" >&6;}
-  # The eval makes quoting arguments work.
-  eval "\$SHELL \"\$ac_sub_configure\" $ac_sub_configure_args \
-       --cache-file=\"\$ac_sub_cache_file\" --srcdir=\"\$ac_srcdir\"" ||
-    as_fn_error $? "$ac_sub_configure failed for $ac_dir" "$LINENO" 5
-
-  cd "$ac_popdir"
-
-
-
-  in_src="../libiberty"
-  in_build="build-libiberty-gdbserver"
-  in_extra_args=
-
-  # Remove --cache-file, --srcdir, and --disable-option-checking arguments
-  # so they do not pile up.
-  ac_sub_configure_args=
-  ac_prev=
-  eval "set x $ac_configure_args"
-  shift
-  for ac_arg
-  do
-    if test -n "$ac_prev"; then
-      ac_prev=
-      continue
-    fi
-    case $ac_arg in
-    -cache-file | --cache-file | --cache-fil | --cache-fi \
-    | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
-      ac_prev=cache_file ;;
-    -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
-    | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* \
-    | --c=*)
-      ;;
-    --config-cache | -C)
-      ;;
-    -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
-      ac_prev=srcdir ;;
-    -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
-      ;;
-    -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
-      ac_prev=prefix ;;
-    -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
-      ;;
-    --disable-option-checking)
-      ;;
-    *)
-      case $ac_arg in
-      *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
-      esac
-      as_fn_append ac_sub_configure_args " '$ac_arg'" ;;
-    esac
-  done
-
-  # Always prepend --prefix to ensure using the same prefix
-  # in subdir configurations.
-  ac_arg="--prefix=$prefix"
-  case $ac_arg in
-  *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
-  esac
-  ac_sub_configure_args="'$ac_arg' $ac_sub_configure_args"
-
-  # Pass --silent
-  if test "$silent" = yes; then
-    ac_sub_configure_args="--silent $ac_sub_configure_args"
-  fi
-
-  # Always prepend --disable-option-checking to silence warnings, since
-  # different subdirs can have different --enable and --with options.
-  ac_sub_configure_args="--disable-option-checking $ac_sub_configure_args"
-
-  ac_popdir=`pwd`
-  ac_dir=$in_build
-
-  ac_msg="=== configuring in $ac_dir (`pwd`/$ac_dir)"
-  $as_echo "$as_me:${as_lineno-$LINENO}: $ac_msg" >&5
-  $as_echo "$ac_msg" >&6
-  as_dir="$ac_dir"; as_fn_mkdir_p
-
-  case $srcdir in
-  [\\/]* | ?:[\\/]* )
-    ac_srcdir=$srcdir/$in_src ;;
-  *) # Relative name.
-    ac_srcdir=../$srcdir/$in_src ;;
-  esac
-
-  cd "$ac_dir"
-
-  ac_sub_configure=$ac_srcdir/configure
-
-  # Make the cache file name correct relative to the subdirectory.
-  case $cache_file in
-  [\\/]* | ?:[\\/]* ) ac_sub_cache_file=$cache_file ;;
-  *) # Relative name.
-    ac_sub_cache_file=$ac_top_build_prefix$cache_file ;;
-  esac
-
-  if test -n "$in_extra_args"; then
-    # Add the extra args at the end.
-    ac_sub_configure_args="$ac_sub_configure_args $in_extra_args"
-  fi
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: running $SHELL $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir" >&5
-$as_echo "$as_me: running $SHELL $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir" >&6;}
-  # The eval makes quoting arguments work.
-  eval "\$SHELL \"\$ac_sub_configure\" $ac_sub_configure_args \
-       --cache-file=\"\$ac_sub_cache_file\" --srcdir=\"\$ac_srcdir\"" ||
-    as_fn_error $? "$ac_sub_configure failed for $ac_dir" "$LINENO" 5
-
-  cd "$ac_popdir"
-
-
 for ac_header in termios.h sys/reg.h string.h 		 sys/procfs.h linux/elf.h 		 fcntl.h signal.h sys/file.h 		 sys/ioctl.h netinet/in.h sys/socket.h netdb.h 		 netinet/tcp.h arpa/inet.h
 do :
   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
@@ -10838,7 +10621,7 @@  fi
 
 
 
-GNULIB=build-gnulib-gdbserver/import
+GNULIB=../gnulib/import
 
 GNULIB_STDINT_H=
 if test x"$STDINT_H" != x; then
diff --git a/gdbserver/configure.ac b/gdbserver/configure.ac
index 285a297a1c6..cbd12ea2ed0 100644
--- a/gdbserver/configure.ac
+++ b/gdbserver/configure.ac
@@ -69,22 +69,6 @@  AC_CONFIG_COMMANDS([gdbdepdir],[
 
 ZW_PROG_COMPILER_DEPENDENCIES([CC])
 
-gnulib_extra_configure_args=
-# If large-file support is disabled, make sure gnulib does the same.
-if test "$enable_largefile" = no; then
-gnulib_extra_configure_args="$gnulib_extra_configure_args --disable-largefile"
-fi
-
-# Configure gnulib.  We can't use AC_CONFIG_SUBDIRS as that'd expect
-# to find the the source subdir to be configured directly under
-# gdbserver/.  We need to build gnulib under some other directory not
-# "gnulib", to avoid the problem of both GDB and GDBserver wanting to
-# build it in the same directory, when building in the source dir.
-ACX_CONFIGURE_DIR(["../gnulib"], ["build-gnulib-gdbserver"],
-                  ["$gnulib_extra_configure_args"])
-
-ACX_CONFIGURE_DIR(["../libiberty"], ["build-libiberty-gdbserver"])
-
 AC_CHECK_HEADERS(termios.h sys/reg.h string.h dnl
 		 sys/procfs.h linux/elf.h dnl
 		 fcntl.h signal.h sys/file.h dnl
@@ -432,7 +416,7 @@  AC_SUBST(srv_xmlfiles)
 AC_SUBST(IPA_DEPFILES)
 AC_SUBST(extra_libraries)
 
-GNULIB=build-gnulib-gdbserver/import
+GNULIB=../gnulib/import
 
 GNULIB_STDINT_H=
 if test x"$STDINT_H" != x; then
diff --git a/gdbsupport/common-defs.h b/gdbsupport/common-defs.h
index 027bf099c1a..a5c57de2f27 100644
--- a/gdbsupport/common-defs.h
+++ b/gdbsupport/common-defs.h
@@ -22,7 +22,7 @@ 
 
 #ifdef GDBSERVER
 
-#include <build-gnulib-gdbserver/config.h>
+#include <gnulib/config.h>
 
 #undef PACKAGE_NAME
 #undef PACKAGE