diff mbox

[RFA] configure gdb/gnulib with --disable-largefile if largefile support disabled.

Message ID 1417608509-15533-1-git-send-email-brobecker@adacore.com
State New
Headers show

Commit Message

Joel Brobecker Dec. 3, 2014, 12:08 p.m. UTC
This patch mostly aims at fixing a GDB build failure on 32bit Solaris
systems (Sparc and x86), due to a recent gnulib update adding the
readlink module. But it might also fix related issues when configuring
with --disable-largefile.

A side-effect of the gnulib readlink module addition is that it caused
largefile support to be added as well, and in particular
gnulib/import/m4/largefile.m4 introduced the following new #define in
gnulib's config.in:

| +/* Number of bits in a file offset, on hosts where this is settable. */
| +#undef _FILE_OFFSET_BITS

When defined to 64, it triggers an issue with procfs.h while trying
to build sparc-sol2-nat.c:

| #if !defined(_LP64) && _FILE_OFFSET_BITS == 64
| #error  "Cannot use procfs in the large file compilation environment"
| #endif

As it turns out, this is a fairly familiar problem, and one of
the reasons behind ACX_LARGEFILE having been created. In that macro,
we have some code which disables largefile support on solaris hosts:

|   sparc-*-solaris*|i[3-7]86-*-solaris*)
| changequote([,])dnl
|     # On native 32bit sparc and ia32 solaris, large-file and procfs support
|     # are mutually exclusive; and without procfs support, the bfd/ elf module
|     # cannot provide certain routines such as elfcore_write_prpsinfo
|     # or elfcore_write_prstatus.  So unless the user explicitly requested
|     # large-file support through the --enable-largefile switch, disable
|     # large-file support in favor of procfs support.
|     test "${target}" = "${host}" -a "x$plugins" = xno \
|       && : ${enable_largefile="no"}
|     ;;

But gnulib ignores this fact, and so tries to determine how to
enable large-file support irrespective of whether we want it or not.
This patch fixes the issue by passing --disable-largefile to gnulib's
configure when large-file support in GDB is disabled. This is done
by first enhancing ACX_CONFIGURE_DIR to allow us to pass extra
arguments to be passed to the configure command, and then by modifying
GDB's configure to pass --disable-largefile if large-file support
is disabled.

gdb/ChangeLog:

	* acx_configure_dir.m4 (ACX_CONFIGURE_DIR): Add support for
        new "EXTRA-ARGS" parameter.
	* configure.ac: If large-file support is disabled in GDB,
        pass --disable-largefile to ACX_CONFIGURE_DIR call for "gnulib".
	* configure: Regenerate.

gdb/gdbserver/ChangeLog:

	* configure.ac: If large-file support is disabled in GDBserver,
        pass --disable-largefile to ACX_CONFIGURE_DIR call for "gnulib".
        * configure: Regenerate.

Tested by rebuilding on sparc-solaris and x86_64-linux (with gdbserver).
This fixes the build failure on sparc-solaris. I also verified in
gnulib's config.log file that we pass --disable-largefile in the solaris
case, while we do not in the GNU/Linux case.

OK to apply?

Thank you,

Comments

Eli Zaretskii Dec. 3, 2014, 5:59 p.m. UTC | #1
> From: Joel Brobecker <brobecker@adacore.com>
> Cc: Yao Qi <yao@codesourcery.com>
> Date: Wed,  3 Dec 2014 07:08:29 -0500
> 
> |   sparc-*-solaris*|i[3-7]86-*-solaris*)
> | changequote([,])dnl
> |     # On native 32bit sparc and ia32 solaris, large-file and procfs support
> |     # are mutually exclusive; and without procfs support, the bfd/ elf module
> |     # cannot provide certain routines such as elfcore_write_prpsinfo
> |     # or elfcore_write_prstatus.  So unless the user explicitly requested
> |     # large-file support through the --enable-largefile switch, disable
> |     # large-file support in favor of procfs support.
> |     test "${target}" = "${host}" -a "x$plugins" = xno \
> |       && : ${enable_largefile="no"}
> |     ;;
> 
> But gnulib ignores this fact, and so tries to determine how to
> enable large-file support irrespective of whether we want it or not.
> This patch fixes the issue by passing --disable-largefile to gnulib's
> configure when large-file support in GDB is disabled. This is done
> by first enhancing ACX_CONFIGURE_DIR to allow us to pass extra
> arguments to be passed to the configure command, and then by modifying
> GDB's configure to pass --disable-largefile if large-file support
> is disabled.

Shouldn't this be reported to gnulib folks and preferably fixed there?
Yao Qi Dec. 4, 2014, 2:16 a.m. UTC | #2
Joel Brobecker <brobecker@adacore.com> writes:

> This patch fixes the issue by passing --disable-largefile to gnulib's
> configure when large-file support in GDB is disabled. This is done
> by first enhancing ACX_CONFIGURE_DIR to allow us to pass extra
> arguments to be passed to the configure command, and then by modifying
> GDB's configure to pass --disable-largefile if large-file support
> is disabled.

I tested this patch by configuring gdb with --disable-largefile for
x86-linux and mingw32.  Everything looks right to me.
Joel Brobecker Dec. 4, 2014, 3:18 a.m. UTC | #3
> > But gnulib ignores this fact, and so tries to determine how to
> > enable large-file support irrespective of whether we want it or not.
> > This patch fixes the issue by passing --disable-largefile to gnulib's
> > configure when large-file support in GDB is disabled. This is done
> > by first enhancing ACX_CONFIGURE_DIR to allow us to pass extra
> > arguments to be passed to the configure command, and then by modifying
> > GDB's configure to pass --disable-largefile if large-file support
> > is disabled.
> 
> Shouldn't this be reported to gnulib folks and preferably fixed there?

I do not think so, because gnulib can be used independently of procfs,
in which case you would probably want gnulib to have large-file support
by default. It's only in GDB and binutils' peculiar situation that
we need to disable by default.
Eli Zaretskii Dec. 4, 2014, 6:47 a.m. UTC | #4
> Date: Thu, 4 Dec 2014 07:18:28 +0400
> From: Joel Brobecker <brobecker@adacore.com>
> Cc: gdb-patches@sourceware.org, yao@codesourcery.com
> 
> > > But gnulib ignores this fact, and so tries to determine how to
> > > enable large-file support irrespective of whether we want it or not.
> > > This patch fixes the issue by passing --disable-largefile to gnulib's
> > > configure when large-file support in GDB is disabled. This is done
> > > by first enhancing ACX_CONFIGURE_DIR to allow us to pass extra
> > > arguments to be passed to the configure command, and then by modifying
> > > GDB's configure to pass --disable-largefile if large-file support
> > > is disabled.
> > 
> > Shouldn't this be reported to gnulib folks and preferably fixed there?
> 
> I do not think so, because gnulib can be used independently of procfs,
> in which case you would probably want gnulib to have large-file support
> by default. It's only in GDB and binutils' peculiar situation that
> we need to disable by default.

Gnulib could have the necessary magic to DTRT in both situations, I
think.

Anyway, I don't think it's wise to not even tell Gnulib folks about
this.  If they say it's just our problem, so be it.  But they might
have other proposals.
Joel Brobecker Dec. 13, 2014, 2:46 p.m. UTC | #5
> > This patch fixes the issue by passing --disable-largefile to gnulib's
> > configure when large-file support in GDB is disabled. This is done
> > by first enhancing ACX_CONFIGURE_DIR to allow us to pass extra
> > arguments to be passed to the configure command, and then by modifying
> > GDB's configure to pass --disable-largefile if large-file support
> > is disabled.
> 
> I tested this patch by configuring gdb with --disable-largefile for
> x86-linux and mingw32.  Everything looks right to me.

Thank you, Yao. Patch now pushed.
Joel Brobecker Dec. 13, 2014, 4:29 p.m. UTC | #6
> > I do not think so, because gnulib can be used independently of procfs,
> > in which case you would probably want gnulib to have large-file support
> > by default. It's only in GDB and binutils' peculiar situation that
> > we need to disable by default.
> 
> Gnulib could have the necessary magic to DTRT in both situations, I
> think.
> 
> Anyway, I don't think it's wise to not even tell Gnulib folks about
> this.  If they say it's just our problem, so be it.  But they might
> have other proposals.

FTR, reported at:
http://lists.gnu.org/archive/html/bug-gnulib/2014-12/msg00177.html
diff mbox

Patch

diff --git a/gdb/acx_configure_dir.m4 b/gdb/acx_configure_dir.m4
index 5a76eba..f5ae3a2 100644
--- a/gdb/acx_configure_dir.m4
+++ b/gdb/acx_configure_dir.m4
@@ -4,7 +4,7 @@ 
 # unlimited permission to copy and/or distribute it, with or without
 # modifications, as long as this notice is preserved.
 
-# ACX_CONFIGURE_DIR(SRC-DIR-NAME, BUILD-DIR-NAME)
+# ACX_CONFIGURE_DIR(SRC-DIR-NAME, BUILD-DIR-NAME, EXTRA-ARGS)
 # ---------------------------
 #
 # Configure a subdirectory.  This is an alternative to
@@ -16,11 +16,14 @@ 
 # Inputs:
 #   - SRC-DIR-NAME is the source directory, relative to $srcdir.
 #   - BUILD-DIR-NAME is `top-build -> build'
+#   - EXTRA-ARGS is an optional list of extra arguments to add
+#     at the end of the configure command.
 
 AC_DEFUN([ACX_CONFIGURE_DIR],
 [
   in_src=$1
   in_build=$2
+  in_extra_args=$3
 
   # Remove --cache-file, --srcdir, and --disable-option-checking arguments
   # so they do not pile up.
@@ -105,6 +108,11 @@  AC_DEFUN([ACX_CONFIGURE_DIR],
     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
+
   AC_MSG_NOTICE([running $SHELL $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir])
   # The eval makes quoting arguments work.
   eval "\$SHELL \"\$ac_sub_configure\" $ac_sub_configure_args \
diff --git a/gdb/configure b/gdb/configure
index e449aa6..d074aef 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -4836,6 +4836,12 @@  $as_echo "no" >&6; }
 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 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
@@ -4843,6 +4849,7 @@  fi
 
   in_src="gnulib"
   in_build="build-gnulib"
+  in_extra_args="$gnulib_extra_configure_args"
 
   # Remove --cache-file, --srcdir, and --disable-option-checking arguments
   # so they do not pile up.
@@ -4927,6 +4934,11 @@  fi
     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.
diff --git a/gdb/configure.ac b/gdb/configure.ac
index cd4c183..79ebc99 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -51,11 +51,18 @@  esac
 AM_CONDITIONAL(GMAKE, test "$MAKE_IS_GNU" = yes)
 AC_PROG_MAKE_SET
 
+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 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"])
+ACX_CONFIGURE_DIR(["gnulib"], ["build-gnulib"],
+                  ["$gnulib_extra_configure_args"])
 
 dnl List of object files and targets accumulated by configure.
 
diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure
index 45838f5..45efc51 100755
--- a/gdb/gdbserver/configure
+++ b/gdb/gdbserver/configure
@@ -4514,6 +4514,12 @@  $as_echo "no" >&6; }
 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
@@ -4522,6 +4528,7 @@  fi
 
   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.
@@ -4606,6 +4613,11 @@  fi
     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.
@@ -4619,6 +4631,7 @@  $as_echo "$as_me: running $SHELL $ac_sub_configure $ac_sub_configure_args --cach
 
   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.
@@ -4703,6 +4716,11 @@  $as_echo "$as_me: running $SHELL $ac_sub_configure $ac_sub_configure_args --cach
     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.
diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac
index f59e65b..c9bb15d 100644
--- a/gdb/gdbserver/configure.ac
+++ b/gdb/gdbserver/configure.ac
@@ -69,12 +69,19 @@  esac
 AM_CONDITIONAL(GMAKE, test "$MAKE_IS_GNU" = yes)
 AC_PROG_MAKE_SET
 
+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"])
+ACX_CONFIGURE_DIR(["../gnulib"], ["build-gnulib-gdbserver"],
+                  ["$gnulib_extra_configure_args"])
 
 ACX_CONFIGURE_DIR(["../../libiberty"], ["build-libiberty-gdbserver"])