diff mbox series

configure: Re-disable building cross-gdbserver

Message ID alpine.LFD.2.21.2002081532520.18621@redsun52.ssa.fujisawa.hgst.com
State Not Applicable
Headers show
Series configure: Re-disable building cross-gdbserver | expand

Commit Message

Maciej W. Rozycki Feb. 8, 2020, 4:21 p.m. UTC
Correct fallout from commit 919adfe84092 ("Move gdbserver to top level") 
and revert to not building `gdbserver' in a cross-configuration, that is 
where host != target, matching the documented behaviour.  We have no way 
to support non-native `gdbserver', and native `gdbserver' is usually of 
no use with cross-GDB of the chosen host.

	* configure.ac: Do not build `gdbserver' if $is_cross_compiler.
	* configure: Regenerate.
---
Hi,

 Verified with a native build, a crossed build of a native configuration 
and a build of a cross-debugger; Canadian Cross not checked.  OK to apply?

 NB I have noticed that the gdbserver(1) man page is still being built and 
installed (as ${target_alias}-gdbserver.1, if building a cross-debugger), 
even if `gdbserver' itself is not (and it is not built if only `gdbserver' 
is while GDB is not).  Obviously this is due to the man page still living 
under gdb/doc/, and I presume it will be addressed sometime soon, by 
moving the man page somewhere under gdbserver/, right?

 Also there are currently a number of mismatches in configure.ac between 
the gcc and the binutils-gdb repositories; what is the plan to eliminate 
them?

  Maciej
---
 configure    |    5 +++--
 configure.ac |    5 +++--
 2 files changed, 6 insertions(+), 4 deletions(-)

gdbserver-no-cross.diff

Comments

Tom Tromey Feb. 11, 2020, 3:24 p.m. UTC | #1
>>>>> "Maciej" == Maciej W Rozycki <macro@wdc.com> writes:

Maciej> Correct fallout from commit 919adfe84092 ("Move gdbserver to top level") 
Maciej> and revert to not building `gdbserver' in a cross-configuration, that is 
Maciej> where host != target, matching the documented behaviour.  We have no way 
Maciej> to support non-native `gdbserver', and native `gdbserver' is usually of 
Maciej> no use with cross-GDB of the chosen host.

Pedro had a different way to do this, that keeps the decision under
gdbserver's control:

https://sourceware.org/ml/gdb-patches/2020-02/msg00383.html

Also note that I haven't sent the top-level configury patches upstream
to gcc yet.  I am going to do this all at once, at the end.  I think
there's one more patch that will be needed, once gdbserver depends on
the top-level gdbsupport.

Tom
Maciej W. Rozycki Feb. 11, 2020, 9:01 p.m. UTC | #2
On Tue, 11 Feb 2020, Tom Tromey wrote:

> Maciej> Correct fallout from commit 919adfe84092 ("Move gdbserver to top level") 
> Maciej> and revert to not building `gdbserver' in a cross-configuration, that is 
> Maciej> where host != target, matching the documented behaviour.  We have no way 
> Maciej> to support non-native `gdbserver', and native `gdbserver' is usually of 
> Maciej> no use with cross-GDB of the chosen host.
> 
> Pedro had a different way to do this, that keeps the decision under
> gdbserver's control:
> 
> https://sourceware.org/ml/gdb-patches/2020-02/msg00383.html

 That's actually quite similar to what I considered first, before I 
changed my mind.  Whatever.

 However I would expect `exit' not to be what we want in a sourced script 
(I did this differently; see below).

> Also note that I haven't sent the top-level configury patches upstream
> to gcc yet.  I am going to do this all at once, at the end.  I think
> there's one more patch that will be needed, once gdbserver depends on
> the top-level gdbsupport.

 Ack.

  Maciej
---
 gdbserver/configure.srv |    8 ++++++++
 1 file changed, 8 insertions(+)

Index: binutils-gdb/gdbserver/configure.srv
===================================================================
--- binutils-gdb.orig/gdbserver/configure.srv
+++ binutils-gdb/gdbserver/configure.srv
@@ -36,6 +36,14 @@ srv_linux_obj="linux-low.o nat/linux-osd
 # Input is taken from the "${host}" variable.
 
 case "${host}" in
+  ${target})
+			gdbserver_host=${host}
+			;;
+  *)
+			gdbserver_host=NONE
+			;;
+esac
+case "${gdbserver_host}" in
   aarch64*-*-linux*)	srv_tgtobj="linux-aarch64-low.o"
 			srv_tgtobj="$srv_tgtobj nat/aarch64-linux-hw-point.o"
 			srv_tgtobj="$srv_tgtobj linux-aarch32-low.o"
Pedro Alves Feb. 12, 2020, 1:56 p.m. UTC | #3
On 2/11/20 9:01 PM, Maciej W. Rozycki wrote:
> On Tue, 11 Feb 2020, Tom Tromey wrote:
> 
>> Maciej> Correct fallout from commit 919adfe84092 ("Move gdbserver to top level") 
>> Maciej> and revert to not building `gdbserver' in a cross-configuration, that is 
>> Maciej> where host != target, matching the documented behaviour.  We have no way 
>> Maciej> to support non-native `gdbserver', and native `gdbserver' is usually of 
>> Maciej> no use with cross-GDB of the chosen host.
>>
>> Pedro had a different way to do this, that keeps the decision under
>> gdbserver's control:
>>
>> https://sourceware.org/ml/gdb-patches/2020-02/msg00383.html
> 
>  That's actually quite similar to what I considered first, before I 
> changed my mind.  Whatever.

Doing it in gdbserver/ has the advantage that it stays under gdbserver's
control, so it doesn't need syncing code with the gcc tree.  I know of at
least one off-tree port that uses gdbserver in a host != target scenario,
so I imagine that this condition will evolve over time.

Also, this way, changes in this area don't require running autoconf to
regenerate configure.

I'm not seeing any downside.

> 
>  However I would expect `exit' not to be what we want in a sourced script 
> (I did this differently; see below).

Good point, somehow did not think of that.
It worked in my patch because we source the script in a sub-shell.
But it's clearer/better to not rely on that.

>  
>  case "${host}" in
> +  ${target})
> +			gdbserver_host=${host}
> +			;;
> +  *)
> +			gdbserver_host=NONE
> +			;;
if/else reads more to-the-point to me, so I tweaked it that
way, and merged it in (to binutils-gdb), like below.

I'm sorry for not noticing your earlier patch.

From f20e3e823d56e54ffe56792ea6a2fe947c2dec0d Mon Sep 17 00:00:00 2001
From: "Maciej W. Rozycki" <macro@wdc.com>
Date: Wed, 12 Feb 2020 13:50:30 +0000
Subject: [PATCH] Disable gdbserver on host != target configurations

Correct fallout from commit 919adfe84092 ("Move gdbserver to top level")
and revert to not building `gdbserver' in a cross-configuration, that is
where host != target, matching the documented behaviour.  We have no way
to support non-native `gdbserver', and native `gdbserver' is usually of
no use with cross-GDB of the chosen host.

gdbserver/ChangeLog:
2020-02-12  Maciej W. Rozycki <macro@wdc.com>
	    Pedro Alves  <palves@redhat.com>

	Skip building gdbserver in a cross-configuration.
	* configure.srv: Set $gdbserver_host depending on whether $target
	is $host.  Use $gdbserver_host instead of $host.
---
 gdbserver/ChangeLog     |  7 +++++++
 gdbserver/configure.srv | 11 +++++++++--
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/gdbserver/ChangeLog b/gdbserver/ChangeLog
index 09707067730..709ef23674c 100644
--- a/gdbserver/ChangeLog
+++ b/gdbserver/ChangeLog
@@ -1,3 +1,10 @@
+2020-02-12  Maciej W. Rozycki <macro@wdc.com>
+	    Pedro Alves  <palves@redhat.com>
+
+	Skip building gdbserver in a cross-configuration.
+	* configure.srv: Set $gdbserver_host depending on whether $target
+	is $host.  Use $gdbserver_host instead of $host.
+
 2020-02-11  Simon Marchi  <simon.marchi@efficios.com>
 
 	* configure: Re-generate.
diff --git a/gdbserver/configure.srv b/gdbserver/configure.srv
index 2e83cbdc07f..375ac0aeb2a 100644
--- a/gdbserver/configure.srv
+++ b/gdbserver/configure.srv
@@ -33,9 +33,16 @@ ipa_ppc_linux_regobj="powerpc-32l-ipa.o powerpc-altivec32l-ipa.o powerpc-vsx32l-
 # these files over and over again.
 srv_linux_obj="linux-low.o nat/linux-osdata.o nat/linux-procfs.o nat/linux-ptrace.o nat/linux-waitpid.o nat/linux-personality.o nat/linux-namespaces.o fork-child.o nat/fork-inferior.o"
 
-# Input is taken from the "${host}" variable.
+# Input is taken from the "${host}" and "${target}" variables.
 
-case "${host}" in
+# GDBserver can only debug native programs.
+if test "${target}" = "${host}"; then
+    gdbserver_host=${host}
+else
+    gdbserver_host=
+fi
+
+case "${gdbserver_host}" in
   aarch64*-*-linux*)	srv_tgtobj="linux-aarch64-low.o"
 			srv_tgtobj="$srv_tgtobj nat/aarch64-linux-hw-point.o"
 			srv_tgtobj="$srv_tgtobj linux-aarch32-low.o"

base-commit: 38de8abe21fe17c31888094bd860a84f88cb5749
Maciej W. Rozycki Feb. 13, 2020, 11:48 p.m. UTC | #4
On Wed, 12 Feb 2020, Pedro Alves wrote:

> >  That's actually quite similar to what I considered first, before I 
> > changed my mind.  Whatever.
> 
> Doing it in gdbserver/ has the advantage that it stays under gdbserver's
> control, so it doesn't need syncing code with the gcc tree.  I know of at
> least one off-tree port that uses gdbserver in a host != target scenario,
> so I imagine that this condition will evolve over time.

 Sure, that makes sense to me.

> >  case "${host}" in
> > +  ${target})
> > +			gdbserver_host=${host}
> > +			;;
> > +  *)
> > +			gdbserver_host=NONE
> > +			;;
> if/else reads more to-the-point to me, so I tweaked it that
> way, and merged it in (to binutils-gdb), like below.

 Great, thanks for handling this!

> I'm sorry for not noticing your earlier patch.

 No worries, I'm glad we've got this sorted.

  Maciej
diff mbox series

Patch

Index: binutils-gdb/configure
===================================================================
--- binutils-gdb.orig/configure
+++ binutils-gdb/configure
@@ -3538,12 +3538,13 @@  case "${target}" in
     ;;
 esac
 
-# Only allow gdbserver on some systems.
+# Only allow native gdbserver and then only on some systems.
 if test -d ${srcdir}/gdbserver; then
     if test x$enable_gdbserver = x; then
 	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gdbserver support" >&5
 $as_echo_n "checking for gdbserver support... " >&6; }
-	if (srcdir=${srcdir}/gdbserver; \
+	if test x${is_cross_compiler} = xyes \
+	    || (srcdir=${srcdir}/gdbserver; \
 		. ${srcdir}/configure.srv; \
 		test -n "$UNSUPPORTED")
 	then
Index: binutils-gdb/configure.ac
===================================================================
--- binutils-gdb.orig/configure.ac
+++ binutils-gdb/configure.ac
@@ -782,11 +782,12 @@  case "${target}" in
     ;;
 esac
 
-# Only allow gdbserver on some systems.
+# Only allow native gdbserver and then only on some systems.
 if test -d ${srcdir}/gdbserver; then
     if test x$enable_gdbserver = x; then
 	AC_MSG_CHECKING([for gdbserver support])
-	if (srcdir=${srcdir}/gdbserver; \
+	if test x${is_cross_compiler} = xyes \
+	    || (srcdir=${srcdir}/gdbserver; \
 		. ${srcdir}/configure.srv; \
 		test -n "$UNSUPPORTED")
 	then