public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [RFC 0/2] let gdbserver use libiberty
@ 2014-01-20 18:49 Tom Tromey
  2014-01-20 18:49 ` [RFC 2/2] delete gdbserver's freeargv Tom Tromey
                   ` (3 more replies)
  0 siblings, 4 replies; 23+ messages in thread
From: Tom Tromey @ 2014-01-20 18:49 UTC (permalink / raw)
  To: gdb-patches

This series changes gdbserver to build its own copy of libiberty
(using ACX_CONFIGURE_DIR) and then link against it.  I've needed this
at least once (for a cloexec patch) and I've seen other situations
where it would have been useful.

This is of course not the ideal way to depend on libiberty -- better
would be to use the same build that gdb uses.  However, due to the
requirement that gdbserver be separately configurable, this is the
best that can be done immediately.

FWIW I do have a branch to move common, gnulib, and gdbserver to
top-level.  However, that branch still has some issues to be sorted
out (namely, what to rename "common", and how to compute the
definition of CORE_ADDR); and in any case a patch like this one would
be required at some point in the process -- and it seems useful to
have it sooner rather than later.

Built and regtested on x86-64 Fedora 18.

Tom

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

* [RFC 1/2] link gdbserver against libiberty
  2014-01-20 18:49 [RFC 0/2] let gdbserver use libiberty Tom Tromey
  2014-01-20 18:49 ` [RFC 2/2] delete gdbserver's freeargv Tom Tromey
@ 2014-01-20 18:49 ` Tom Tromey
  2014-01-21  1:49   ` Yao Qi
  2014-01-21  2:03   ` Yao Qi
  2014-01-20 18:54 ` [RFC 0/2] let gdbserver use libiberty Tom Tromey
  2014-06-12 20:37 ` Tom Tromey
  3 siblings, 2 replies; 23+ messages in thread
From: Tom Tromey @ 2014-01-20 18:49 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This builds a libiberty just for gdbserver and arranges for gdbserver
to use it.  I've tripped across the lack of libiberty in gdbserver at
least once, and I have seen other threads where it would have been
useful.

2014-01-20  Tom Tromey  <tromey@redhat.com>

	* Makefile.in (LIBIBERTY_BUILDDIR, LIBIBERTY): New variables.
	(SUBDIRS, REQUIRED_SUBDIRS): Add libiberty.
	(FLAGS_TO_PASS): Remove AR, AR_FLAGS
	(gdbserver$(EXEEXT), gdbreplay$(EXEEXT)): Depend on and link
	against libiberty.
	($(LIBGNU)): Depend on libiberty.
	(all-lib): Recurse into all subdirs.
	(vasprintf.o, vsnprintf.o, safe-ctype.o, lbasename.o): Remove
	targets.
	* configure: Rebuild.
	* configure.ac: Add ACX_CONFIGURE_DIR for libiberty.  Don't check
	for vasprintf or vsnprintf.
	* configure.srv: Don't add safe-ctype.o or lbasename.o to
	srv_tgtobj.
---
 gdb/gdbserver/ChangeLog     |  17 +++++++
 gdb/gdbserver/Makefile.in   |  40 +++++----------
 gdb/gdbserver/configure     | 120 ++++++++++++++++++++++++++++++++++++--------
 gdb/gdbserver/configure.ac  |   3 +-
 gdb/gdbserver/configure.srv |   6 ---
 5 files changed, 129 insertions(+), 57 deletions(-)

diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in
index e72ee6b..ec3b86c 100644
--- a/gdb/gdbserver/Makefile.in
+++ b/gdb/gdbserver/Makefile.in
@@ -83,6 +83,9 @@ CC-LD=${CC}
 INCLUDE_DIR =  ${srcdir}/../../include
 INCLUDE_DEP = $$(INCLUDE_DIR)
 
+LIBIBERTY_BUILDDIR = build-libiberty-gdbserver
+LIBIBERTY = $(LIBIBERTY_BUILDDIR)/libiberty.a
+
 # Where is ust?  These will be empty if ust was not available.
 ustlibs = @ustlibs@
 ustinc = @ustinc@
@@ -190,14 +193,14 @@ XML_BUILTIN = @srv_xmlbuiltin@
 IPA_DEPFILES = @IPA_DEPFILES@
 extra_libraries = @extra_libraries@
 
-SUBDIRS = $(GNULIB_BUILDDIR)
+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)
+REQUIRED_SUBDIRS = $(GNULIB_BUILDDIR) | $(LIBIBERTY_BUILDDIR)
 
 FLAGS_TO_PASS = \
 	"prefix=$(prefix)" \
@@ -213,8 +216,6 @@ FLAGS_TO_PASS = \
 	"includedir=$(includedir)" \
 	"against=$(against)" \
 	"DESTDIR=$(DESTDIR)" \
-	"AR=$(AR)" \
-	"AR_FLAGS=$(AR_FLAGS)" \
 	"CC=$(CC)" \
 	"CFLAGS=$(CFLAGS)" \
 	"CXX=$(CXX)" \
@@ -276,20 +277,20 @@ install-html:
 clean-info: force
 	@$(MAKE) $(FLAGS_TO_PASS) DO=$@ "DODIRS=$(SUBDIRS)" subdir_do
 
-gdbserver$(EXEEXT): $(OBS) ${ADD_DEPS} ${CDEPS} $(LIBGNU)
+gdbserver$(EXEEXT): $(OBS) ${ADD_DEPS} ${CDEPS} $(LIBGNU) $(LIBIBERTY)
 	rm -f gdbserver$(EXEEXT)
 	${CC-LD} $(INTERNAL_CFLAGS) $(INTERNAL_LDFLAGS) -o gdbserver$(EXEEXT) $(OBS) \
-	$(LIBGNU) $(GDBSERVER_LIBS) $(XM_CLIBS)
+	$(LIBGNU) $(LIBIBERTY) $(GDBSERVER_LIBS) $(XM_CLIBS)
 
-$(LIBGNU) $(GNULIB_H): all-lib
-all-lib: $(GNULIB_BUILDDIR)/Makefile
-	@$(MAKE) $(FLAGS_TO_PASS) DO=all DODIRS=$(GNULIB_BUILDDIR) subdir_do
+$(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): $(GDBREPLAY_OBS) $(LIBGNU)
+gdbreplay$(EXEEXT): $(GDBREPLAY_OBS) $(LIBGNU) $(LIBIBERTY)
 	rm -f gdbreplay$(EXEEXT)
 	${CC-LD} $(INTERNAL_CFLAGS) $(INTERNAL_LDFLAGS) -o gdbreplay$(EXEEXT) $(GDBREPLAY_OBS) \
-	  $(XM_CLIBS) $(LIBGNU)
+	  $(XM_CLIBS) $(LIBGNU) $(LIBIBERTY)
 
 IPA_OBJS=ax-ipa.o tracepoint-ipa.o format-ipa.o utils-ipa.o regcache-ipa.o remote-utils-ipa.o common-utils-ipa.o tdesc-ipa.o ${IPA_DEPFILES}
 
@@ -533,23 +534,6 @@ linux-waitpid.o: ../nat/linux-waitpid.c
 	$(COMPILE) $<
 	$(POSTCOMPILE)
 
-# We build vasprintf with -DHAVE_CONFIG_H because we want that unit to
-# include our config.h file.  Otherwise, some system headers do not get
-# included, and the compiler emits a warning about implicitly defined
-# functions (missing declaration).
-vasprintf.o: $(srcdir)/../../libiberty/vasprintf.c
-	$(COMPILE) $< -DHAVE_CONFIG_H
-	$(POSTCOMPILE)
-vsnprintf.o: $(srcdir)/../../libiberty/vsnprintf.c
-	$(COMPILE) $<
-	$(POSTCOMPILE)
-safe-ctype.o: $(srcdir)/../../libiberty/safe-ctype.c
-	$(COMPILE) $<
-	$(POSTCOMPILE)
-lbasename.o: $(srcdir)/../../libiberty/lbasename.c
-	$(COMPILE) $<
-	$(POSTCOMPILE)
-
 aarch64.c : $(srcdir)/../regformats/aarch64.dat $(regdat_sh)
 	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/aarch64.dat aarch64.c
 reg-arm.c : $(srcdir)/../regformats/reg-arm.dat $(regdat_sh)
diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure
index fac7fb3..3526b2f 100755
--- a/gdb/gdbserver/configure
+++ b/gdb/gdbserver/configure
@@ -589,6 +589,7 @@ ac_includes_default="\
 #endif"
 
 ac_subst_vars='LTLIBOBJS
+LIBOBJS
 GNULIB_STDINT_H
 extra_libraries
 IPA_DEPFILES
@@ -604,7 +605,6 @@ WERROR_CFLAGS
 WARN_CFLAGS
 ustinc
 ustlibs
-LIBOBJS
 SET_MAKE
 GMAKE_FALSE
 GMAKE_TRUE
@@ -4714,6 +4714,103 @@ $as_echo "$as_me: running $SHELL $ac_sub_configure $ac_sub_configure_args --cach
   cd "$ac_popdir"
 
 
+
+  in_src="../../libiberty"
+  in_build="build-libiberty-gdbserver"
+
+  # 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
+
+  { $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 sgtty.h termio.h termios.h sys/reg.h string.h 		 proc_service.h sys/procfs.h linux/elf.h 		 errno.h fcntl.h signal.h sys/file.h malloc.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`
@@ -4741,27 +4838,6 @@ _ACEOF
 fi
 done
 
-for ac_func in vasprintf vsnprintf
-do :
-  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
-ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-eval as_val=\$$as_ac_var
-   if test "x$as_val" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
-
-else
-  case " $LIBOBJS " in
-  *" $ac_func.$ac_objext "* ) ;;
-  *) LIBOBJS="$LIBOBJS $ac_func.$ac_objext"
- ;;
-esac
-
-fi
-done
-
-
 
 
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac
index dc8131c..4a845d8 100644
--- a/gdb/gdbserver/configure.ac
+++ b/gdb/gdbserver/configure.ac
@@ -77,13 +77,14 @@ AC_PROG_MAKE_SET
 # build it in the same directory, when building in the source dir.
 ACX_CONFIGURE_DIR(["../gnulib"], ["build-gnulib-gdbserver"])
 
+ACX_CONFIGURE_DIR(["../../libiberty"], ["build-libiberty-gdbserver"])
+
 AC_CHECK_HEADERS(sgtty.h termio.h termios.h sys/reg.h string.h dnl
 		 proc_service.h sys/procfs.h linux/elf.h dnl
 		 errno.h fcntl.h signal.h sys/file.h malloc.h dnl
 		 sys/ioctl.h netinet/in.h sys/socket.h netdb.h dnl
 		 netinet/tcp.h arpa/inet.h)
 AC_CHECK_FUNCS(pread pwrite pread64 readlink)
-AC_REPLACE_FUNCS(vasprintf vsnprintf)
 
 GDB_AC_COMMON
 
diff --git a/gdb/gdbserver/configure.srv b/gdb/gdbserver/configure.srv
index f4e6154..32d935a 100644
--- a/gdb/gdbserver/configure.srv
+++ b/gdb/gdbserver/configure.srv
@@ -77,7 +77,6 @@ case "${target}" in
 			;;
   arm*-*-mingw32ce*)	srv_regobj=reg-arm.o
 			srv_tgtobj="win32-low.o win32-arm-low.o"
-			srv_tgtobj="${srv_tgtobj} safe-ctype.o lbasename.o"
 			srv_tgtobj="${srv_tgtobj} wincecompat.o"
 			# hostio_last_error implementation is in win32-low.c
 			srv_hostio_err_objs=""
@@ -101,7 +100,6 @@ case "${target}" in
 			;;
   i[34567]86-*-cygwin*)	srv_regobj="$srv_i386_regobj"
 			srv_tgtobj="i386-low.o win32-low.o win32-i386-low.o"
-			srv_tgtobj="${srv_tgtobj} safe-ctype.o lbasename.o"
 			srv_xmlfiles="$srv_i386_xmlfiles"
 			;;
   i[34567]86-*-linux*)	srv_regobj="$srv_i386_linux_regobj"
@@ -128,7 +126,6 @@ case "${target}" in
   i[34567]86-*-mingw32ce*)
 			srv_regobj="$srv_i386_regobj"
 			srv_tgtobj="i386-low.o win32-low.o win32-i386-low.o"
-			srv_tgtobj="${srv_tgtobj} safe-ctype.o lbasename.o"
 			srv_tgtobj="${srv_tgtobj} wincecompat.o"
 			srv_xmlfiles="$srv_i386_xmlfiles"
 			# hostio_last_error implementation is in win32-low.c
@@ -138,7 +135,6 @@ case "${target}" in
 			;;
   i[34567]86-*-mingw*)	srv_regobj="$srv_i386_regobj"
 			srv_tgtobj="i386-low.o win32-low.o win32-i386-low.o"
-			srv_tgtobj="${srv_tgtobj} safe-ctype.o lbasename.o"
 			srv_xmlfiles="$srv_i386_xmlfiles"
 			srv_mingw=yes
 			;;
@@ -330,13 +326,11 @@ case "${target}" in
 			;;
   x86_64-*-mingw*)	srv_regobj="$srv_amd64_regobj"
 			srv_tgtobj="i386-low.o i387-fp.o win32-low.o win32-i386-low.o"
-			srv_tgtobj="${srv_tgtobj} safe-ctype.o lbasename.o"
 			srv_xmlfiles="$srv_i386_xmlfiles $srv_amd64_xmlfiles"
 			srv_mingw=yes
 			;;
   x86_64-*-cygwin*)	srv_regobj="$srv_amd64_regobj"
 			srv_tgtobj="i386-low.o i387-fp.o win32-low.o win32-i386-low.o"
-			srv_tgtobj="${srv_tgtobj} safe-ctype.o lbasename.o"
 			srv_xmlfiles="$srv_i386_xmlfiles"
 			;;
 
-- 
1.8.1.4

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

* [RFC 2/2] delete gdbserver's freeargv
  2014-01-20 18:49 [RFC 0/2] let gdbserver use libiberty Tom Tromey
@ 2014-01-20 18:49 ` Tom Tromey
  2014-02-07 16:35   ` Pedro Alves
  2014-01-20 18:49 ` [RFC 1/2] link gdbserver against libiberty Tom Tromey
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 23+ messages in thread
From: Tom Tromey @ 2014-01-20 18:49 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

gdbserver defines freeargv, but it is now trivial to just use the one
in libiberty.

2014-01-20  Tom Tromey  <tromey@redhat.com>

	* utils.c (freeargv): Remove.
---
 gdb/gdbserver/ChangeLog |  4 ++++
 gdb/gdbserver/utils.c   | 21 ---------------------
 2 files changed, 4 insertions(+), 21 deletions(-)

diff --git a/gdb/gdbserver/utils.c b/gdb/gdbserver/utils.c
index eff4499..dae351e 100644
--- a/gdb/gdbserver/utils.c
+++ b/gdb/gdbserver/utils.c
@@ -55,27 +55,6 @@ xstrdup (const char *s)
   return ret;
 }
 
-#ifndef IN_PROCESS_AGENT
-
-/* Free a standard argv vector.  */
-
-void
-freeargv (char **vector)
-{
-  char **scan;
-
-  if (vector != NULL)
-    {
-      for (scan = vector; *scan != NULL; scan++)
-	{
-	  free (*scan);
-	}
-      free (vector);
-    }
-}
-
-#endif
-
 /* Print the system error message for errno, and also mention STRING
    as the file name for which the error was encountered.
    Then return to command level.  */
-- 
1.8.1.4

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

* Re: [RFC 0/2] let gdbserver use libiberty
  2014-01-20 18:49 [RFC 0/2] let gdbserver use libiberty Tom Tromey
  2014-01-20 18:49 ` [RFC 2/2] delete gdbserver's freeargv Tom Tromey
  2014-01-20 18:49 ` [RFC 1/2] link gdbserver against libiberty Tom Tromey
@ 2014-01-20 18:54 ` Tom Tromey
  2014-06-12 20:37 ` Tom Tromey
  3 siblings, 0 replies; 23+ messages in thread
From: Tom Tromey @ 2014-01-20 18:54 UTC (permalink / raw)
  To: gdb-patches

>>>>> "Tom" == Tom Tromey <tromey@redhat.com> writes:

Tom> Built and regtested on x86-64 Fedora 18.

Sorry, I should have mentioned explicitly that I did this test using the
native-gdbserver target board.

Tom

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

* Re: [RFC 1/2] link gdbserver against libiberty
  2014-01-20 18:49 ` [RFC 1/2] link gdbserver against libiberty Tom Tromey
@ 2014-01-21  1:49   ` Yao Qi
  2014-01-21  2:33     ` Tom Tromey
  2014-02-07 14:49     ` Tom Tromey
  2014-01-21  2:03   ` Yao Qi
  1 sibling, 2 replies; 23+ messages in thread
From: Yao Qi @ 2014-01-21  1:49 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 01/21/2014 02:49 AM, Tom Tromey wrote:
> 2014-01-20  Tom Tromey  <tromey@redhat.com>
> 
> 	* Makefile.in (LIBIBERTY_BUILDDIR, LIBIBERTY): New variables.
> 	(SUBDIRS, REQUIRED_SUBDIRS): Add libiberty.
> 	(FLAGS_TO_PASS): Remove AR, AR_FLAGS

period is missing ...

>  
>  FLAGS_TO_PASS = \
>  	"prefix=$(prefix)" \
> @@ -213,8 +216,6 @@ FLAGS_TO_PASS = \
>  	"includedir=$(includedir)" \
>  	"against=$(against)" \
>  	"DESTDIR=$(DESTDIR)" \
> -	"AR=$(AR)" \
> -	"AR_FLAGS=$(AR_FLAGS)" \
>  	"CC=$(CC)" \
>  	"CFLAGS=$(CFLAGS)" \
>  	"CXX=$(CXX)" \

... and I don't understand why do we remove AR and AR_FLAGS from
FLAGS_TO_PASS.

-- 
Yao (齐尧)

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

* Re: [RFC 1/2] link gdbserver against libiberty
  2014-01-20 18:49 ` [RFC 1/2] link gdbserver against libiberty Tom Tromey
  2014-01-21  1:49   ` Yao Qi
@ 2014-01-21  2:03   ` Yao Qi
  1 sibling, 0 replies; 23+ messages in thread
From: Yao Qi @ 2014-01-21  2:03 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 01/21/2014 02:49 AM, Tom Tromey wrote:
> 2014-01-20  Tom Tromey  <tromey@redhat.com>
> 
> 	* Makefile.in (LIBIBERTY_BUILDDIR, LIBIBERTY): New variables.
> 	(SUBDIRS, REQUIRED_SUBDIRS): Add libiberty.
> 	(FLAGS_TO_PASS): Remove AR, AR_FLAGS

period is missing ...

>  
>  FLAGS_TO_PASS = \
>  	"prefix=$(prefix)" \
> @@ -213,8 +216,6 @@ FLAGS_TO_PASS = \
>  	"includedir=$(includedir)" \
>  	"against=$(against)" \
>  	"DESTDIR=$(DESTDIR)" \
> -	"AR=$(AR)" \
> -	"AR_FLAGS=$(AR_FLAGS)" \
>  	"CC=$(CC)" \
>  	"CFLAGS=$(CFLAGS)" \
>  	"CXX=$(CXX)" \

... and I don't understand why do we remove AR and AR_FLAGS from
FLAGS_TO_PASS.

-- 
Yao (齐尧)

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

* Re: [RFC 1/2] link gdbserver against libiberty
  2014-01-21  1:49   ` Yao Qi
@ 2014-01-21  2:33     ` Tom Tromey
  2014-02-07 14:49     ` Tom Tromey
  1 sibling, 0 replies; 23+ messages in thread
From: Tom Tromey @ 2014-01-21  2:33 UTC (permalink / raw)
  To: Yao Qi; +Cc: gdb-patches

>> -	"AR=$(AR)" \
>> -	"AR_FLAGS=$(AR_FLAGS)" \

Yao> ... and I don't understand why do we remove AR and AR_FLAGS from
Yao> FLAGS_TO_PASS.

Passing them in this way causes AR_FLAGS to be empty when the build
finally reaches gdbserver's subdir build of libiberty.  This cause a
build failure.

That isn't really a satisfactory answer.  I will dig deeper.

Tom

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

* Re: [RFC 1/2] link gdbserver against libiberty
  2014-01-21  1:49   ` Yao Qi
  2014-01-21  2:33     ` Tom Tromey
@ 2014-02-07 14:49     ` Tom Tromey
  2014-02-07 16:32       ` Pedro Alves
  2014-02-08  2:36       ` Yao Qi
  1 sibling, 2 replies; 23+ messages in thread
From: Tom Tromey @ 2014-02-07 14:49 UTC (permalink / raw)
  To: Yao Qi; +Cc: gdb-patches

Yao> ... and I don't understand why do we remove AR and AR_FLAGS from
Yao> FLAGS_TO_PASS.

I don't remember any more, either.
I restored them and rebuilt and it all worked fine.
I did discover that my earlier patch had broken "make install"; fixed in
this version.

Tom

commit 5c5cd49434296e33d4b7ef160f37cc01f17d9b20
Author: Tom Tromey <tromey@redhat.com>
Date:   Sun Jan 19 14:33:37 2014 -0700

    link gdbserver against libiberty
    
    This builds a libiberty just for gdbserver and arranges for gdbserver
    to use it.  I've tripped across the lack of libiberty in gdbserver at
    least once, and I have seen other threads where it would have been
    useful.
    
    2014-02-07  Tom Tromey  <tromey@redhat.com>
    
    	* debug.c (debug_printf): Remove HAVE_GETTIMEOFDAY checks.
    	* server.c (monitor_show_help): Remove HAVE_GETTIMEOFDAY check.
    	(parse_debug_format_options): Likewise.
    	(gdbserver_usage): Likewise.
    	* Makefile.in (LIBIBERTY_BUILDDIR, LIBIBERTY, INSTALLDIRS): New
    	variables.
    	(SUBDIRS, REQUIRED_SUBDIRS): Add libiberty.
    	(gdbserver$(EXEEXT), gdbreplay$(EXEEXT)): Depend on and link
    	against libiberty.
    	($(LIBGNU)): Depend on libiberty.
    	(all-lib): Recurse into all subdirs.
    	(install-only, uninstall): Recurse using INSTALLDIRS.
    	(vasprintf.o, vsnprintf.o, safe-ctype.o, lbasename.o): Remove
    	targets.
    	* configure: Rebuild.
    	* configure.ac: Add ACX_CONFIGURE_DIR for libiberty.  Don't check
    	for vasprintf, vsnprintf, or gettimeofday.
    	* configure.srv: Don't add safe-ctype.o or lbasename.o to
    	srv_tgtobj.

diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in
index c172995..7a71120 100644
--- a/gdb/gdbserver/Makefile.in
+++ b/gdb/gdbserver/Makefile.in
@@ -83,6 +83,9 @@ CC-LD=${CC}
 INCLUDE_DIR =  ${srcdir}/../../include
 INCLUDE_DEP = $$(INCLUDE_DIR)
 
+LIBIBERTY_BUILDDIR = build-libiberty-gdbserver
+LIBIBERTY = $(LIBIBERTY_BUILDDIR)/libiberty.a
+
 # Where is ust?  These will be empty if ust was not available.
 ustlibs = @ustlibs@
 ustinc = @ustinc@
@@ -190,14 +193,15 @@ XML_BUILTIN = @srv_xmlbuiltin@
 IPA_DEPFILES = @IPA_DEPFILES@
 extra_libraries = @extra_libraries@
 
-SUBDIRS = $(GNULIB_BUILDDIR)
+SUBDIRS = $(GNULIB_BUILDDIR) $(LIBIBERTY_BUILDDIR)
 CLEANDIRS = $(SUBDIRS)
+INSTALLDIRS = $(GNULIB_BUILDDIR)
 
 # 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)
+REQUIRED_SUBDIRS = $(GNULIB_BUILDDIR) | $(LIBIBERTY_BUILDDIR)
 
 FLAGS_TO_PASS = \
 	"prefix=$(prefix)" \
@@ -258,13 +262,13 @@ install-only:
 	fi; \
 	$(SHELL) $(srcdir)/../../mkinstalldirs $(DESTDIR)$(bindir); \
 	$(INSTALL_PROGRAM) gdbserver$(EXEEXT) $(DESTDIR)$(bindir)/$$n$(EXEEXT)
-	@$(MAKE) $(FLAGS_TO_PASS) DO=$@ "DODIRS=$(SUBDIRS)" subdir_do
+	@$(MAKE) $(FLAGS_TO_PASS) DO=$@ "DODIRS=$(INSTALLDIRS)" subdir_do
 
 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
+	@$(MAKE) $(FLAGS_TO_PASS) DO=$@ "DODIRS=$(INSTALLDIRS)" subdir_do
 
 installcheck:
 check:
@@ -276,20 +280,20 @@ install-html:
 clean-info: force
 	@$(MAKE) $(FLAGS_TO_PASS) DO=$@ "DODIRS=$(SUBDIRS)" subdir_do
 
-gdbserver$(EXEEXT): $(OBS) ${ADD_DEPS} ${CDEPS} $(LIBGNU)
+gdbserver$(EXEEXT): $(OBS) ${ADD_DEPS} ${CDEPS} $(LIBGNU) $(LIBIBERTY)
 	rm -f gdbserver$(EXEEXT)
 	${CC-LD} $(INTERNAL_CFLAGS) $(INTERNAL_LDFLAGS) -o gdbserver$(EXEEXT) $(OBS) \
-	$(LIBGNU) $(GDBSERVER_LIBS) $(XM_CLIBS)
+	$(LIBGNU) $(LIBIBERTY) $(GDBSERVER_LIBS) $(XM_CLIBS)
 
-$(LIBGNU) $(GNULIB_H): all-lib
-all-lib: $(GNULIB_BUILDDIR)/Makefile
-	@$(MAKE) $(FLAGS_TO_PASS) DO=all DODIRS=$(GNULIB_BUILDDIR) subdir_do
+$(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): $(GDBREPLAY_OBS) $(LIBGNU)
+gdbreplay$(EXEEXT): $(GDBREPLAY_OBS) $(LIBGNU) $(LIBIBERTY)
 	rm -f gdbreplay$(EXEEXT)
 	${CC-LD} $(INTERNAL_CFLAGS) $(INTERNAL_LDFLAGS) -o gdbreplay$(EXEEXT) $(GDBREPLAY_OBS) \
-	  $(XM_CLIBS) $(LIBGNU)
+	  $(XM_CLIBS) $(LIBGNU) $(LIBIBERTY)
 
 IPA_OBJS=ax-ipa.o tracepoint-ipa.o format-ipa.o utils-ipa.o regcache-ipa.o remote-utils-ipa.o common-utils-ipa.o tdesc-ipa.o ${IPA_DEPFILES}
 
@@ -533,23 +537,6 @@ linux-waitpid.o: ../nat/linux-waitpid.c
 	$(COMPILE) $<
 	$(POSTCOMPILE)
 
-# We build vasprintf with -DHAVE_CONFIG_H because we want that unit to
-# include our config.h file.  Otherwise, some system headers do not get
-# included, and the compiler emits a warning about implicitly defined
-# functions (missing declaration).
-vasprintf.o: $(srcdir)/../../libiberty/vasprintf.c
-	$(COMPILE) $< -DHAVE_CONFIG_H
-	$(POSTCOMPILE)
-vsnprintf.o: $(srcdir)/../../libiberty/vsnprintf.c
-	$(COMPILE) $<
-	$(POSTCOMPILE)
-safe-ctype.o: $(srcdir)/../../libiberty/safe-ctype.c
-	$(COMPILE) $<
-	$(POSTCOMPILE)
-lbasename.o: $(srcdir)/../../libiberty/lbasename.c
-	$(COMPILE) $<
-	$(POSTCOMPILE)
-
 aarch64.c : $(srcdir)/../regformats/aarch64.dat $(regdat_sh)
 	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/aarch64.dat aarch64.c
 reg-arm.c : $(srcdir)/../regformats/reg-arm.dat $(regdat_sh)
diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac
index 0dfa4a9..16360c0 100644
--- a/gdb/gdbserver/configure.ac
+++ b/gdb/gdbserver/configure.ac
@@ -77,12 +77,14 @@ AC_PROG_MAKE_SET
 # build it in the same directory, when building in the source dir.
 ACX_CONFIGURE_DIR(["../gnulib"], ["build-gnulib-gdbserver"])
 
+ACX_CONFIGURE_DIR(["../../libiberty"], ["build-libiberty-gdbserver"])
+
 AC_CHECK_HEADERS(sgtty.h termio.h termios.h sys/reg.h string.h dnl
 		 proc_service.h sys/procfs.h linux/elf.h dnl
 		 errno.h fcntl.h signal.h sys/file.h malloc.h dnl
 		 sys/ioctl.h netinet/in.h sys/socket.h netdb.h dnl
 		 netinet/tcp.h arpa/inet.h)
-AC_CHECK_FUNCS(gettimeofday pread pwrite pread64 readlink)
+AC_CHECK_FUNCS(pread pwrite pread64 readlink)
 AC_REPLACE_FUNCS(vasprintf vsnprintf)
 
 GDB_AC_COMMON
diff --git a/gdb/gdbserver/configure.srv b/gdb/gdbserver/configure.srv
index f4e6154..32d935a 100644
--- a/gdb/gdbserver/configure.srv
+++ b/gdb/gdbserver/configure.srv
@@ -77,7 +77,6 @@ case "${target}" in
 			;;
   arm*-*-mingw32ce*)	srv_regobj=reg-arm.o
 			srv_tgtobj="win32-low.o win32-arm-low.o"
-			srv_tgtobj="${srv_tgtobj} safe-ctype.o lbasename.o"
 			srv_tgtobj="${srv_tgtobj} wincecompat.o"
 			# hostio_last_error implementation is in win32-low.c
 			srv_hostio_err_objs=""
@@ -101,7 +100,6 @@ case "${target}" in
 			;;
   i[34567]86-*-cygwin*)	srv_regobj="$srv_i386_regobj"
 			srv_tgtobj="i386-low.o win32-low.o win32-i386-low.o"
-			srv_tgtobj="${srv_tgtobj} safe-ctype.o lbasename.o"
 			srv_xmlfiles="$srv_i386_xmlfiles"
 			;;
   i[34567]86-*-linux*)	srv_regobj="$srv_i386_linux_regobj"
@@ -128,7 +126,6 @@ case "${target}" in
   i[34567]86-*-mingw32ce*)
 			srv_regobj="$srv_i386_regobj"
 			srv_tgtobj="i386-low.o win32-low.o win32-i386-low.o"
-			srv_tgtobj="${srv_tgtobj} safe-ctype.o lbasename.o"
 			srv_tgtobj="${srv_tgtobj} wincecompat.o"
 			srv_xmlfiles="$srv_i386_xmlfiles"
 			# hostio_last_error implementation is in win32-low.c
@@ -138,7 +135,6 @@ case "${target}" in
 			;;
   i[34567]86-*-mingw*)	srv_regobj="$srv_i386_regobj"
 			srv_tgtobj="i386-low.o win32-low.o win32-i386-low.o"
-			srv_tgtobj="${srv_tgtobj} safe-ctype.o lbasename.o"
 			srv_xmlfiles="$srv_i386_xmlfiles"
 			srv_mingw=yes
 			;;
@@ -330,13 +326,11 @@ case "${target}" in
 			;;
   x86_64-*-mingw*)	srv_regobj="$srv_amd64_regobj"
 			srv_tgtobj="i386-low.o i387-fp.o win32-low.o win32-i386-low.o"
-			srv_tgtobj="${srv_tgtobj} safe-ctype.o lbasename.o"
 			srv_xmlfiles="$srv_i386_xmlfiles $srv_amd64_xmlfiles"
 			srv_mingw=yes
 			;;
   x86_64-*-cygwin*)	srv_regobj="$srv_amd64_regobj"
 			srv_tgtobj="i386-low.o i387-fp.o win32-low.o win32-i386-low.o"
-			srv_tgtobj="${srv_tgtobj} safe-ctype.o lbasename.o"
 			srv_xmlfiles="$srv_i386_xmlfiles"
 			;;
 
diff --git a/gdb/gdbserver/debug.c b/gdb/gdbserver/debug.c
index 6f4d531..c50af76 100644
--- a/gdb/gdbserver/debug.c
+++ b/gdb/gdbserver/debug.c
@@ -36,7 +36,7 @@ void
 debug_printf (const char *msg, ...)
 {
   va_list args;
-#if defined (HAVE_GETTIMEOFDAY) && !defined (IN_PROCESS_AGENT)
+#if !defined (IN_PROCESS_AGENT)
   /* N.B. Not thread safe, and can't be used, as is, with IPA.  */
   static int new_line = 1;
 
@@ -57,7 +57,7 @@ debug_printf (const char *msg, ...)
   vfprintf (stderr, msg, args);
   va_end (args);
 
-#if defined (HAVE_GETTIMEOFDAY) && !defined (IN_PROCESS_AGENT)
+#if !defined (IN_PROCESS_AGENT)
   if (*msg)
     new_line = msg[strlen (msg) - 1] == '\n';
 #endif
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index 88354be..314cc92 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -695,9 +695,7 @@ monitor_show_help (void)
   monitor_output ("  set debug-format option1[,option2,...]\n");
   monitor_output ("    Add additional information to debugging messages\n");
   monitor_output ("    Options: all, none");
-#ifdef HAVE_GETTIMEOFDAY
   monitor_output (", timestamp");
-#endif
   monitor_output ("\n");
   monitor_output ("  exit\n");
   monitor_output ("    Quit GDBserver\n");
@@ -973,14 +971,12 @@ parse_debug_format_options (const char *arg, int is_monitor)
 	  if (is_monitor)
 	    monitor_output ("All extra debug format options disabled.\n");
 	}
-#ifdef HAVE_GETTIMEOFDAY
       else if (strcmp (option, "timestamp") == 0)
 	{
 	  debug_timestamp = 1;
 	  if (is_monitor)
 	    monitor_output ("Timestamps will be added to debug output.\n");
 	}
-#endif
       else if (*option == '\0')
 	{
 	  /* An empty option, e.g., "--debug-format=foo,,bar", is ignored.  */
@@ -2831,9 +2827,7 @@ gdbserver_usage (FILE *stream)
 	   "                          Options:\n"
 	   "                            all\n"
 	   "                            none\n"
-#ifdef HAVE_GETTIMEOFDAY
 	   "                            timestamp\n"
-#endif
 	   "  --remote-debug        Enable remote protocol debugging output.\n"
 	   "  --version             Display version information and exit.\n"
 	   "  --wrapper WRAPPER --  Run WRAPPER to start new programs.\n"

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

* Re: [RFC 1/2] link gdbserver against libiberty
  2014-02-07 14:49     ` Tom Tromey
@ 2014-02-07 16:32       ` Pedro Alves
  2014-02-07 21:00         ` Tom Tromey
  2014-02-08  2:36       ` Yao Qi
  1 sibling, 1 reply; 23+ messages in thread
From: Pedro Alves @ 2014-02-07 16:32 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Yao Qi, gdb-patches

On 02/07/2014 02:49 PM, Tom Tromey wrote:
> Yao> ... and I don't understand why do we remove AR and AR_FLAGS from
> Yao> FLAGS_TO_PASS.
> 
> I don't remember any more, either.
> I restored them and rebuilt and it all worked fine.
> I did discover that my earlier patch had broken "make install"; fixed in
> this version.

This looks good to me.  Thanks for doing this.

> -SUBDIRS = $(GNULIB_BUILDDIR)
> +SUBDIRS = $(GNULIB_BUILDDIR) $(LIBIBERTY_BUILDDIR)
>  CLEANDIRS = $(SUBDIRS)
> +INSTALLDIRS = $(GNULIB_BUILDDIR)

I understand making sure we don't try to install anything from
libiberty.  Preexisting to this patch, but I wonder why we even
run make install in gnulib.  Seems that like with libiberty,
we wouldn't ever want to install anything built in gnulib
subdir.

-- 
Pedro Alves

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

* Re: [RFC 2/2] delete gdbserver's freeargv
  2014-01-20 18:49 ` [RFC 2/2] delete gdbserver's freeargv Tom Tromey
@ 2014-02-07 16:35   ` Pedro Alves
  0 siblings, 0 replies; 23+ messages in thread
From: Pedro Alves @ 2014-02-07 16:35 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 01/20/2014 06:49 PM, Tom Tromey wrote:
> gdbserver defines freeargv, but it is now trivial to just use the one
> in libiberty.
> 
> 2014-01-20  Tom Tromey  <tromey@redhat.com>
> 
> 	* utils.c (freeargv): Remove.

OK.

-- 
Pedro Alves

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

* Re: [RFC 1/2] link gdbserver against libiberty
  2014-02-07 16:32       ` Pedro Alves
@ 2014-02-07 21:00         ` Tom Tromey
  2014-02-10 13:27           ` Pedro Alves
  0 siblings, 1 reply; 23+ messages in thread
From: Tom Tromey @ 2014-02-07 21:00 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Yao Qi, gdb-patches

>> -SUBDIRS = $(GNULIB_BUILDDIR)
>> +SUBDIRS = $(GNULIB_BUILDDIR) $(LIBIBERTY_BUILDDIR)
>> CLEANDIRS = $(SUBDIRS)
>> +INSTALLDIRS = $(GNULIB_BUILDDIR)

Pedro> I understand making sure we don't try to install anything from
Pedro> libiberty.  Preexisting to this patch, but I wonder why we even
Pedro> run make install in gnulib.  Seems that like with libiberty,
Pedro> we wouldn't ever want to install anything built in gnulib
Pedro> subdir.

On the one hand it is odd; but on the other it can be argued for from a
black-box perspective.  The reason I skipped this for libiberty is that
gdb uses its own "install-only" target when entering subdirs; but this
is neither GNU nor generally used in the rest of the tree.  So, it
caused installation to fail.

It's possible to fix this another way, say entering libiberty and using
the "install" target there.  But it seems not worth the effort to me;
first because we don't want to install anything in libiberty (unless one
highly values the black box approach, which I do not); and second
because eventually I will be moving all this stuff to the top-level
anyway.

Tom

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

* Re: [RFC 1/2] link gdbserver against libiberty
  2014-02-07 14:49     ` Tom Tromey
  2014-02-07 16:32       ` Pedro Alves
@ 2014-02-08  2:36       ` Yao Qi
  1 sibling, 0 replies; 23+ messages in thread
From: Yao Qi @ 2014-02-08  2:36 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 02/07/2014 10:49 PM, Tom Tromey wrote:
> I don't remember any more, either.
> I restored them and rebuilt and it all worked fine.

OK, I don't have other comments.

Thanks for doing this, Tom.

-- 
Yao (齐尧)

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

* Re: [RFC 1/2] link gdbserver against libiberty
  2014-02-07 21:00         ` Tom Tromey
@ 2014-02-10 13:27           ` Pedro Alves
  2014-02-12 16:44             ` Tom Tromey
  0 siblings, 1 reply; 23+ messages in thread
From: Pedro Alves @ 2014-02-10 13:27 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Yao Qi, gdb-patches

On 02/07/2014 08:59 PM, Tom Tromey wrote:
>>> -SUBDIRS = $(GNULIB_BUILDDIR)
>>> +SUBDIRS = $(GNULIB_BUILDDIR) $(LIBIBERTY_BUILDDIR)
>>> CLEANDIRS = $(SUBDIRS)
>>> +INSTALLDIRS = $(GNULIB_BUILDDIR)
> 
> Pedro> I understand making sure we don't try to install anything from
> Pedro> libiberty.  Preexisting to this patch, but I wonder why we even
> Pedro> run make install in gnulib.  Seems that like with libiberty,
> Pedro> we wouldn't ever want to install anything built in gnulib
> Pedro> subdir.
> 
> On the one hand it is odd; but on the other it can be argued for from a
> black-box perspective.  

Agreed.

I had actually assumed the reason would be that a single gdb build
that included gdbserver would end up installing libiberty twice.
But, libiberty doesn't really install anything actually without
--enable-install-libiberty (which moving to toplevel would sort out).

> The reason I skipped this for libiberty is that
> gdb uses its own "install-only" target when entering subdirs; but this
> is neither GNU nor generally used in the rest of the tree.  So, it
> caused installation to fail.

OK.  That was not obvious at all though.  If this stays, can you
add this info somewhere (source or commit log)?

> It's possible to fix this another way, say entering libiberty and using
> the "install" target there.  But it seems not worth the effort to me;

Well, looking at gdb's own Makefile, we see that install-only there
already punts on "-only" when recursing, therefore never escaping
that gdb-specific target elsewhere:

gdb's Makefile:

install-only: $(CONFIG_INSTALL)
...
        @$(MAKE) DO=install "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do

It's just that gdbserver's currently doesn't.  Seems quite easy to
do and just less magic.

> first because we don't want to install anything in libiberty (unless one
> highly values the black box approach, which I do not); and second
> because eventually I will be moving all this stuff to the top-level
> anyway.

OK.

Thanks,
-- 
Pedro Alves

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

* Re: [RFC 1/2] link gdbserver against libiberty
  2014-02-10 13:27           ` Pedro Alves
@ 2014-02-12 16:44             ` Tom Tromey
  2014-02-12 16:49               ` Pedro Alves
  0 siblings, 1 reply; 23+ messages in thread
From: Tom Tromey @ 2014-02-12 16:44 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Yao Qi, gdb-patches

Pedro> Well, looking at gdb's own Makefile, we see that install-only there
Pedro> already punts on "-only" when recursing, therefore never escaping
Pedro> that gdb-specific target elsewhere:

Pedro> gdb's Makefile:

Pedro> install-only: $(CONFIG_INSTALL)
Pedro> ...
Pedro>         @$(MAKE) DO=install "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do

Pedro> It's just that gdbserver's currently doesn't.  Seems quite easy to
Pedro> do and just less magic.

Here's a revised patch.

Tom

2014-02-12  Tom Tromey  <tromey@redhat.com>

	* debug.c (debug_printf): Remove HAVE_GETTIMEOFDAY checks.
	* server.c (monitor_show_help): Remove HAVE_GETTIMEOFDAY check.
	(parse_debug_format_options): Likewise.
	(gdbserver_usage): Likewise.
	* Makefile.in (LIBIBERTY_BUILDDIR, LIBIBERTY): New variables.
	(SUBDIRS, REQUIRED_SUBDIRS): Add libiberty.
	(gdbserver$(EXEEXT), gdbreplay$(EXEEXT)): Depend on and link
	against libiberty.
	($(LIBGNU)): Depend on libiberty.
	(all-lib): Recurse into all subdirs.
	(install-only): Invoke "install" target in subdirs.
	(vasprintf.o, vsnprintf.o, safe-ctype.o, lbasename.o): Remove
	targets.
	* configure: Rebuild.
	* configure.ac: Add ACX_CONFIGURE_DIR for libiberty.  Don't check
	for vasprintf, vsnprintf, or gettimeofday.
	* configure.srv: Don't add safe-ctype.o or lbasename.o to
	srv_tgtobj.

commit 111ff97a644a43c4f84fea5b3a089d652676e668
Author: Tom Tromey <tromey@redhat.com>
Date:   Sun Jan 19 14:33:37 2014 -0700

    link gdbserver against libiberty
    
    This builds a libiberty just for gdbserver and arranges for gdbserver
    to use it.  I've tripped across the lack of libiberty in gdbserver at
    least once, and I have seen other threads where it would have been
    useful.
    
    2014-02-12  Tom Tromey  <tromey@redhat.com>
    
    	* debug.c (debug_printf): Remove HAVE_GETTIMEOFDAY checks.
    	* server.c (monitor_show_help): Remove HAVE_GETTIMEOFDAY check.
    	(parse_debug_format_options): Likewise.
    	(gdbserver_usage): Likewise.
    	* Makefile.in (LIBIBERTY_BUILDDIR, LIBIBERTY): New variables.
    	(SUBDIRS, REQUIRED_SUBDIRS): Add libiberty.
    	(gdbserver$(EXEEXT), gdbreplay$(EXEEXT)): Depend on and link
    	against libiberty.
    	($(LIBGNU)): Depend on libiberty.
    	(all-lib): Recurse into all subdirs.
    	(install-only): Invoke "install" target in subdirs.
    	(vasprintf.o, vsnprintf.o, safe-ctype.o, lbasename.o): Remove
    	targets.
    	* configure: Rebuild.
    	* configure.ac: Add ACX_CONFIGURE_DIR for libiberty.  Don't check
    	for vasprintf, vsnprintf, or gettimeofday.
    	* configure.srv: Don't add safe-ctype.o or lbasename.o to
    	srv_tgtobj.

diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in
index c172995..8305492 100644
--- a/gdb/gdbserver/Makefile.in
+++ b/gdb/gdbserver/Makefile.in
@@ -83,6 +83,9 @@ CC-LD=${CC}
 INCLUDE_DIR =  ${srcdir}/../../include
 INCLUDE_DEP = $$(INCLUDE_DIR)
 
+LIBIBERTY_BUILDDIR = build-libiberty-gdbserver
+LIBIBERTY = $(LIBIBERTY_BUILDDIR)/libiberty.a
+
 # Where is ust?  These will be empty if ust was not available.
 ustlibs = @ustlibs@
 ustinc = @ustinc@
@@ -190,14 +193,14 @@ XML_BUILTIN = @srv_xmlbuiltin@
 IPA_DEPFILES = @IPA_DEPFILES@
 extra_libraries = @extra_libraries@
 
-SUBDIRS = $(GNULIB_BUILDDIR)
+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)
+REQUIRED_SUBDIRS = $(GNULIB_BUILDDIR) | $(LIBIBERTY_BUILDDIR)
 
 FLAGS_TO_PASS = \
 	"prefix=$(prefix)" \
@@ -258,7 +261,10 @@ install-only:
 	fi; \
 	$(SHELL) $(srcdir)/../../mkinstalldirs $(DESTDIR)$(bindir); \
 	$(INSTALL_PROGRAM) gdbserver$(EXEEXT) $(DESTDIR)$(bindir)/$$n$(EXEEXT)
-	@$(MAKE) $(FLAGS_TO_PASS) DO=$@ "DODIRS=$(SUBDIRS)" subdir_do
+	# 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
 
 uninstall: force
 	n=`echo gdbserver | sed '$(program_transform_name)'`; \
@@ -276,20 +282,20 @@ install-html:
 clean-info: force
 	@$(MAKE) $(FLAGS_TO_PASS) DO=$@ "DODIRS=$(SUBDIRS)" subdir_do
 
-gdbserver$(EXEEXT): $(OBS) ${ADD_DEPS} ${CDEPS} $(LIBGNU)
+gdbserver$(EXEEXT): $(OBS) ${ADD_DEPS} ${CDEPS} $(LIBGNU) $(LIBIBERTY)
 	rm -f gdbserver$(EXEEXT)
 	${CC-LD} $(INTERNAL_CFLAGS) $(INTERNAL_LDFLAGS) -o gdbserver$(EXEEXT) $(OBS) \
-	$(LIBGNU) $(GDBSERVER_LIBS) $(XM_CLIBS)
+	$(LIBGNU) $(LIBIBERTY) $(GDBSERVER_LIBS) $(XM_CLIBS)
 
-$(LIBGNU) $(GNULIB_H): all-lib
-all-lib: $(GNULIB_BUILDDIR)/Makefile
-	@$(MAKE) $(FLAGS_TO_PASS) DO=all DODIRS=$(GNULIB_BUILDDIR) subdir_do
+$(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): $(GDBREPLAY_OBS) $(LIBGNU)
+gdbreplay$(EXEEXT): $(GDBREPLAY_OBS) $(LIBGNU) $(LIBIBERTY)
 	rm -f gdbreplay$(EXEEXT)
 	${CC-LD} $(INTERNAL_CFLAGS) $(INTERNAL_LDFLAGS) -o gdbreplay$(EXEEXT) $(GDBREPLAY_OBS) \
-	  $(XM_CLIBS) $(LIBGNU)
+	  $(XM_CLIBS) $(LIBGNU) $(LIBIBERTY)
 
 IPA_OBJS=ax-ipa.o tracepoint-ipa.o format-ipa.o utils-ipa.o regcache-ipa.o remote-utils-ipa.o common-utils-ipa.o tdesc-ipa.o ${IPA_DEPFILES}
 
@@ -533,23 +539,6 @@ linux-waitpid.o: ../nat/linux-waitpid.c
 	$(COMPILE) $<
 	$(POSTCOMPILE)
 
-# We build vasprintf with -DHAVE_CONFIG_H because we want that unit to
-# include our config.h file.  Otherwise, some system headers do not get
-# included, and the compiler emits a warning about implicitly defined
-# functions (missing declaration).
-vasprintf.o: $(srcdir)/../../libiberty/vasprintf.c
-	$(COMPILE) $< -DHAVE_CONFIG_H
-	$(POSTCOMPILE)
-vsnprintf.o: $(srcdir)/../../libiberty/vsnprintf.c
-	$(COMPILE) $<
-	$(POSTCOMPILE)
-safe-ctype.o: $(srcdir)/../../libiberty/safe-ctype.c
-	$(COMPILE) $<
-	$(POSTCOMPILE)
-lbasename.o: $(srcdir)/../../libiberty/lbasename.c
-	$(COMPILE) $<
-	$(POSTCOMPILE)
-
 aarch64.c : $(srcdir)/../regformats/aarch64.dat $(regdat_sh)
 	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/aarch64.dat aarch64.c
 reg-arm.c : $(srcdir)/../regformats/reg-arm.dat $(regdat_sh)
diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac
index 0dfa4a9..16360c0 100644
--- a/gdb/gdbserver/configure.ac
+++ b/gdb/gdbserver/configure.ac
@@ -77,12 +77,14 @@ AC_PROG_MAKE_SET
 # build it in the same directory, when building in the source dir.
 ACX_CONFIGURE_DIR(["../gnulib"], ["build-gnulib-gdbserver"])
 
+ACX_CONFIGURE_DIR(["../../libiberty"], ["build-libiberty-gdbserver"])
+
 AC_CHECK_HEADERS(sgtty.h termio.h termios.h sys/reg.h string.h dnl
 		 proc_service.h sys/procfs.h linux/elf.h dnl
 		 errno.h fcntl.h signal.h sys/file.h malloc.h dnl
 		 sys/ioctl.h netinet/in.h sys/socket.h netdb.h dnl
 		 netinet/tcp.h arpa/inet.h)
-AC_CHECK_FUNCS(gettimeofday pread pwrite pread64 readlink)
+AC_CHECK_FUNCS(pread pwrite pread64 readlink)
 AC_REPLACE_FUNCS(vasprintf vsnprintf)
 
 GDB_AC_COMMON
diff --git a/gdb/gdbserver/configure.srv b/gdb/gdbserver/configure.srv
index f4e6154..32d935a 100644
--- a/gdb/gdbserver/configure.srv
+++ b/gdb/gdbserver/configure.srv
@@ -77,7 +77,6 @@ case "${target}" in
 			;;
   arm*-*-mingw32ce*)	srv_regobj=reg-arm.o
 			srv_tgtobj="win32-low.o win32-arm-low.o"
-			srv_tgtobj="${srv_tgtobj} safe-ctype.o lbasename.o"
 			srv_tgtobj="${srv_tgtobj} wincecompat.o"
 			# hostio_last_error implementation is in win32-low.c
 			srv_hostio_err_objs=""
@@ -101,7 +100,6 @@ case "${target}" in
 			;;
   i[34567]86-*-cygwin*)	srv_regobj="$srv_i386_regobj"
 			srv_tgtobj="i386-low.o win32-low.o win32-i386-low.o"
-			srv_tgtobj="${srv_tgtobj} safe-ctype.o lbasename.o"
 			srv_xmlfiles="$srv_i386_xmlfiles"
 			;;
   i[34567]86-*-linux*)	srv_regobj="$srv_i386_linux_regobj"
@@ -128,7 +126,6 @@ case "${target}" in
   i[34567]86-*-mingw32ce*)
 			srv_regobj="$srv_i386_regobj"
 			srv_tgtobj="i386-low.o win32-low.o win32-i386-low.o"
-			srv_tgtobj="${srv_tgtobj} safe-ctype.o lbasename.o"
 			srv_tgtobj="${srv_tgtobj} wincecompat.o"
 			srv_xmlfiles="$srv_i386_xmlfiles"
 			# hostio_last_error implementation is in win32-low.c
@@ -138,7 +135,6 @@ case "${target}" in
 			;;
   i[34567]86-*-mingw*)	srv_regobj="$srv_i386_regobj"
 			srv_tgtobj="i386-low.o win32-low.o win32-i386-low.o"
-			srv_tgtobj="${srv_tgtobj} safe-ctype.o lbasename.o"
 			srv_xmlfiles="$srv_i386_xmlfiles"
 			srv_mingw=yes
 			;;
@@ -330,13 +326,11 @@ case "${target}" in
 			;;
   x86_64-*-mingw*)	srv_regobj="$srv_amd64_regobj"
 			srv_tgtobj="i386-low.o i387-fp.o win32-low.o win32-i386-low.o"
-			srv_tgtobj="${srv_tgtobj} safe-ctype.o lbasename.o"
 			srv_xmlfiles="$srv_i386_xmlfiles $srv_amd64_xmlfiles"
 			srv_mingw=yes
 			;;
   x86_64-*-cygwin*)	srv_regobj="$srv_amd64_regobj"
 			srv_tgtobj="i386-low.o i387-fp.o win32-low.o win32-i386-low.o"
-			srv_tgtobj="${srv_tgtobj} safe-ctype.o lbasename.o"
 			srv_xmlfiles="$srv_i386_xmlfiles"
 			;;
 
diff --git a/gdb/gdbserver/debug.c b/gdb/gdbserver/debug.c
index 6f4d531..c50af76 100644
--- a/gdb/gdbserver/debug.c
+++ b/gdb/gdbserver/debug.c
@@ -36,7 +36,7 @@ void
 debug_printf (const char *msg, ...)
 {
   va_list args;
-#if defined (HAVE_GETTIMEOFDAY) && !defined (IN_PROCESS_AGENT)
+#if !defined (IN_PROCESS_AGENT)
   /* N.B. Not thread safe, and can't be used, as is, with IPA.  */
   static int new_line = 1;
 
@@ -57,7 +57,7 @@ debug_printf (const char *msg, ...)
   vfprintf (stderr, msg, args);
   va_end (args);
 
-#if defined (HAVE_GETTIMEOFDAY) && !defined (IN_PROCESS_AGENT)
+#if !defined (IN_PROCESS_AGENT)
   if (*msg)
     new_line = msg[strlen (msg) - 1] == '\n';
 #endif
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index 88354be..314cc92 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -695,9 +695,7 @@ monitor_show_help (void)
   monitor_output ("  set debug-format option1[,option2,...]\n");
   monitor_output ("    Add additional information to debugging messages\n");
   monitor_output ("    Options: all, none");
-#ifdef HAVE_GETTIMEOFDAY
   monitor_output (", timestamp");
-#endif
   monitor_output ("\n");
   monitor_output ("  exit\n");
   monitor_output ("    Quit GDBserver\n");
@@ -973,14 +971,12 @@ parse_debug_format_options (const char *arg, int is_monitor)
 	  if (is_monitor)
 	    monitor_output ("All extra debug format options disabled.\n");
 	}
-#ifdef HAVE_GETTIMEOFDAY
       else if (strcmp (option, "timestamp") == 0)
 	{
 	  debug_timestamp = 1;
 	  if (is_monitor)
 	    monitor_output ("Timestamps will be added to debug output.\n");
 	}
-#endif
       else if (*option == '\0')
 	{
 	  /* An empty option, e.g., "--debug-format=foo,,bar", is ignored.  */
@@ -2831,9 +2827,7 @@ gdbserver_usage (FILE *stream)
 	   "                          Options:\n"
 	   "                            all\n"
 	   "                            none\n"
-#ifdef HAVE_GETTIMEOFDAY
 	   "                            timestamp\n"
-#endif
 	   "  --remote-debug        Enable remote protocol debugging output.\n"
 	   "  --version             Display version information and exit.\n"
 	   "  --wrapper WRAPPER --  Run WRAPPER to start new programs.\n"

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

* Re: [RFC 1/2] link gdbserver against libiberty
  2014-02-12 16:44             ` Tom Tromey
@ 2014-02-12 16:49               ` Pedro Alves
  0 siblings, 0 replies; 23+ messages in thread
From: Pedro Alves @ 2014-02-12 16:49 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Yao Qi, gdb-patches

On 02/12/2014 04:44 PM, Tom Tromey wrote:
> Pedro> Well, looking at gdb's own Makefile, we see that install-only there
> Pedro> already punts on "-only" when recursing, therefore never escaping
> Pedro> that gdb-specific target elsewhere:
> 
> Pedro> gdb's Makefile:
> 
> Pedro> install-only: $(CONFIG_INSTALL)
> Pedro> ...
> Pedro>         @$(MAKE) DO=install "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
> 
> Pedro> It's just that gdbserver's currently doesn't.  Seems quite easy to
> Pedro> do and just less magic.
> 
> Here's a revised patch.

Thank you!  Looks good to me.

-- 
Pedro Alves

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

* Re: [RFC 0/2] let gdbserver use libiberty
  2014-01-20 18:49 [RFC 0/2] let gdbserver use libiberty Tom Tromey
                   ` (2 preceding siblings ...)
  2014-01-20 18:54 ` [RFC 0/2] let gdbserver use libiberty Tom Tromey
@ 2014-06-12 20:37 ` Tom Tromey
  2014-06-16 13:26   ` James Greenhalgh
  2014-06-20 12:01   ` Gary Benson
  3 siblings, 2 replies; 23+ messages in thread
From: Tom Tromey @ 2014-06-12 20:37 UTC (permalink / raw)
  To: gdb-patches

>>>>> "Tom" == Tom Tromey <tromey@redhat.com> writes:

Tom> This series changes gdbserver to build its own copy of libiberty
Tom> (using ACX_CONFIGURE_DIR) and then link against it.  I've needed this
Tom> at least once (for a cloexec patch) and I've seen other situations
Tom> where it would have been useful.

This series slipped through the cracks somehow.  I'm going to push it
now.  I believe I addressed all the review comments upthread.  I rebased
it and rebuilt it on x86-64 Fedora 20; let me know if you encounter any
problems.

thanks,
Tom

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

* Re: [RFC 0/2] let gdbserver use libiberty
  2014-06-12 20:37 ` Tom Tromey
@ 2014-06-16 13:26   ` James Greenhalgh
  2014-06-18 12:27     ` Marcus Shawcroft
  2014-06-20 12:01   ` Gary Benson
  1 sibling, 1 reply; 23+ messages in thread
From: James Greenhalgh @ 2014-06-16 13:26 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Thu, Jun 12, 2014 at 09:37:19PM +0100, Tom Tromey wrote:
> >>>>> "Tom" == Tom Tromey <tromey@redhat.com> writes:
> 
> Tom> This series changes gdbserver to build its own copy of libiberty
> Tom> (using ACX_CONFIGURE_DIR) and then link against it.  I've needed this
> Tom> at least once (for a cloexec patch) and I've seen other situations
> Tom> where it would have been useful.
> 
> This series slipped through the cracks somehow.  I'm going to push it
> now.  I believe I addressed all the review comments upthread.  I rebased
> it and rebuilt it on x86-64 Fedora 20; let me know if you encounter any
> problems.

Hi Tom,

This seems to cause issues when building gdbserver as part of a larger
Canadian Cross ARM/AArch64 build. ar ends up confused having seemingly lost
the expected flags:

----

ar  ./libiberty.a \
	  ./regex.o ./cplus-dem.o ./cp-demangle.o ./md5.o ./sha1.o ./alloca.o ./argv.o ./choose-temp.o ./concat.o ./cp-demint.o ./crc32.o ./dwarfnames.o ./dyn-string.o ./fdmatch.o ./fibheap.o ./filename_cmp.o ./floatformat.o ./fnmatch.o ./fopen_unlocked.o ./getopt.o ./getopt1.o ./getpwd.o ./getruntime.o ./hashtab.o ./hex.o ./lbasename.o ./lrealpath.o ./make-relative-prefix.o ./make-temp-file.o ./objalloc.o ./obstack.o ./partition.o ./pexecute.o ./physmem.o ./pex-common.o ./pex-one.o ./pex-unix.o ./safe-ctype.o ./simple-object.o ./simple-object-coff.o ./simple-object-elf.o ./simple-object-mach-o.o ./simple-object-xcoff.o ./sort.o ./spaces.o ./splay-tree.o ./stack-limit.o ./strerror.o ./strsignal.o ./timeval-utils.o ./unlink-if-ordinary.o ./xatexit.o ./xexit.o ./xmalloc.o ./xmemdup.o ./xstrdup.o ./xstrerror.o ./xstrndup.o  ./setproctitle.o

ar: illegal option -- .
Usage: ar [emulation options] [-]{dmpqrstx}[abcfilNoPsSuvV] [member-name] [count] archive-file file...
       ar -M [<mri-script]

----

The small patch below (from your initial patch series) gets the build
going again, but looking back at the discussion, I see this was
controversial and was dropped before the final commit.

My knowledge of the build system is minimal, but I'm happy to test any
proposed patches.

Thanks,
James Greenhalgh

---

diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in
index cbf36ab..86c404d 100644
--- a/gdb/gdbserver/Makefile.in
+++ b/gdb/gdbserver/Makefile.in
@@ -217,8 +217,6 @@ FLAGS_TO_PASS = \
 	"includedir=$(includedir)" \
 	"against=$(against)" \
 	"DESTDIR=$(DESTDIR)" \
-	"AR=$(AR)" \
-	"AR_FLAGS=$(AR_FLAGS)" \
 	"CC=$(CC)" \
 	"CFLAGS=$(CFLAGS)" \
 	"CXX=$(CXX)" \

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

* Re: [RFC 0/2] let gdbserver use libiberty
  2014-06-16 13:26   ` James Greenhalgh
@ 2014-06-18 12:27     ` Marcus Shawcroft
  2014-06-19 14:48       ` Tom Tromey
  0 siblings, 1 reply; 23+ messages in thread
From: Marcus Shawcroft @ 2014-06-18 12:27 UTC (permalink / raw)
  To: James Greenhalgh; +Cc: Tom Tromey, gdb-patches

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

On 16 June 2014 14:25, James Greenhalgh <james.greenhalgh@arm.com> wrote:
> On Thu, Jun 12, 2014 at 09:37:19PM +0100, Tom Tromey wrote:
>> This series slipped through the cracks somehow.  I'm going to push it
>> now.  I believe I addressed all the review comments upthread.  I rebased
>> it and rebuilt it on x86-64 Fedora 20; let me know if you encounter any
>> problems.
>
> Hi Tom,
>
> This seems to cause issues when building gdbserver as part of a larger
> Canadian Cross ARM/AArch64 build. ar ends up confused having seemingly lost
> the expected flags:

The issue here appears to be that libiberty configure script probes
for and finds an appropriate AR for the --build/--target combination.
However, the gdbserver configure does not probe for AR but does
override the AR used in the libiberty build by explicitly passing AR
to the sub-builds.  This has the effect of passing the systems 'ar'
rather than an ar appropriate for the --build/--target combination.

An alternative  approach to that suggested by James is to have the
gdbserver configure scri[t probe for AR to ensure that something sane
is passed on to the sub-builds.

Patch attached.

OK ?

/Marcus

[-- Attachment #2: 0001-Fix-gdbserver-canadian-cross-build.patch --]
[-- Type: text/x-patch, Size: 1435 bytes --]

From 96c14c27fc7ff86e028d1f1a156391154d8e7c04 Mon Sep 17 00:00:00 2001
From: Marcus Shawcroft <marcus.shawcroft@arm.com>
Date: Wed, 18 Jun 2014 11:53:33 +0100
Subject: [PATCH 1/2] Fix gdbserver canadian cross build.

---
 gdb/gdbserver/ChangeLog    |    5 +++++
 gdb/gdbserver/Makefile.in  |    2 ++
 gdb/gdbserver/configure.ac |    1 +
 3 files changed, 8 insertions(+)

diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 3186336..8788be1 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,8 @@
+2014-06-18  Marcus Shawcroft  <marcus.shawcroft@arm.com>
+
+	* configure.ac: Invoke. AC_CHECK_TOOL(AR, ar).
+	* Makefile.in (AR, AR_FLAGS): Define.
+
 2014-06-18  Gary Benson  <gbenson@redhat.com>
 
 	* i386-low.h (i386_low_insert_watchpoint): Renamed to
diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in
index cbf36ab..c650477 100644
--- a/gdb/gdbserver/Makefile.in
+++ b/gdb/gdbserver/Makefile.in
@@ -50,6 +50,8 @@ INSTALL_DATA = @INSTALL_DATA@
 RANLIB = @RANLIB@
 
 CC = @CC@
+AR = @AR@
+AR_FLAGS = rc
 
 # Dependency tracking information.
 DEPMODE = @CCDEPMODE@
diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac
index ede38d0..7fa89d6 100644
--- a/gdb/gdbserver/configure.ac
+++ b/gdb/gdbserver/configure.ac
@@ -32,6 +32,7 @@ AC_SYS_LARGEFILE
 AC_CANONICAL_SYSTEM
 
 AC_PROG_INSTALL
+AC_CHECK_TOOL(AR, ar)
 AC_PROG_RANLIB
 
 AC_ARG_PROGRAM
-- 
1.7.9.5


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

* Re: [RFC 0/2] let gdbserver use libiberty
  2014-06-18 12:27     ` Marcus Shawcroft
@ 2014-06-19 14:48       ` Tom Tromey
  2014-06-20 10:52         ` Pedro Alves
  0 siblings, 1 reply; 23+ messages in thread
From: Tom Tromey @ 2014-06-19 14:48 UTC (permalink / raw)
  To: Marcus Shawcroft; +Cc: James Greenhalgh, gdb-patches

>>>>> "Marcus" == Marcus Shawcroft <marcus.shawcroft@gmail.com> writes:

Marcus> An alternative  approach to that suggested by James is to have the
Marcus> gdbserver configure scri[t probe for AR to ensure that something sane
Marcus> is passed on to the sub-builds.

Marcus> Patch attached.

Marcus> OK ?

Yes, this is ok.  Thanks.

Tom

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

* Re: [RFC 0/2] let gdbserver use libiberty
  2014-06-19 14:48       ` Tom Tromey
@ 2014-06-20 10:52         ` Pedro Alves
  0 siblings, 0 replies; 23+ messages in thread
From: Pedro Alves @ 2014-06-20 10:52 UTC (permalink / raw)
  To: Tom Tromey, Marcus Shawcroft; +Cc: James Greenhalgh, gdb-patches

On 06/19/2014 03:48 PM, Tom Tromey wrote:
>>>>>> "Marcus" == Marcus Shawcroft <marcus.shawcroft@gmail.com> writes:
> 
> Marcus> An alternative  approach to that suggested by James is to have the
> Marcus> gdbserver configure scri[t probe for AR to ensure that something sane
> Marcus> is passed on to the sub-builds.
> 
> Marcus> Patch attached.
> 
> Marcus> OK ?
> 
> Yes, this is ok.  Thanks.
> 
> Tom
> 

I've pushed this.

----------------
From e1d2394b50c7b174f48e38efb398034d75e67c99 Mon Sep 17 00:00:00 2001
From: Marcus Shawcroft <marcus.shawcroft@arm.com>
Date: Fri, 20 Jun 2014 11:48:15 +0100
Subject: [PATCH] Fix gdbserver cross build.

The recent libiberty patch caused issues when cross building
gdbserver.  The Makefile ends invoking the build machine's "ar"
instead of the --host version:

  ar  ./libiberty.a \
	    ./regex.o (...)

  ar: illegal option -- .
  Usage: ar [emulation options] [-]{dmpqrstx}[abcfilNoPsSuvV] [member-name] [count] archive-file file...
	 ar -M [<mri-script]

The libiberty configure script does probe for and finds an appropriate
AR.  However, gdbserver's configure does not probe for AR and
overrides the AR used in the libiberty build by explicitly passing AR
to the sub-builds.

gdb/gdbserver/
2014-06-20  Marcus Shawcroft  <marcus.shawcroft@arm.com>

	* configure.ac: Invoke. AC_CHECK_TOOL(AR, ar).
	* Makefile.in (AR, AR_FLAGS): Define.
	* configure: Regenerate.
---
 gdb/gdbserver/ChangeLog    |  6 +++
 gdb/gdbserver/Makefile.in  |  2 +
 gdb/gdbserver/configure    | 93 ++++++++++++++++++++++++++++++++++++++++++++++
 gdb/gdbserver/configure.ac |  1 +
 4 files changed, 102 insertions(+)

diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index dda84f9..54556f8 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,9 @@
+2014-06-20  Marcus Shawcroft  <marcus.shawcroft@arm.com>
+
+	* configure.ac: Invoke. AC_CHECK_TOOL(AR, ar).
+	* Makefile.in (AR, AR_FLAGS): Define.
+	* configure: Regenerate.
+
 2014-06-19  Gary Benson  <gbenson@redhat.com>
 
 	* Makefile.in (i386-dregs.o): New rule.
diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in
index 76d8965..3674aed 100644
--- a/gdb/gdbserver/Makefile.in
+++ b/gdb/gdbserver/Makefile.in
@@ -50,6 +50,8 @@ INSTALL_DATA = @INSTALL_DATA@
 RANLIB = @RANLIB@
 
 CC = @CC@
+AR = @AR@
+AR_FLAGS = rc
 
 # Dependency tracking information.
 DEPMODE = @CCDEPMODE@
diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure
index 90930bb..33db6e3 100755
--- a/gdb/gdbserver/configure
+++ b/gdb/gdbserver/configure
@@ -616,6 +616,7 @@ host_noncanonical
 target_noncanonical
 ALLOCA
 RANLIB
+AR
 INSTALL_DATA
 INSTALL_SCRIPT
 INSTALL_PROGRAM
@@ -3916,6 +3917,98 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
 test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
 
 if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ar; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_AR+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$AR"; then
+  ac_cv_prog_AR="$AR" # Let the user override the test.
+else
+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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_AR="${ac_tool_prefix}ar"
+    $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
+
+fi
+fi
+AR=$ac_cv_prog_AR
+if test -n "$AR"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5
+$as_echo "$AR" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_AR"; then
+  ac_ct_AR=$AR
+  # Extract the first word of "ar", so it can be a program name with args.
+set dummy ar; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_AR+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_AR"; then
+  ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
+else
+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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_AR="ar"
+    $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
+
+fi
+fi
+ac_ct_AR=$ac_cv_prog_ac_ct_AR
+if test -n "$ac_ct_AR"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5
+$as_echo "$ac_ct_AR" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_AR" = x; then
+    AR=""
+  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
+    AR=$ac_ct_AR
+  fi
+else
+  AR="$ac_cv_prog_AR"
+fi
+
+if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
 set dummy ${ac_tool_prefix}ranlib; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac
index ede38d0..7fa89d6 100644
--- a/gdb/gdbserver/configure.ac
+++ b/gdb/gdbserver/configure.ac
@@ -32,6 +32,7 @@ AC_SYS_LARGEFILE
 AC_CANONICAL_SYSTEM
 
 AC_PROG_INSTALL
+AC_CHECK_TOOL(AR, ar)
 AC_PROG_RANLIB
 
 AC_ARG_PROGRAM
-- 
1.9.3


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

* Re: [RFC 0/2] let gdbserver use libiberty
  2014-06-12 20:37 ` Tom Tromey
  2014-06-16 13:26   ` James Greenhalgh
@ 2014-06-20 12:01   ` Gary Benson
  2014-06-20 14:16     ` Tom Tromey
  1 sibling, 1 reply; 23+ messages in thread
From: Gary Benson @ 2014-06-20 12:01 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

Tom Tromey wrote:
> >>>>> "Tom" == Tom Tromey <tromey@redhat.com> writes:
> 
> Tom> This series changes gdbserver to build its own copy of libiberty
> Tom> (using ACX_CONFIGURE_DIR) and then link against it.  I've needed
> Tom> this at least once (for a cloexec patch) and I've seen other
> Tom> situations where it would have been useful.
> 
> This series slipped through the cracks somehow.  I'm going to push
> it now.  I believe I addressed all the review comments upthread.  I
> rebased it and rebuilt it on x86-64 Fedora 20; let me know if you
> encounter any problems.

I had to apply the attached patch (and run autoconf, autoheader) to
build with mingw32 on x86-64 RHEL 6.5.  Should I tidy this up and
commit it?

Cheers
Gary

--
diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac
index ede38d0..6fb2379 100644
--- a/gdb/gdbserver/configure.ac
+++ b/gdb/gdbserver/configure.ac
@@ -85,7 +85,6 @@ AC_CHECK_HEADERS(sgtty.h termio.h termios.h sys/reg.h string.h dnl
 		 sys/ioctl.h netinet/in.h sys/socket.h netdb.h dnl
 		 netinet/tcp.h arpa/inet.h)
 AC_CHECK_FUNCS(pread pwrite pread64 readlink)
-AC_REPLACE_FUNCS(vasprintf vsnprintf)
 
 GDB_AC_COMMON
 

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

* Re: [RFC 0/2] let gdbserver use libiberty
  2014-06-20 12:01   ` Gary Benson
@ 2014-06-20 14:16     ` Tom Tromey
  2014-06-20 14:44       ` [COMMITTED PATCH] Fix mingw32 build on x86-64 RHEL 6.5 Gary Benson
  0 siblings, 1 reply; 23+ messages in thread
From: Tom Tromey @ 2014-06-20 14:16 UTC (permalink / raw)
  To: Gary Benson; +Cc: gdb-patches

>>>>> "Gary" == Gary Benson <gbenson@redhat.com> writes:

Gary> I had to apply the attached patch (and run autoconf, autoheader) to
Gary> build with mingw32 on x86-64 RHEL 6.5.  Should I tidy this up and
Gary> commit it?

Yes, please.  Thanks.

Tom

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

* [COMMITTED PATCH] Fix mingw32 build on x86-64 RHEL 6.5
  2014-06-20 14:16     ` Tom Tromey
@ 2014-06-20 14:44       ` Gary Benson
  0 siblings, 0 replies; 23+ messages in thread
From: Gary Benson @ 2014-06-20 14:44 UTC (permalink / raw)
  To: gdb-patches

This commit fixes the mingw32 build on x86-64 RHEL 6.5.

gdb/gdbserver/
2014-06-20  Gary Benson  <gbenson@redhat.com>

	* configure.ac (AC_REPLACE_FUNCS) <vasprintf, vsnprintf>: Removed.
	* configure: Regenerated.
	* config.in: Likewise.
---
 gdb/gdbserver/ChangeLog    |    6 ++++++
 gdb/gdbserver/config.in    |    9 ---------
 gdb/gdbserver/configure    |   23 +----------------------
 gdb/gdbserver/configure.ac |    1 -
 4 files changed, 7 insertions(+), 32 deletions(-)

diff --git a/gdb/gdbserver/config.in b/gdb/gdbserver/config.in
index 1b9751f..6ce45a6 100644
--- a/gdb/gdbserver/config.in
+++ b/gdb/gdbserver/config.in
@@ -66,9 +66,6 @@
 /* Define to 1 if you have the `getrlimit' function. */
 #undef HAVE_GETRLIMIT
 
-/* Define to 1 if you have the `gettimeofday' function. */
-#undef HAVE_GETTIMEOFDAY
-
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
 
@@ -232,12 +229,6 @@
 /* Define if UST is available */
 #undef HAVE_UST
 
-/* Define to 1 if you have the `vasprintf' function. */
-#undef HAVE_VASPRINTF
-
-/* Define to 1 if you have the `vsnprintf' function. */
-#undef HAVE_VSNPRINTF
-
 /* Define to 1 if you have the <wait.h> header file. */
 #undef HAVE_WAIT_H
 
diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure
index 33db6e3..5f8dcd2 100755
--- a/gdb/gdbserver/configure
+++ b/gdb/gdbserver/configure
@@ -589,6 +589,7 @@ ac_includes_default="\
 #endif"
 
 ac_subst_vars='LTLIBOBJS
+LIBOBJS
 GNULIB_STDINT_H
 extra_libraries
 IPA_DEPFILES
@@ -604,7 +605,6 @@ WERROR_CFLAGS
 WARN_CFLAGS
 ustinc
 ustlibs
-LIBOBJS
 SET_MAKE
 GMAKE_FALSE
 GMAKE_TRUE
@@ -4931,27 +4931,6 @@ _ACEOF
 fi
 done
 
-for ac_func in vasprintf vsnprintf
-do :
-  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
-ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-eval as_val=\$$as_ac_var
-   if test "x$as_val" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
-
-else
-  case " $LIBOBJS " in
-  *" $ac_func.$ac_objext "* ) ;;
-  *) LIBOBJS="$LIBOBJS $ac_func.$ac_objext"
- ;;
-esac
-
-fi
-done
-
-
 
 
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac
index 7fa89d6..67866f8 100644
--- a/gdb/gdbserver/configure.ac
+++ b/gdb/gdbserver/configure.ac
@@ -86,7 +86,6 @@ AC_CHECK_HEADERS(sgtty.h termio.h termios.h sys/reg.h string.h dnl
 		 sys/ioctl.h netinet/in.h sys/socket.h netdb.h dnl
 		 netinet/tcp.h arpa/inet.h)
 AC_CHECK_FUNCS(pread pwrite pread64 readlink)
-AC_REPLACE_FUNCS(vasprintf vsnprintf)
 
 GDB_AC_COMMON
 
-- 
1.7.1

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

end of thread, other threads:[~2014-06-20 14:44 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-20 18:49 [RFC 0/2] let gdbserver use libiberty Tom Tromey
2014-01-20 18:49 ` [RFC 2/2] delete gdbserver's freeargv Tom Tromey
2014-02-07 16:35   ` Pedro Alves
2014-01-20 18:49 ` [RFC 1/2] link gdbserver against libiberty Tom Tromey
2014-01-21  1:49   ` Yao Qi
2014-01-21  2:33     ` Tom Tromey
2014-02-07 14:49     ` Tom Tromey
2014-02-07 16:32       ` Pedro Alves
2014-02-07 21:00         ` Tom Tromey
2014-02-10 13:27           ` Pedro Alves
2014-02-12 16:44             ` Tom Tromey
2014-02-12 16:49               ` Pedro Alves
2014-02-08  2:36       ` Yao Qi
2014-01-21  2:03   ` Yao Qi
2014-01-20 18:54 ` [RFC 0/2] let gdbserver use libiberty Tom Tromey
2014-06-12 20:37 ` Tom Tromey
2014-06-16 13:26   ` James Greenhalgh
2014-06-18 12:27     ` Marcus Shawcroft
2014-06-19 14:48       ` Tom Tromey
2014-06-20 10:52         ` Pedro Alves
2014-06-20 12:01   ` Gary Benson
2014-06-20 14:16     ` Tom Tromey
2014-06-20 14:44       ` [COMMITTED PATCH] Fix mingw32 build on x86-64 RHEL 6.5 Gary Benson

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