Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFC]: Use `gdb_compile' instead of `target_link' for linking asm-source testcase
@ 2001-12-18  5:59 Corinna Vinschen
  2001-12-18 10:38 ` Fernando Nasser
  0 siblings, 1 reply; 6+ messages in thread
From: Corinna Vinschen @ 2001-12-18  5:59 UTC (permalink / raw)
  To: gdb, gdb-patches

Hi,

I would like to propose a change in the asm testcase in testsuite/gdb.asm.

The target_link should get substituted by a call to gdb_compile
using the `-nostartfiles' option for the following reason.

Some (many?) targets have to support several different variants
as, e.g., coff or elf exec format, simulated or real HW targets,
etc.

Each of these styles need a slightly different handling.  E.g. some
embedded boards need a special link flag while another board using
the same CPU need another link flag while the simulated target needs
again another flag (-Tfoo.ld, -Tfoo-bar.ld, -Tfoo-sim.ld, ...)

While the gcc flags for these variants are typically correctly setup
in the external board files, we can't rely on these flags correctly
set up for a direct call to the linker, resulting in an increasingly
messy target depended prologue in asm-source.exp as new targets support
that test.

Therefore I'm proposing to change the call to target_link in this
testcase as soon as possible to a call to gdb_compile with the
gcc flag `-nostartfiles' set, which result in the same testcase but
w/o the need to care for each single flag needed for our targets.

The patch itself is easy.  If it's really necessary, a target could
still add link-flags but e.g. for the XStormy16 target I could even
drop that setting.  It's superfluous now since the board description
files already care for the correct settings.

The below patch would do it (including dropping the XScale link-flags
setting.

Corinna


2001-12-18  Corinna Vinschen  <vinschen@redhat.com>

	* gdb.asm/asm-source.exp: Drop setting link-flags for xstormy16.
	Substitute call to target_link by call to gdb_compile.


Index: gdb.asm/asm-source.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.asm/asm-source.exp,v
retrieving revision 1.14
diff -u -p -r1.14 asm-source.exp
--- asm-source.exp	2001/12/13 13:42:19	1.14
+++ asm-source.exp	2001/12/18 13:58:18
@@ -53,7 +53,6 @@ if [istarget "sparc-*-*"] then {
 if [istarget "xstormy16-*-*"] then {
     set asm-arch xstormy16
     set asm-flags "-gdwarf2 -I${srcdir}/${subdir} -I${objdir}/${subdir}"
-    set link-flags "-L${objdir}/../../gcc"
 }
 if { "${asm-arch}" == "" } {
     gdb_suppress_entire_file "Assembly source test -- not implemented for this target."
@@ -76,7 +75,11 @@ if {[target_assemble ${src2} asmsrc2.o "
      gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
 }
 
-if  { [target_link "asmsrc1.o asmsrc2.o" ${binfile} "${link-flags}"] != "" } {
+set opts "debug ldflags=-nostartfiles"
+foreach i ${link-flags} {
+    append opts " ldflags=$i"
+}
+if { [gdb_compile "asmsrc1.o asmsrc2.o" "${binfile}" executable $opts] != "" } {
      gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
 }
 
-- 
Corinna Vinschen
Cygwin Developer
Red Hat, Inc.
mailto:vinschen@redhat.com


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

* Re: [RFC]: Use `gdb_compile' instead of `target_link' for linking  asm-source testcase
  2001-12-18  5:59 [RFC]: Use `gdb_compile' instead of `target_link' for linking asm-source testcase Corinna Vinschen
@ 2001-12-18 10:38 ` Fernando Nasser
  2001-12-20  3:35   ` Corinna Vinschen
  0 siblings, 1 reply; 6+ messages in thread
From: Fernando Nasser @ 2001-12-18 10:38 UTC (permalink / raw)
  To: Corinna Vinschen; +Cc: gdb, gdb-patches, Michael Snyder

This looks reasonable to me.

Fernando

Corinna Vinschen wrote:
> 
> Hi,
> 
> I would like to propose a change in the asm testcase in testsuite/gdb.asm.
> 
> The target_link should get substituted by a call to gdb_compile
> using the `-nostartfiles' option for the following reason.
> 
> Some (many?) targets have to support several different variants
> as, e.g., coff or elf exec format, simulated or real HW targets,
> etc.
> 
> Each of these styles need a slightly different handling.  E.g. some
> embedded boards need a special link flag while another board using
> the same CPU need another link flag while the simulated target needs
> again another flag (-Tfoo.ld, -Tfoo-bar.ld, -Tfoo-sim.ld, ...)
> 
> While the gcc flags for these variants are typically correctly setup
> in the external board files, we can't rely on these flags correctly
> set up for a direct call to the linker, resulting in an increasingly
> messy target depended prologue in asm-source.exp as new targets support
> that test.
> 
> Therefore I'm proposing to change the call to target_link in this
> testcase as soon as possible to a call to gdb_compile with the
> gcc flag `-nostartfiles' set, which result in the same testcase but
> w/o the need to care for each single flag needed for our targets.
> 
> The patch itself is easy.  If it's really necessary, a target could
> still add link-flags but e.g. for the XStormy16 target I could even
> drop that setting.  It's superfluous now since the board description
> files already care for the correct settings.
> 
> The below patch would do it (including dropping the XScale link-flags
> setting.
> 
> Corinna
> 
> 2001-12-18  Corinna Vinschen  <vinschen@redhat.com>
> 
>         * gdb.asm/asm-source.exp: Drop setting link-flags for xstormy16.
>         Substitute call to target_link by call to gdb_compile.
> 
> Index: gdb.asm/asm-source.exp
> ===================================================================
> RCS file: /cvs/src/src/gdb/testsuite/gdb.asm/asm-source.exp,v
> retrieving revision 1.14
> diff -u -p -r1.14 asm-source.exp
> --- asm-source.exp      2001/12/13 13:42:19     1.14
> +++ asm-source.exp      2001/12/18 13:58:18
> @@ -53,7 +53,6 @@ if [istarget "sparc-*-*"] then {
>  if [istarget "xstormy16-*-*"] then {
>      set asm-arch xstormy16
>      set asm-flags "-gdwarf2 -I${srcdir}/${subdir} -I${objdir}/${subdir}"
> -    set link-flags "-L${objdir}/../../gcc"
>  }
>  if { "${asm-arch}" == "" } {
>      gdb_suppress_entire_file "Assembly source test -- not implemented for this target."
> @@ -76,7 +75,11 @@ if {[target_assemble ${src2} asmsrc2.o "
>       gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
>  }
> 
> -if  { [target_link "asmsrc1.o asmsrc2.o" ${binfile} "${link-flags}"] != "" } {
> +set opts "debug ldflags=-nostartfiles"
> +foreach i ${link-flags} {
> +    append opts " ldflags=$i"
> +}
> +if { [gdb_compile "asmsrc1.o asmsrc2.o" "${binfile}" executable $opts] != "" } {
>       gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
>  }
> 
> --
> Corinna Vinschen
> Cygwin Developer
> Red Hat, Inc.
> mailto:vinschen@redhat.com

-- 
Fernando Nasser
Red Hat - Toronto                       E-Mail:  fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario   M4P 2C9


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

* Re: [RFC]: Use `gdb_compile' instead of `target_link' for linking asm-source testcase
  2001-12-18 10:38 ` Fernando Nasser
@ 2001-12-20  3:35   ` Corinna Vinschen
  2001-12-20  5:54     ` Fernando Nasser
  0 siblings, 1 reply; 6+ messages in thread
From: Corinna Vinschen @ 2001-12-20  3:35 UTC (permalink / raw)
  To: gdb, gdb-patches

On Tue, Dec 18, 2001 at 01:38:20PM -0500, Fernando Nasser wrote:
> This looks reasonable to me.
> 
> Fernando

Since there's no further discussion or any complaints, does that mean
the patch is ok and approved?

Corinna

> 
> Corinna Vinschen wrote:
> > 
> > Hi,
> > 
> > I would like to propose a change in the asm testcase in testsuite/gdb.asm.
> > 
> > The target_link should get substituted by a call to gdb_compile
> > using the `-nostartfiles' option for the following reason.
> > 
> > Some (many?) targets have to support several different variants
> > as, e.g., coff or elf exec format, simulated or real HW targets,
> > etc.
> > 
> > Each of these styles need a slightly different handling.  E.g. some
> > embedded boards need a special link flag while another board using
> > the same CPU need another link flag while the simulated target needs
> > again another flag (-Tfoo.ld, -Tfoo-bar.ld, -Tfoo-sim.ld, ...)
> > 
> > While the gcc flags for these variants are typically correctly setup
> > in the external board files, we can't rely on these flags correctly
> > set up for a direct call to the linker, resulting in an increasingly
> > messy target depended prologue in asm-source.exp as new targets support
> > that test.
> > 
> > Therefore I'm proposing to change the call to target_link in this
> > testcase as soon as possible to a call to gdb_compile with the
> > gcc flag `-nostartfiles' set, which result in the same testcase but
> > w/o the need to care for each single flag needed for our targets.
> > 
> > The patch itself is easy.  If it's really necessary, a target could
> > still add link-flags but e.g. for the XStormy16 target I could even
> > drop that setting.  It's superfluous now since the board description
> > files already care for the correct settings.
> > 
> > The below patch would do it (including dropping the XScale link-flags
> > setting.
> > 
> > Corinna
> > 
> > 2001-12-18  Corinna Vinschen  <vinschen@redhat.com>
> > 
> >         * gdb.asm/asm-source.exp: Drop setting link-flags for xstormy16.
> >         Substitute call to target_link by call to gdb_compile.
> > 
> > Index: gdb.asm/asm-source.exp
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/testsuite/gdb.asm/asm-source.exp,v
> > retrieving revision 1.14
> > diff -u -p -r1.14 asm-source.exp
> > --- asm-source.exp      2001/12/13 13:42:19     1.14
> > +++ asm-source.exp      2001/12/18 13:58:18
> > @@ -53,7 +53,6 @@ if [istarget "sparc-*-*"] then {
> >  if [istarget "xstormy16-*-*"] then {
> >      set asm-arch xstormy16
> >      set asm-flags "-gdwarf2 -I${srcdir}/${subdir} -I${objdir}/${subdir}"
> > -    set link-flags "-L${objdir}/../../gcc"
> >  }
> >  if { "${asm-arch}" == "" } {
> >      gdb_suppress_entire_file "Assembly source test -- not implemented for this target."
> > @@ -76,7 +75,11 @@ if {[target_assemble ${src2} asmsrc2.o "
> >       gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
> >  }
> > 
> > -if  { [target_link "asmsrc1.o asmsrc2.o" ${binfile} "${link-flags}"] != "" } {
> > +set opts "debug ldflags=-nostartfiles"
> > +foreach i ${link-flags} {
> > +    append opts " ldflags=$i"
> > +}
> > +if { [gdb_compile "asmsrc1.o asmsrc2.o" "${binfile}" executable $opts] != "" } {
> >       gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
> >  }
> > 
> > --
> > Corinna Vinschen
> > Cygwin Developer
> > Red Hat, Inc.
> > mailto:vinschen@redhat.com
> 
> -- 
> Fernando Nasser
> Red Hat - Toronto                       E-Mail:  fnasser@redhat.com
> 2323 Yonge Street, Suite #300
> Toronto, Ontario   M4P 2C9

-- 
Corinna Vinschen
Cygwin Developer
Red Hat, Inc.
mailto:vinschen@redhat.com


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

* Re: [RFC]: Use `gdb_compile' instead of `target_link' for linking  asm-source testcase
  2001-12-20  3:35   ` Corinna Vinschen
@ 2001-12-20  5:54     ` Fernando Nasser
  2001-12-20  8:09       ` Corinna Vinschen
  0 siblings, 1 reply; 6+ messages in thread
From: Fernando Nasser @ 2001-12-20  5:54 UTC (permalink / raw)
  To: Corinna Vinschen; +Cc: gdb, gdb-patches

Corinna Vinschen wrote:
> 
> On Tue, Dec 18, 2001 at 01:38:20PM -0500, Fernando Nasser wrote:
> > This looks reasonable to me.
> >
> > Fernando
> 
> Since there's no further discussion or any complaints, does that mean
> the patch is ok and approved?
> 

Yes.   Thanks.

-- 
Fernando Nasser
Red Hat Canada Ltd.                     E-Mail:  fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario   M4P 2C9


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

* Re: [RFC]: Use `gdb_compile' instead of `target_link' for linking asm-source testcase
  2001-12-20  5:54     ` Fernando Nasser
@ 2001-12-20  8:09       ` Corinna Vinschen
  2001-12-27  6:30         ` Mark Kettenis
  0 siblings, 1 reply; 6+ messages in thread
From: Corinna Vinschen @ 2001-12-20  8:09 UTC (permalink / raw)
  To: gdb-patches

On Thu, Dec 20, 2001 at 08:53:12AM -0500, Fernando Nasser wrote:
> Corinna Vinschen wrote:
> > 
> > On Tue, Dec 18, 2001 at 01:38:20PM -0500, Fernando Nasser wrote:
> > > This looks reasonable to me.
> > >
> > > Fernando
> > 
> > Since there's no further discussion or any complaints, does that mean
> > the patch is ok and approved?
> > 
> 
> Yes.   Thanks.

Thanks, applied.

Corinna


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

* Re: [RFC]: Use `gdb_compile' instead of `target_link' for linking asm-source testcase
  2001-12-20  8:09       ` Corinna Vinschen
@ 2001-12-27  6:30         ` Mark Kettenis
  0 siblings, 0 replies; 6+ messages in thread
From: Mark Kettenis @ 2001-12-27  6:30 UTC (permalink / raw)
  To: gdb-patches

Corinna Vinschen <vinschen@redhat.com> writes:

> On Thu, Dec 20, 2001 at 08:53:12AM -0500, Fernando Nasser wrote:
> > Corinna Vinschen wrote:
> > > 
> > > On Tue, Dec 18, 2001 at 01:38:20PM -0500, Fernando Nasser wrote:
> > > > This looks reasonable to me.
> > > >
> > > > Fernando
> > > 
> > > Since there's no further discussion or any complaints, does that mean
> > > the patch is ok and approved?
> > > 
> > 
> > Yes.   Thanks.
> 
> Thanks, applied.

Unfortunately this breaks the test on FreeBSD 4.4.

gdb_compile automatically links against libc, and on FreeBSD that
makes the link fail since libc depends on certain symbols in crt0.o,
which we don't link in because of -nostartfiles.  Adding -nostdlib
isn't an option since gdb_compile also adds -lm which depends on
libc.  Removing -nostartfiles isn't an option either since it would
result in confilicting symbols.

Instead of reverting Corrina's patch, we could add "-static" to
ldflags (see the attached patch).

Opinions?

Index: testsuite/ChangeLog
from  Mark Kettenis  <kettenis@gnu.org>

	* gdb.asm/asm-source.exp: Add ldflags=-static for gdb_compile.

Index: testsuite/gdb.asm/asm-source.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.asm/asm-source.exp,v
retrieving revision 1.16
diff -u -p -r1.16 asm-source.exp
--- testsuite/gdb.asm/asm-source.exp 2001/12/20 22:12:20 1.16
+++ testsuite/gdb.asm/asm-source.exp 2001/12/27 14:27:51
@@ -81,7 +81,7 @@ if {[target_assemble ${src2} asmsrc2.o "
      gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
 }
 
-set opts "debug ldflags=-nostartfiles"
+set opts "debug ldflags=-nostartfiles ldflags=-static"
 foreach i ${link-flags} {
     append opts " ldflags=$i"
 }


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

end of thread, other threads:[~2001-12-27 14:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-12-18  5:59 [RFC]: Use `gdb_compile' instead of `target_link' for linking asm-source testcase Corinna Vinschen
2001-12-18 10:38 ` Fernando Nasser
2001-12-20  3:35   ` Corinna Vinschen
2001-12-20  5:54     ` Fernando Nasser
2001-12-20  8:09       ` Corinna Vinschen
2001-12-27  6:30         ` Mark Kettenis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox