[RFA-v2] testsuite: Avoid auto-import warning on cygwin/mingw

Pierre Muller
2009-10-02T07:29:25Z

> > Is this OK?
> >
>
> I _think_ the idea is fine.

Thanks,

> IWBN to have basic tests covering
> printing auto-imported vs dllimported variables,
> and covering stepping into import-lib'ed dll functions (through
> the __imp_ trampolines).

Not sure, I really get this, sorry.

> > --- lib/gdb.exp 13 Jul 2009 19:24:18 -0000 1.119
> > +++ lib/gdb.exp 1 Oct 2009 22:03:25 -0000
> > @@ -1731,7 +1731,10 @@ proc gdb_compile {source dest type optio
> > lappend options "additional_flags=-L${outdir}"
> > } elseif { [istarget "mips-sgi-irix*"] } {
> > lappend options "additional_flags=-rpath
> ${outdir}"
> > - }
> > + } elseif { ([istarget "*-*-mingw*"]
> > + || [istarget *-*-cygwin*]) } {
> > + lappend new_options
> > "additional_flags=-Wl,--enable-auto-import"
>
> Did you mean 'lappend options'?

No, appending to options
would mean that this addition would be parsed by the loop
'foreach opt $options {'
of line 1713,
while adding it to new_options like it
is done also below for 'shlib_load'.

Furthermore, I always feel uncomfortable
when code inside a loop changes the variable
on which the loop is performed (options in that case.)
Wouldn't it be better to also
append to new_options for the two conditions above?

So, what about this?

2009-10-02 Pierre Muller <muller@ics.u-strasbg.fr>

* lib/gdb.exp (gdb_compile): Append added options
directly to new_options variable.
Add --enable-auto-import option for
mingw and cygwin targets.

Index: lib/gdb.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/lib/gdb.exp,v
retrieving revision 1.119
diff -u -p -r1.119 gdb.exp
--- lib/gdb.exp 13 Jul 2009 19:24:18 -0000 1.119
+++ lib/gdb.exp 2 Oct 2009 07:26:54 -0000
@@ -1728,10 +1728,13 @@ proc gdb_compile {source dest type optio
if { ([test_compiler_info "gcc-*"]
&& ([istarget "powerpc*-*-aix*"]
|| [istarget "rs6000*-*-aix*"] )) } {
- lappend options "additional_flags=-L${outdir}"
+ lappend new_options "additional_flags=-L${outdir}"
} elseif { [istarget "mips-sgi-irix*"] } {
- lappend options "additional_flags=-rpath ${outdir}"
- }
+ lappend new_options "additional_flags=-rpath ${outdir}"
+ } elseif { ([istarget "*-*-mingw*"]
+ || [istarget *-*-cygwin*]) } {
+ lappend new_options
"additional_flags=-Wl,--enable-auto-import"
+ }
}
} elseif { $opt == "shlib_load" } {
if { ([istarget "*-*-mingw*"]