diff mbox

[testsuite,ada] Convert ACATS to DejaGnu (PR testsuite/37703)

Message ID yddr5bt6nxw.fsf@manam.CeBiTec.Uni-Bielefeld.DE
State New
Headers show

Commit Message

Rainer Orth Jan. 31, 2011, 4:24 p.m. UTC
As I've mentioned before, I've long meant to convert the ACATS testsuite
to DejaGnu to provide all dg features (timeouts, xfails, multilib
support, don't copy all sources into the build dir).  After the gnat.dg
cleanup patch (and requiring it), here's the first version of a patch
that does this.  It is by no means ready or polished, but I'm asking for
general comments, suggestions for fixes or improvements, and testers.

At least it has passed a make -k check on i386-pc-solaris2.11 this
weekend with the following results:

		=== gnat tests ===


Running target unix

		=== gnat Summary for unix ===

# of expected passes		5500
# of expected failures		10
# of unsupported tests		3

Running target unix/-m64
FAIL: c9a011b.adb execution test
FAIL: cb1010c.adb -O2 -fstack-check execution test
FAIL: cb1010d.adb -O2 -fstack-check execution test
WARNING: program timed out.

		=== gnat Summary for unix/-m64 ===

# of expected passes		5497
# of unexpected failures	3
# of expected failures		10
# of unsupported tests		3

		=== gnat Summary ===

# of expected passes		10997
# of unexpected failures	3
# of expected failures		20
# of unsupported tests		6
/vol/gcc/obj/gcc-4.6.0-20110128/11-gcc-gas-go/gcc/gnatmake version 4.6.0 20110128 (experimental) [trunk revision 169359]

The 64-bit -fstack-check failures may be due to the fact that I've
doubled the stack size limit for the make check run to account for a few
non-Ada tests that fail with the default, but have not yet implemented
this snippet in run_acats in DejaGnu:

# Limit the stack to 16MB for stack checking
ulimit -s 16384

As you will see, the implementation is full of FIXME comments, debug
logging, lacks error checking and some cleanup, and I've not yet
verified that the set of tests run is identical to the current one.
I'll also have to tune the parallelization to make sure that the various
parts take roughly the same time.

For the final patch, I plan to move the contents of ada/acats/tests to
gnat.acats, and ada/acats/support will go to gnat.acats/support.  The
remaining files in ada/acats, as well as support/acats25.lst, will be
removed.

One caveat: I need to be more careful parsing gnatchop output: right
now, a testsuite run removes cxh30030.a in the sourcedir since I don't
handle

writing configuration pragmas from /vol/gcc/src/hg/trunk/solaris/gcc/testsuite/ada/acats/tests/cxh/cxh30030.a to gnat.adc

correctly.

Anyway, here we go; comments welcome.

Thanks.
	Rainer


2011-01-05  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	contrib:
	PR testsuite/37703
	* dg-extract-results.sh: Remove ACATS support.

	gcc/ada:
	PR testsuite/37703
	* gcc-interface/Make-lang.in (check-ada): Remove check-acats.
	(check-ada-subtargets): Remove check-acats-subtargets.
	(ACATSDIR): Remove.
	(check_acats_targets): Remove.
	(check-acats): Remove.
	(check-acats-subtargets): Remove.
	($(check_acats_targets)): Remove.
	(.PHONY): Remove.

	gcc/testsuite:
	PR testsuite/37703
	* lib/gnat.exp: Load copy-file.exp.
	(gnat-acats-init): New proc.
	(gnat-acats-finish): New proc.
	(gnat_set_ada_env_vars): New proc.
	(gnat_target_compile): Use it.
	Remove -f from compiler.
	Pass additional_flags for ACATS.
	(find_gnatchop): New proc.
	* lib/gnat-dg.exp (acats-get-options): New proc.
	(gnat-dg-acats-runtest): New proc.
	(gnat_load): Handle ACATS status reporting.
	* gnat.acats/acats.exp: New file.

	* ada/acats/support/impdef.a (Linker_Options): Remove ACATS4GNATDIR/.
	(Test_Path_Root): Use tests/.

	* ada/acats/tests/a/ac3106a.ada: Add dg-options "-O2 -gnat95".
	* ada/acats/tests/c3/c34005p.ada: Likewise.
	* ada/acats/tests/c3/c34005r.ada: Likewise.
	* ada/acats/tests/c3/c34005s.ada: Likewise.
	* ada/acats/tests/c3/c34005u.ada: Likewise.
	* ada/acats/tests/c3/c34005v.ada: Likewise.
	* ada/acats/tests/c3/c34006g.ada: Likewise.
	* ada/acats/tests/c3/c34006j.ada: Likewise.
	* ada/acats/tests/c3/c34006l.ada: Likewise.
	* ada/acats/tests/c3/c34008a.ada: Likewise.
	* ada/acats/tests/c3/c3a0014.a: Likewise.
	* ada/acats/tests/c4/c41103b.ada: Likewise.
	* ada/acats/tests/c4/c41203b.ada: Likewise.
	* ada/acats/tests/c4/c41306a.ada: Likewise.
	* ada/acats/tests/c4/c460a01.a: Likewise.
	* ada/acats/tests/c6/c650001.a: Likewise.
	* ada/acats/tests/c7/c74302b.ada: Likewise.
	* ada/acats/tests/c7/c74306a.ada: Likewise.
	* ada/acats/tests/c8/c85014a.ada: Likewise.
	* ada/acats/tests/c8/c85014b.ada: Likewise.
	* ada/acats/tests/c8/c85014c.ada: Likewise.
	* ada/acats/tests/c8/c87b26b.ada: Likewise.
	* ada/acats/tests/c8/c87b41a.ada: Likewise.
	* ada/acats/tests/c9/c99004a.ada: Likewise.
	* ada/acats/tests/cb/cb40005.a: Likewise.
	* ada/acats/tests/cc/cc3019c0.ada: Likewise.
	* ada/acats/tests/cc/cc51b03.a: Likewise.
	* ada/acats/tests/cc/cc51d02.a: Likewise.
	* ada/acats/tests/cd/cd10002.a: Likewise.
	* ada/acats/tests/cd/cdd2a03.a: Likewise.
	* ada/acats/tests/cxa/cxac005.a: Likewise.

	* ada/acats/tests/c7/c731001.a: Add dg-options "-O2 -gnatE".
	* ada/acats/tests/c8/c854002.a: Likewise.
	* ada/acats/tests/ca/ca11018.a: Likewise.
	* ada/acats/tests/ca/ca11019.a: Likewise.
	* ada/acats/tests/ca/ca5006a.ada: Likewise.

	* ada/acats/tests/c4/c45304a.ada: Add dg-options "-O2 -gnato".
	* ada/acats/tests/c4/c45304b.dep: Likewise.
	* ada/acats/tests/c4/c45304c.dep: Likewise.
	* ada/acats/tests/c4/c45504a.ada: Likewise.
	* ada/acats/tests/c4/c45504b.dep: Likewise.
	* ada/acats/tests/c4/c45504c.dep: Likewise.
	* ada/acats/tests/c4/c45613a.ada: Likewise.
	* ada/acats/tests/c4/c45613b.dep: Likewise.
	* ada/acats/tests/c4/c45613c.dep: Likewise.
	* ada/acats/tests/c4/c45632a.ada: Likewise.
	* ada/acats/tests/c4/c45632b.dep: Likewise.
	* ada/acats/tests/c4/c45632c.dep: Likewise.
	* ada/acats/tests/c4/c460008.a: Likewise.
	* ada/acats/tests/c4/c460011.a: Likewise.
	* ada/acats/tests/c4/c46014a.ada: Likewise.
	* ada/acats/tests/c4/c4a012b.ada: Likewise.

	* ada/acats/tests/c5/c52103x.ada: Add dg-options "-O2 -fstack-check".
	* ada/acats/tests/c5/c52104x.ada: Likewise.
	* ada/acats/tests/c5/c52104y.ada: Likewise.
	* ada/acats/tests/cb/cb1010a.ada: Likewise.
	* ada/acats/tests/cb/cb1010c.ada: Likewise.
	* ada/acats/tests/cb/cb1010d.ada: Likewise.

Comments

Eric Botcazou Jan. 31, 2011, 5:09 p.m. UTC | #1
> The 64-bit -fstack-check failures may be due to the fact that I've
> doubled the stack size limit for the make check run to account for a few
> non-Ada tests that fail with the default, but have not yet implemented
> this snippet in run_acats in DejaGnu:
>
> # Limit the stack to 16MB for stack checking
> ulimit -s 16384

Yes, it is required to properly test stack checking.

> As you will see, the implementation is full of FIXME comments, debug
> logging, lacks error checking and some cleanup, and I've not yet
> verified that the set of tests run is identical to the current one.
> I'll also have to tune the parallelization to make sure that the various
> parts take roughly the same time.

Please avoid hard-coding -O2 in the tests, put only -gnat95, -gnato, etc.

> Anyway, here we go; comments welcome.

Maybe we should investigate switching to ACATS 3.0 in the process:
  http://www.ada-auth.org/acats.html
Rainer Orth Jan. 31, 2011, 5:20 p.m. UTC | #2
Eric Botcazou <ebotcazou@adacore.com> writes:

>> The 64-bit -fstack-check failures may be due to the fact that I've
>> doubled the stack size limit for the make check run to account for a few
>> non-Ada tests that fail with the default, but have not yet implemented
>> this snippet in run_acats in DejaGnu:
>>
>> # Limit the stack to 16MB for stack checking
>> ulimit -s 16384
>
> Yes, it is required to properly test stack checking.

Ok.  I'll have to look how to implement this in general to handle
e.g. limits-exprparen.c which fails with default stack limits on many
platforms.

>> As you will see, the implementation is full of FIXME comments, debug
>> logging, lacks error checking and some cleanup, and I've not yet
>> verified that the set of tests run is identical to the current one.
>> I'll also have to tune the parallelization to make sure that the various
>> parts take roughly the same time.
>
> Please avoid hard-coding -O2 in the tests, put only -gnat95, -gnato, etc.

The problem is that dg-options replaces the default options, so while
all other tests are built with -O2, those with special option would not
be.

>> Anyway, here we go; comments welcome.
>
> Maybe we should investigate switching to ACATS 3.0 in the process:
>   http://www.ada-auth.org/acats.html

Laurent already expressed interest in this.  I've no idea how much
changes to the framework would be required.

Thanks.
	Rainer
Eric Botcazou Jan. 31, 2011, 5:31 p.m. UTC | #3
> The problem is that dg-options replaces the default options, so while
> all other tests are built with -O2, those with special option would not
> be.

How much work would it take to uncouple -gnat95/-gnato/-gnatE/-fstack-check 
from dg-options, e.g. to have specific dg markers for them?

> Laurent already expressed interest in this.  I've no idea how much
> changes to the framework would be required.

I don't think this would be an earthquake, but I haven't really looked at it.
Rainer Orth Jan. 31, 2011, 5:38 p.m. UTC | #4
Eric Botcazou <ebotcazou@adacore.com> writes:

>> The problem is that dg-options replaces the default options, so while
>> all other tests are built with -O2, those with special option would not
>> be.
>
> How much work would it take to uncouple -gnat95/-gnato/-gnatE/-fstack-check 
> from dg-options, e.g. to have specific dg markers for them?

Doable of course (and mostly mechanical), but probably overkill since
this is a general issue.  I'd rather introduce a dg-options variant
(dg-add-options is taken for something different, unfortunately), that
adds to instead of replaces the default options.  On the other hand,
dg-add-options with corresponding keywords could do the trick, too.

	Rainer
Iain Sandoe Jan. 31, 2011, 6:02 p.m. UTC | #5
On 31 Jan 2011, at 17:38, Rainer Orth wrote:

> Eric Botcazou <ebotcazou@adacore.com> writes:
>
>>> The problem is that dg-options replaces the default options, so  
>>> while
>>> all other tests are built with -O2, those with special option  
>>> would not
>>> be.
>>
>> How much work would it take to uncouple -gnat95/-gnato/-gnatE/- 
>> fstack-check
>> from dg-options, e.g. to have specific dg markers for them?
>
> Doable of course (and mostly mechanical), but probably overkill since
> this is a general issue.  I'd rather introduce a dg-options variant
> (dg-add-options is taken for something different, unfortunately), that
> adds to instead of replaces the default options.  On the other hand,
> dg-add-options with corresponding keywords could do the trick, too.

IMO, something to append to options options rather than replace would  
be generally useful outside of this application.
[ maybe append-options would be a suitable distinguisher from add- 
options?]

  (I would find useful in the ObjC* test-suite, for certain).
Iain
Mike Stump Jan. 31, 2011, 7:50 p.m. UTC | #6
On Jan 31, 2011, at 9:20 AM, Rainer Orth wrote:
>>> # Limit the stack to 16MB for stack checking
>>> ulimit -s 16384
>> 
>> Yes, it is required to properly test stack checking.
> 
> Ok.  I'll have to look how to implement this in general to handle
> e.g. limits-exprparen.c which fails with default stack limits on many
> platforms.

Fails on RedHat 6.0 for me...  :-(  In user mode, it doesn't seem I can increase the stack.  Having to root, then up the limit then switch back to user mode, and then run the testsuite, is annoying.  I'd rather we trim the limit down to the minimum of most common environments.
Rainer Orth Feb. 1, 2011, 11:29 a.m. UTC | #7
Mike Stump <mikestump@comcast.net> writes:

>> Ok.  I'll have to look how to implement this in general to handle
>> e.g. limits-exprparen.c which fails with default stack limits on many
>> platforms.
>
> Fails on RedHat 6.0 for me...  :-(  In user mode, it doesn't seem I can increase the stack.  Having to root, then up the limit then switch back to user mode, and then run the testsuite, is annoying.  I'd rather we trim the limit down to the minimum of most common environments.

Fully agreed: we have a number of testcases with excessive resource
requirements right now, either due to time consumption (both compile and
run), or due to other issues (memory, stack size, ...).  One of the
latest is gcc.c-torture/compile/pr46534.c which alone takes 9:16 min on
a 1.6 GHz Core i7 (i386-pc-solaris2.11, both multilibs).

I'll probably instrument dg.exp to look out for tests taking more than
60 seconds.

Unfortunately, there's no guidance about what is considered appropriate
and what out of bounds.  Perhaps Mark can chime in so we have a general
guideline and don't have to decide on a case-by-cases basis?  We already
have dg-require-effective-target run_expensive_tests, perhaps we should
use it more liberally or reduce test sizes.

	Rainer
Richard Biener Feb. 1, 2011, 12:10 p.m. UTC | #8
On Tue, Feb 1, 2011 at 12:29 PM, Rainer Orth
<ro@cebitec.uni-bielefeld.de> wrote:
> Mike Stump <mikestump@comcast.net> writes:
>
>>> Ok.  I'll have to look how to implement this in general to handle
>>> e.g. limits-exprparen.c which fails with default stack limits on many
>>> platforms.
>>
>> Fails on RedHat 6.0 for me...  :-(  In user mode, it doesn't seem I can increase the stack.  Having to root, then up the limit then switch back to user mode, and then run the testsuite, is annoying.  I'd rather we trim the limit down to the minimum of most common environments.
>
> Fully agreed: we have a number of testcases with excessive resource
> requirements right now, either due to time consumption (both compile and
> run), or due to other issues (memory, stack size, ...).  One of the
> latest is gcc.c-torture/compile/pr46534.c which alone takes 9:16 min on
> a 1.6 GHz Core i7 (i386-pc-solaris2.11, both multilibs).

Huh?  I can't see why that testcase should take that long to compile.
With an unoptimized cc1 the full torture for that testcase takes less
than 20 seconds for me (2Ghz Athlon-XP).

Richard.
Rainer Orth Feb. 1, 2011, 12:15 p.m. UTC | #9
Richard Guenther <richard.guenther@gmail.com> writes:

>> Fully agreed: we have a number of testcases with excessive resource
>> requirements right now, either due to time consumption (both compile and
>> run), or due to other issues (memory, stack size, ...).  One of the
>> latest is gcc.c-torture/compile/pr46534.c which alone takes 9:16 min on
>> a 1.6 GHz Core i7 (i386-pc-solaris2.11, both multilibs).
>
> Huh?  I can't see why that testcase should take that long to compile.
> With an unoptimized cc1 the full torture for that testcase takes less
> than 20 seconds for me (2Ghz Athlon-XP).

A single 32-bit compile on

    x86 (GenuineIntel 106E5 family 6 model 30 step 5 clock 1600 MHz)
      Intel(r) Core(tm) i7 CPU       Q 720  @ 1.60GHz

is

real          33.91
user          32.69
sys            0.88

Same on

  x86 (chipid 0x6 GenuineIntel family 6 model 15 step 11 clock 2933 MHz)
        Intel(r) Xeon(r) CPU           X7350  @ 2.93GHz

	Rainer
Richard Biener Feb. 1, 2011, 12:24 p.m. UTC | #10
On Tue, Feb 1, 2011 at 1:15 PM, Rainer Orth <ro@cebitec.uni-bielefeld.de> wrote:
> Richard Guenther <richard.guenther@gmail.com> writes:
>
>>> Fully agreed: we have a number of testcases with excessive resource
>>> requirements right now, either due to time consumption (both compile and
>>> run), or due to other issues (memory, stack size, ...).  One of the
>>> latest is gcc.c-torture/compile/pr46534.c which alone takes 9:16 min on
>>> a 1.6 GHz Core i7 (i386-pc-solaris2.11, both multilibs).
>>
>> Huh?  I can't see why that testcase should take that long to compile.
>> With an unoptimized cc1 the full torture for that testcase takes less
>> than 20 seconds for me (2Ghz Athlon-XP).
>
> A single 32-bit compile on
>
>    x86 (GenuineIntel 106E5 family 6 model 30 step 5 clock 1600 MHz)
>      Intel(r) Core(tm) i7 CPU       Q 720  @ 1.60GHz
>
> is
>
> real          33.91
> user          32.69
> sys            0.88
>
> Same on
>
>  x86 (chipid 0x6 GenuineIntel family 6 model 15 step 11 clock 2933 MHz)
>        Intel(r) Xeon(r) CPU           X7350  @ 2.93GHz

gcc> /usr/bin/time ./cc1 -quiet -O3 -o /dev/null
/space/rguenther/src/svn/trunk/gcc/testsuite/gcc.c-torture/compile/pr46534.c
1.69user 0.34system 0:08.48elapsed 23%CPU (0avgtext+0avgdata 0maxresident)k
46960inputs+0outputs (47major+66673minor)pagefaults 0swaps

checking-enabled cc1, built with -O0 -g.  Something is wrong on
your system(s).

Richard.
Rainer Orth Feb. 1, 2011, 12:43 p.m. UTC | #11
Richard Guenther <richard.guenther@gmail.com> writes:

> gcc> /usr/bin/time ./cc1 -quiet -O3 -o /dev/null
> /space/rguenther/src/svn/trunk/gcc/testsuite/gcc.c-torture/compile/pr46534.c
> 1.69user 0.34system 0:08.48elapsed 23%CPU (0avgtext+0avgdata 0maxresident)k
> 46960inputs+0outputs (47major+66673minor)pagefaults 0swaps
>
> checking-enabled cc1, built with -O0 -g.  Something is wrong on
> your system(s).

> ptime -m ./cc1 /vol/gcc/src/hg/trunk/solaris/gcc/testsuite/gcc.c-torture/compile/pr46534.c -quiet -O3 -o /dev/null

real       23.555286049
user       23.476887335
sys         0.077469644
trap        0.000437780
tflt        0.000000000
dflt        0.000000000
kflt        0.000000000
lock        0.000000000
slp         0.000000000
lat         0.000210792
stop        0.000222844

Regular mainline bootstrap with --enable-checking=release.

This is a 32-bit cc1, built with -mtune=generic -march=pentium4 (the
default):

Without -quiet, I find

Execution times (seconds)
 preprocessing         :   0.26 ( 1%) usr   0.05 (71%) sys   0.30 ( 1%) wall   32770 kB (33%) ggc
 parser                :   0.00 ( 0%) usr   0.00 ( 0%) sys   0.01 ( 0%) wall     139 kB ( 0%) ggc
 tree gimplify         :   0.02 ( 0%) usr   0.01 (14%) sys   0.04 ( 0%) wall   32768 kB (33%) ggc
 expand                :  23.16 (99%) usr   0.01 (14%) sys  23.17 (99%) wall   32769 kB (33%) ggc
 TOTAL                 :  23.44             0.07            23.52              98939 kB

	Rainer
Richard Biener Feb. 1, 2011, 1:03 p.m. UTC | #12
On Tue, Feb 1, 2011 at 1:43 PM, Rainer Orth <ro@cebitec.uni-bielefeld.de> wrote:
> Richard Guenther <richard.guenther@gmail.com> writes:
>
>> gcc> /usr/bin/time ./cc1 -quiet -O3 -o /dev/null
>> /space/rguenther/src/svn/trunk/gcc/testsuite/gcc.c-torture/compile/pr46534.c
>> 1.69user 0.34system 0:08.48elapsed 23%CPU (0avgtext+0avgdata 0maxresident)k
>> 46960inputs+0outputs (47major+66673minor)pagefaults 0swaps
>>
>> checking-enabled cc1, built with -O0 -g.  Something is wrong on
>> your system(s).
>
>> ptime -m ./cc1 /vol/gcc/src/hg/trunk/solaris/gcc/testsuite/gcc.c-torture/compile/pr46534.c -quiet -O3 -o /dev/null
>
> real       23.555286049
> user       23.476887335
> sys         0.077469644
> trap        0.000437780
> tflt        0.000000000
> dflt        0.000000000
> kflt        0.000000000
> lock        0.000000000
> slp         0.000000000
> lat         0.000210792
> stop        0.000222844
>
> Regular mainline bootstrap with --enable-checking=release.
>
> This is a 32-bit cc1, built with -mtune=generic -march=pentium4 (the
> default):
>
> Without -quiet, I find
>
> Execution times (seconds)
>  preprocessing         :   0.26 ( 1%) usr   0.05 (71%) sys   0.30 ( 1%) wall   32770 kB (33%) ggc
>  parser                :   0.00 ( 0%) usr   0.00 ( 0%) sys   0.01 ( 0%) wall     139 kB ( 0%) ggc
>  tree gimplify         :   0.02 ( 0%) usr   0.01 (14%) sys   0.04 ( 0%) wall   32768 kB (33%) ggc
>  expand                :  23.16 (99%) usr   0.01 (14%) sys  23.17 (99%) wall   32769 kB (33%) ggc
>  TOTAL                 :  23.44             0.07            23.52              98939 kB

I can't reproduce it so please debug where all the time is spent for you.

Richard.

>        Rainer
>
> --
> -----------------------------------------------------------------------------
> Rainer Orth, Center for Biotechnology, Bielefeld University
>
Rainer Orth Feb. 1, 2011, 4:22 p.m. UTC | #13
Richard Guenther <richard.guenther@gmail.com> writes:

> I can't reproduce it so please debug where all the time is spent for you.

The collect and analyzer tools from the Studio compilers proved helpful
since they allowed to investigate this without rebuilding cc1 with
profiling enabled.  What I found is shocking: 97% of the time is spent
in varasm.c (assemble_string), no doubt due to the version of
ASM_OUTPUT_ASCII in i386/sysv4.h. ;-(

	Rainer
Richard Biener Feb. 1, 2011, 4:47 p.m. UTC | #14
On Tue, Feb 1, 2011 at 5:22 PM, Rainer Orth <ro@cebitec.uni-bielefeld.de> wrote:
> Richard Guenther <richard.guenther@gmail.com> writes:
>
>> I can't reproduce it so please debug where all the time is spent for you.
>
> The collect and analyzer tools from the Studio compilers proved helpful
> since they allowed to investigate this without rebuilding cc1 with
> profiling enabled.  What I found is shocking: 97% of the time is spent
> in varasm.c (assemble_string), no doubt due to the version of
> ASM_OUTPUT_ASCII in i386/sysv4.h. ;-(

Maybe you don't have fputc_unlocked?

Richard.
Michael Matz Feb. 1, 2011, 4:49 p.m. UTC | #15
Hi,

On Tue, 1 Feb 2011, Rainer Orth wrote:

> Richard Guenther <richard.guenther@gmail.com> writes:
> 
> > I can't reproduce it so please debug where all the time is spent for you.
> 
> The collect and analyzer tools from the Studio compilers proved helpful
> since they allowed to investigate this without rebuilding cc1 with
> profiling enabled.  What I found is shocking: 97% of the time is spent
> in varasm.c (assemble_string), no doubt due to the version of
> ASM_OUTPUT_ASCII in i386/sysv4.h. ;-(

If Solaris as works with the version in elfos.h (using .string and 
.ascii) you can just remove it from i386/sysv4.h.


Ciao,
Michael.
Rainer Orth Feb. 1, 2011, 4:52 p.m. UTC | #16
Richard Guenther <richard.guenther@gmail.com> writes:

>> The collect and analyzer tools from the Studio compilers proved helpful
>> since they allowed to investigate this without rebuilding cc1 with
>> profiling enabled.  What I found is shocking: 97% of the time is spent
>> in varasm.c (assemble_string), no doubt due to the version of
>> ASM_OUTPUT_ASCII in i386/sysv4.h. ;-(
>
> Maybe you don't have fputc_unlocked?

True, but the time is spent in assemble_string itself, not a callee.  In
fact, the vast majority of the time is spent in two/three insns, as can
be seen in the following annotated disassembly, marked with ##:

                                <Function: assemble_string>
   0.         0.                [1725]  861b2a0:  pushl   %ebp
   0.         0.                [1725]  861b2a1:  movl    %esp,%ebp
   0.         0.                [1725]  861b2a3:  pushl   %edi
   0.         0.                [1725]  861b2a4:  pushl   %esi
   0.         0.                [1725]  861b2a5:  pushl   %ebx
   0.         0.                [1725]  861b2a6:  subl    $0x2c,%esp
   0.         0.                [1731]  861b2a9:  movl    0xc(%ebp),%eax
   0.         0.                [1725]  861b2ac:  movl    8(%ebp),%ebx
   0.         0.                [1731]  861b2af:  testl   %eax,%eax
   0.         0.                [1731]  861b2b1:  jle     .+0x2b6 [ 0x861b567 ]
   0.         0.                [1731]  861b2b7:  movl    $0,-0x20(%ebp)
   0.         0.                [1731]  861b2be:  nop     
   0.         0.                [1731]  861b2bf:  nop     
   0.         0.                [1733]  861b2c0:  movl    0xc(%ebp),%eax
   0.         0.                [1733]  861b2c3:  movl    $0x7d0,%edx
   0.         0.                [1733]  861b2c8:  subl    -0x20(%ebp),%eax
   0.         0.                [1733]  861b2cb:  cmpl    $0x7d0,%eax
   0.         0.                [1733]  861b2d0:  cmovl.le  %eax,%edx
   0.         0.                [1737]  861b2d3:  xorl    %esi,%esi
   0.         0.                [1733]  861b2d5:  movl    %edx,-0x24(%ebp)
   0.         0.                [1737]  861b2d8:  addl    %ebx,%edx
   0.         0.                [1737]  861b2da:  cmpl    %ebx,%edx
   0.         0.                [1737]  861b2dc:  movl    %edx,-0x1c(%ebp)
   0.         0.                [1737]  861b2df:  jbe     .+0x12a [ 0x861b409 ]
   0.         0.                [1737]  861b2e5:  nop     
   0.         0.                [1737]  861b2e6:  nop     
   0.         0.                [1737]  861b2e7:  nop     
   0.         0.                [1737]  861b2e8:  cmpl    %ebx,-0x1c(%ebp)
   0.         0.                [1737]  861b2eb:  jbe     .+0x17c [ 0x861b467 ]
   0.010      0.010             [1737]  861b2f1:  cmpb    $0,(%ebx)
   0.         0.                [1737]  861b2f4:  movl    %ebx,%edi
   0.010      0.010             [1737]  861b2f6:  jne     .+0x152 [ 0x861b448 ]
   0.         0.                [1737]  861b2fc:  testl   %esi,%esi
   0.         0.                [1737]  861b2fe:  jne     .+0x272 [ 0x861b570 ]
   0.         0.                [1737]  861b304:  movl    0x8cede50,%eax
   0.         0.                [1737]  861b309:  movl    %ebx,%esi
   0.         0.                [1737]  861b30b:  movl    $0x8a89e1c,8(%esp)
   0.         0.                [1737]  861b313:  movl    $0x8a89e26,4(%esp)
   0.         0.                [1737]  861b31b:  movl    %eax,(%esp)
   0.         0.                [1737]  861b31e:  call    fprintf [ 0x80b7d58, .-0x5635c6 ]
   0.         0.                [1737]  861b323:  movzbl  (%ebx),%edx
   0.         0.                [1737]  861b326:  movzbl  %dl,%eax
   0.         0.                [1737]  861b329:  testl   %eax,%eax
   0.         0.                [1737]  861b32b:  jne     .+0x3d [ 0x861b368 ]
   0.         0.                [1737]  861b32d:  jmp     .+0x9f [ 0x861b3cc ]
   0.         0.                [1737]  861b332:  nop     
   0.         0.                [1737]  861b333:  nop     
   0.         0.                [1737]  861b334:  nop     
   0.         0.                [1737]  861b335:  nop     
   0.         0.                [1737]  861b336:  nop     
   0.         0.                [1737]  861b337:  nop     
   0.         0.                [1737]  861b338:  movl    0x8cede50,%ecx
   0.         0.                [1737]  861b33e:  movl    (%ecx),%ebx
   0.         0.                [1737]  861b340:  subl    $1,%ebx
   0.         0.                [1737]  861b343:  testl   %ebx,%ebx
   0.         0.                [1737]  861b345:  movl    %ebx,(%ecx)
   0.         0.                [1737]  861b347:  js      .+0x1b1 [ 0x861b4f8 ]
   0.         0.                [1737]  861b34d:  movl    4(%ecx),%eax
   0.         0.                [1737]  861b350:  movb    %dl,(%eax)
   0.         0.                [1737]  861b352:  addl    $1,%eax
   0.         0.                [1737]  861b355:  movl    %eax,4(%ecx)
   0.         0.                [1737]  861b358:  movzbl  1(%esi),%edx
   0.         0.                [1737]  861b35c:  leal    1(%esi),%ecx
   0.         0.                [1737]  861b35f:  movzbl  %dl,%eax
   0.         0.                [1737]  861b362:  testl   %eax,%eax
   0.         0.                [1737]  861b364:  je      .+0x68 [ 0x861b3cc ]
   0.         0.                [1737]  861b366:  movl    %ecx,%esi
   0.         0.                [1737]  861b368:  movzbl  0x8a89e44(%eax),%ebx
   0.         0.                [1737]  861b36f:  testb   %bl,%bl
   0.         0.                [1737]  861b371:  je      .-0x39 [ 0x861b338 ]
   0.         0.                [1737]  861b373:  cmpb    $1,%bl
   0.         0.                [1737]  861b376:  je      .+0xb2 [ 0x861b428 ]
   0.         0.                [1737]  861b37c:  movl    0x8cede50,%eax
   0.         0.                [1737]  861b381:  movl    (%eax),%edx
   0.         0.                [1737]  861b383:  subl    $1,%edx
   0.         0.                [1737]  861b386:  testl   %edx,%edx
   0.         0.                [1737]  861b388:  movl    %edx,(%eax)
   0.         0.                [1737]  861b38a:  js      .+0x19e [ 0x861b528 ]
   0.         0.                [1737]  861b390:  movl    4(%eax),%edx
   0.         0.                [1737]  861b393:  movb    $0x5c,(%edx)
   0.         0.                [1737]  861b396:  addl    $1,%edx
   0.         0.                [1737]  861b399:  movl    %edx,4(%eax)
   0.         0.                [1737]  861b39c:  movl    0x8cede50,%eax
   0.         0.                [1737]  861b3a1:  movsbl  %bl,%ecx
   0.         0.                [1737]  861b3a4:  movl    (%eax),%edx
   0.         0.                [1737]  861b3a6:  subl    $1,%edx
   0.         0.                [1737]  861b3a9:  testl   %edx,%edx
   0.         0.                [1737]  861b3ab:  movl    %edx,(%eax)
   0.         0.                [1737]  861b3ad:  js      .+0x163 [ 0x861b510 ]
   0.         0.                [1737]  861b3b3:  movl    4(%eax),%edx
   0.         0.                [1737]  861b3b6:  leal    1(%esi),%ecx
   0.         0.                [1737]  861b3b9:  movb    %bl,(%edx)
   0.         0.                [1737]  861b3bb:  addl    $1,%edx
   0.         0.                [1737]  861b3be:  movl    %edx,4(%eax)
   0.         0.                [1737]  861b3c1:  movzbl  1(%esi),%edx
   0.         0.                [1737]  861b3c5:  movzbl  %dl,%eax
   0.         0.                [1737]  861b3c8:  testl   %eax,%eax
   0.         0.                [1737]  861b3ca:  jne     .-0x64 [ 0x861b366 ]
   0.         0.                [1737]  861b3cc:  movl    0x8cede50,%eax
   0.         0.                [1737]  861b3d1:  movl    %edi,%ebx
   0.         0.                [1737]  861b3d3:  xorl    %esi,%esi
   0.         0.                [1737]  861b3d5:  movl    $2,8(%esp)
   0.         0.                [1737]  861b3dd:  addl    $1,%ebx
   0.         0.                [1737]  861b3e0:  movl    $1,4(%esp)
   0.         0.                [1737]  861b3e8:  movl    $0x8a89e30,(%esp)
   0.         0.                [1737]  861b3ef:  movl    %eax,0xc(%esp)
   0.         0.                [1737]  861b3f3:  call    fwrite [ 0x80b7da8, .-0x56364b ]
   0.         0.                [1737]  861b3f8:  cmpl    %ebx,-0x1c(%ebp)
   0.         0.                [1737]  861b3fb:  ja      .+0xc0 [ 0x861b4bb ]
   0.         0.                [1737]  861b401:  testl   %esi,%esi
   0.         0.                [1737]  861b403:  jne     .+0x13d [ 0x861b540 ]
   0.         0.                [1739]  861b409:  movl    -0x24(%ebp),%ebx
   0.         0.                [1739]  861b40c:  addl    %ebx,-0x20(%ebp)
   0.         0.                [1731]  861b40f:  movl    -0x20(%ebp),%edx
   0.         0.                [1731]  861b412:  cmpl    %edx,0xc(%ebp)
   0.         0.                [1731]  861b415:  jle     .+0x152 [ 0x861b567 ]
   0.         0.                [1737]  861b41b:  movl    -0x1c(%ebp),%ebx
   0.         0.                [1737]  861b41e:  jmp     .-0x15e [ 0x861b2c0 ]
   0.         0.                [1737]  861b423:  nop     
   0.         0.                [1737]  861b424:  nop     
   0.         0.                [1737]  861b425:  nop     
   0.         0.                [1737]  861b426:  nop     
   0.         0.                [1737]  861b427:  nop     
   0.         0.                [1737]  861b428:  movl    %eax,8(%esp)
   0.         0.                [1737]  861b42c:  movl    0x8cede50,%eax
   0.         0.                [1737]  861b431:  movl    $0x8a89e2a,4(%esp)
   0.         0.                [1737]  861b439:  movl    %eax,(%esp)
   0.         0.                [1737]  861b43c:  call    fprintf [ 0x80b7d58, .-0x5636e4 ]
   0.         0.                [1737]  861b441:  jmp     .-0xe9 [ 0x861b358 ]
   0.         0.                [1737]  861b446:  nop     
   0.         0.                [1737]  861b447:  nop     
   0.010      0.010             [1737]  861b448:  movl    %ebx,%eax
## 6.925      6.925             [1737]  861b44a:  leal    1(%eax),%edi
   0.         0.                [1737]  861b44d:  cmpl    -0x1c(%ebp),%edi
   0.         0.                [1737]  861b450:  je      .+0x17 [ 0x861b467 ]
   2.342      2.342             [1737]  861b452:  cmpb    $0,1(%eax)
## 6.384      6.384             [1737]  861b456:  movl    %edi,%eax
   1.001      1.001             [1737]  861b458:  jne     .-0xe [ 0x861b44a ]
   0.         0.                [1737]  861b45a:  subl    %ebx,%eax
   0.         0.                [1737]  861b45c:  cmpl    $0x100,%eax
   0.         0.                [1737]  861b461:  jle     .-0x165 [ 0x861b2fc ]
   0.010      0.010             [1737]  861b467:  testl   %esi,%esi
   0.080      0.080             [1737]  861b469:  movl    0x8cede50,%eax
   0.010      0.010             [1737]  861b46e:  jne     .+0x72 [ 0x861b4e0 ]
   0.         0.                [1737]  861b470:  movl    %eax,0xc(%esp)
   0.         0.                [1737]  861b474:  movl    $7,8(%esp)
   0.         0.                [1737]  861b47c:  movl    $1,4(%esp)
   0.         0.                [1737]  861b484:  movl    $0x8a89e33,(%esp)
   0.010      0.070             [1737]  861b48b:  call    fwrite [ 0x80b7da8, .-0x5636e3 ]
   0.         0.                [1737]  861b490:  movzbl  (%ebx),%eax
   0.         0.                [1737]  861b493:  addl    $5,%esi
   0.         0.                [1737]  861b496:  addl    $1,%ebx
   0.         0.                [1737]  861b499:  movl    $0x8a89e3b,4(%esp)
   0.010      0.010             [1737]  861b4a1:  movl    %eax,8(%esp)
   0.         0.                [1737]  861b4a5:  movl    0x8cede50,%eax
   0.010      0.010             [1737]  861b4aa:  movl    %eax,(%esp)
   0.010      1.481             [1737]  861b4ad:  call    fprintf [ 0x80b7d58, .-0x563755 ]
   0.010      0.010             [1737]  861b4b2:  cmpl    %ebx,-0x1c(%ebp)
   0.         0.                [1737]  861b4b5:  jbe     .-0xb4 [ 0x861b401 ]
   0.         0.                [1737]  861b4bb:  cmpl    $0x3f,%esi
   0.         0.                [1737]  861b4be:  jbe     .-0x1d6 [ 0x861b2e8 ]
   0.         0.                [1737]  861b4c4:  movl    0x8cede50,%eax
   0.         0.                [1737]  861b4c9:  xorl    %esi,%esi
   0.         0.                [1737]  861b4cb:  movl    $0xa,(%esp)
   0.010      0.010             [1737]  861b4d2:  movl    %eax,4(%esp)
   0.         0.020             [1737]  861b4d6:  call    fputc [ 0x80b7d98, .-0x56373e ]
   0.         0.                [1737]  861b4db:  jmp     .-0x1f3 [ 0x861b2e8 ]
   0.         0.                [1737]  861b4e0:  movl    %eax,4(%esp)
   0.010      0.010             [1737]  861b4e4:  movl    $0x2c,(%esp)
   0.050      0.270             [1737]  861b4eb:  call    fputc [ 0x80b7d98, .-0x563753 ]
   0.010      0.010             [1737]  861b4f0:  jmp     .-0x60 [ 0x861b490 ]
   0.         0.                [1737]  861b4f2:  nop     
   0.         0.                [1737]  861b4f3:  nop     
   0.         0.                [1737]  861b4f4:  nop     
   0.         0.                [1737]  861b4f5:  nop     
   0.         0.                [1737]  861b4f6:  nop     
   0.         0.                [1737]  861b4f7:  nop     
   0.         0.                [1737]  861b4f8:  movl    %ecx,4(%esp)
   0.         0.                [1737]  861b4fc:  movl    %eax,(%esp)
   0.         0.                [1737]  861b4ff:  call    __flsbuf [ 0x80b7e98, .-0x563667 ]
   0.         0.                [1737]  861b504:  jmp     .-0x1ac [ 0x861b358 ]
   0.         0.                [1737]  861b509:  nop     
   0.         0.                [1737]  861b50a:  nop     
   0.         0.                [1737]  861b50b:  nop     
   0.         0.                [1737]  861b50c:  nop     
   0.         0.                [1737]  861b50d:  nop     
   0.         0.                [1737]  861b50e:  nop     
   0.         0.                [1737]  861b50f:  nop     
   0.         0.                [1737]  861b510:  movl    %eax,4(%esp)
   0.         0.                [1737]  861b514:  movl    %ecx,(%esp)
   0.         0.                [1737]  861b517:  call    __flsbuf [ 0x80b7e98, .-0x56367f ]
   0.         0.                [1737]  861b51c:  jmp     .-0x1c4 [ 0x861b358 ]
   0.         0.                [1737]  861b521:  nop     
   0.         0.                [1737]  861b522:  nop     
   0.         0.                [1737]  861b523:  nop     
   0.         0.                [1737]  861b524:  nop     
   0.         0.                [1737]  861b525:  nop     
   0.         0.                [1737]  861b526:  nop     
   0.         0.                [1737]  861b527:  nop     
   0.         0.                [1737]  861b528:  movl    %eax,4(%esp)
   0.         0.                [1737]  861b52c:  movl    $0x5c,(%esp)
   0.         0.                [1737]  861b533:  call    __flsbuf [ 0x80b7e98, .-0x56369b ]
   0.         0.                [1737]  861b538:  jmp     .-0x19c [ 0x861b39c ]
   0.         0.                [1737]  861b53d:  nop     
   0.         0.                [1737]  861b53e:  nop     
   0.         0.                [1737]  861b53f:  nop     
   0.         0.                [1737]  861b540:  movl    0x8cede50,%eax
   0.         0.                [1737]  861b545:  movl    $0xa,(%esp)
   0.         0.                [1737]  861b54c:  movl    %eax,4(%esp)
   0.         0.                [1737]  861b550:  call    fputc [ 0x80b7d98, .-0x5637b8 ]
   0.         0.                [1739]  861b555:  movl    -0x24(%ebp),%ebx
   0.         0.                [1739]  861b558:  addl    %ebx,-0x20(%ebp)
   0.         0.                [1731]  861b55b:  movl    -0x20(%ebp),%edx
   0.         0.                [1731]  861b55e:  cmpl    %edx,0xc(%ebp)
   0.         0.                [1731]  861b561:  jg      .-0x146 [ 0x861b41b ]
   0.         0.                [1742]  861b567:  addl    $0x2c,%esp
   0.         0.                [1742]  861b56a:  popl    %ebx
   0.         0.                [1742]  861b56b:  popl    %esi
   0.         0.                [1742]  861b56c:  popl    %edi
   0.         0.                [1742]  861b56d:  popl    %ebp
   0.         0.                [1742]  861b56e:  ret     
   0.         0.                [1742]  861b56f:  nop     
   0.         0.                [1737]  861b570:  movl    0x8cede50,%eax
   0.         0.                [1737]  861b575:  movl    $0xa,(%esp)
   0.         0.                [1737]  861b57c:  movl    %eax,4(%esp)
   0.         0.                [1737]  861b580:  call    fputc [ 0x80b7d98, .-0x5637e8 ]
   0.         0.                [1737]  861b585:  jmp     .-0x281 [ 0x861b304 ]


	Rainer
Rainer Orth Feb. 1, 2011, 5:08 p.m. UTC | #17
Michael Matz <matz@suse.de> writes:

> If Solaris as works with the version in elfos.h (using .string and 
> .ascii) you can just remove it from i386/sysv4.h.

I'll give that a try, all the way back to Solaris 8.  Since
i386/sysv4.h is only used on Solaris 2/x86, I don't even need approval
for such a change.

Thanks.
	Rainer
Joseph Myers Feb. 1, 2011, 5:24 p.m. UTC | #18
On Tue, 1 Feb 2011, Rainer Orth wrote:

> Michael Matz <matz@suse.de> writes:
> 
> > If Solaris as works with the version in elfos.h (using .string and 
> > .ascii) you can just remove it from i386/sysv4.h.
> 
> I'll give that a try, all the way back to Solaris 8.  Since
> i386/sysv4.h is only used on Solaris 2/x86, I don't even need approval
> for such a change.

Whether using the elfos.h version works or not, it's clearly silly for 
this code to be using a quadratic algorithm as the i386/sysv4.h is doing 
at present (recomputing the location of the next 0 byte for every byte in 
the string - elfos.h saves last_null to avoid that).

For the general issue: a slow test appears to have served its purpose by 
showing up a (target-specific) bug in the compiler.  And in general you 
need to consider whether a resource-hungry test is actually showing up a 
bug and should not be so resource-hungry, before reducing the test size or 
only running it conditionally.  (You might still reduce it after finding 
it shows a bug - but only after filing that bug in Bugzilla; not simply 
blindly presume that the test is too big for the testsuite.)
Dave Korn Feb. 1, 2011, 6:51 p.m. UTC | #19
On 01/02/2011 17:24, Joseph S. Myers wrote:

> For the general issue: a slow test appears to have served its purpose by 
> showing up a (target-specific) bug in the compiler.  And in general you 
> need to consider whether a resource-hungry test is actually showing up a 
> bug and should not be so resource-hungry, before reducing the test size or 
> only running it conditionally.  (You might still reduce it after finding 
> it shows a bug - but only after filing that bug in Bugzilla; not simply 
> blindly presume that the test is too big for the testsuite.)
> 

  How many layers of nested parentheses /should/ we be able to support, in how
much memory?  limits-exprparen.c keeps growing...

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31827

    cheers,
      DaveK
Mark Mitchell Feb. 1, 2011, 7:17 p.m. UTC | #20
On 2/1/2011 6:24 PM, Joseph S. Myers wrote:

> For the general issue: a slow test appears to have served its purpose by 
> showing up a (target-specific) bug in the compiler. 

Indeed.  However, that doesn't justify having lots of slow tests.  What
it does justify is investigating the reasons behind a slow test before
turning it off and/or simplifying it.

Here is what I suggest as a policy.

If a test takes longer than 30 seconds to execute (including both
compilation and execution of the generated program) on ordinary
workstation hardware, in a native configuration, then the test should be
investigated.  If the problem is generic (i.e., not specific to a
particular host or target) and nobody is actively developing a patch to
solve the problem, then the test should be flagged as "expensive" and
only when run when the user explicitly requests "expensive" testing.  If
the slow execution is considered unreasonable then a PR should be filed,
just as for any other bug.

I realize that "ordinary workstation hardware" is not a well-defined
term.  But, there's no need to specify this policy with a high degree of
rigor; when there is a question, we can use our usual processes for
reaching consensus, and err on the side of leaving the test as
"inexpensive".

This policy would help to eliminate the small handful of tests that take
completely disproportionate amounts of time to execute.
Joseph Myers Feb. 1, 2011, 8:41 p.m. UTC | #21
On Tue, 1 Feb 2011, Dave Korn wrote:

> On 01/02/2011 17:24, Joseph S. Myers wrote:
> 
> > For the general issue: a slow test appears to have served its purpose by 
> > showing up a (target-specific) bug in the compiler.  And in general you 
> > need to consider whether a resource-hungry test is actually showing up a 
> > bug and should not be so resource-hungry, before reducing the test size or 
> > only running it conditionally.  (You might still reduce it after finding 
> > it shows a bug - but only after filing that bug in Bugzilla; not simply 
> > blindly presume that the test is too big for the testsuite.)
> > 
> 
>   How many layers of nested parentheses /should/ we be able to support, in how
> much memory?  limits-exprparen.c keeps growing...
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31827

I'd say we should support as many as allowed by available memory.  (More 
than 4GB of them even, on a 64-bit system with enough memory.)  Hence the 
suggestion of -fsplit-stack: some code seems natural enough for humans to 
write in a recursive way, and then you want the compiler/linker to be 
smart about stopping this from causing problems with deep recursion.  (If 
-fsplit-stack isn't the right approach, maybe some other C/C++ extension 
to tell the compiler to turn a particular set of mutually recursive 
functions into a non-recursive function using some specified allocator 
would be appropriate - for this and any other case where deep recursion is 
possible in GCC.)  This does not mean we should put a test with 4GB of 
nested parentheses in the testsuite (except in a set of tests that are 
only run if you declare you want to run huge tests and have a huge amount 
of memory)!

The principle of being limited only by available memory applies more 
generally and is in accord with standard GNU principles; for example, 
TREE_STRING_LENGTH should not be an int because that imposes a 2GB-1 limit 
on string constants which should not be needed if both host and target are 
64-bit.  Though in some cases eliminating limits might make the common 
cases take more time and memory (and so would need to be conditioned on 
configure options), and eliminating such limits is certainly one of the 
harder cleanups in GCC (difficulty in avoiding potential integer overflows 
is intrinsic to programming in C or C++, it's not anything specific to the 
GCC code base), as well as being one with less obvious utility in 
practice.
Mike Stump Feb. 1, 2011, 9:18 p.m. UTC | #22
On Feb 1, 2011, at 3:29 AM, Rainer Orth wrote:
> Fully agreed: we have a number of testcases with excessive resource
> requirements right now, either due to time consumption (both compile and
> run), or due to other issues (memory, stack size, ...).  One of the
> latest is gcc.c-torture/compile/pr46534.c which alone takes 9:16 min on
> a 1.6 GHz Core i7 (i386-pc-solaris2.11, both multilibs).
> 
> I'll probably instrument dg.exp to look out for tests taking more than
> 60 seconds.
> 
> Unfortunately, there's no guidance about what is considered appropriate
> and what out of bounds.

If you collect and display them with a plotting program (log scale maybe), it would become obvious where the right cutoff should be.  I'm thinking 3-10 seconds should be enough.
Joseph Myers Feb. 1, 2011, 9:32 p.m. UTC | #23
On Tue, 1 Feb 2011, Dave Korn wrote:

> >>   How many layers of nested parentheses /should/ we be able to support, in how
> >> much memory?  limits-exprparen.c keeps growing...
> >>
> >> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31827
> > 
> > I'd say we should support as many as allowed by available memory.
> 
>   Then the limits-exprparen.c test is quite meaningless and should just be
> deleted.

On the contrary, it has a clear purpose: to test that a reasonable number 
of parentheses work within reasonable resources.  We should support far 
more than is reasonable to test in the testsuite, but if bugs relating to 
excessive resource consumption are fixed we should still test a reasonable 
(smaller) case to make sure they stay fixed.  (Whether the current state 
is reasonable I don't know - and if the bug was never fixed that's a case 
for at least XFAILing the test; we have Bugzilla to track known bugs in 
preference to FAILs in the testsuite.)
Dave Korn Feb. 1, 2011, 9:51 p.m. UTC | #24
On 01/02/2011 20:41, Joseph S. Myers wrote:
> On Tue, 1 Feb 2011, Dave Korn wrote:
> 
>> On 01/02/2011 17:24, Joseph S. Myers wrote:
>>
>>> For the general issue: a slow test appears to have served its purpose by 
>>> showing up a (target-specific) bug in the compiler.  And in general you 
>>> need to consider whether a resource-hungry test is actually showing up a 
>>> bug and should not be so resource-hungry, before reducing the test size or 
>>> only running it conditionally.  (You might still reduce it after finding 
>>> it shows a bug - but only after filing that bug in Bugzilla; not simply 
>>> blindly presume that the test is too big for the testsuite.)
>>>
>>   How many layers of nested parentheses /should/ we be able to support, in how
>> much memory?  limits-exprparen.c keeps growing...
>>
>> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31827
> 
> I'd say we should support as many as allowed by available memory.

  Then the limits-exprparen.c test is quite meaningless and should just be
deleted.

    cheers,
      DaveK
Rainer Orth Feb. 2, 2011, 6:12 p.m. UTC | #25
Mike Stump <mikestump@comcast.net> writes:

>> I'll probably instrument dg.exp to look out for tests taking more than
>> 60 seconds.
>> 
>> Unfortunately, there's no guidance about what is considered appropriate
>> and what out of bounds.
>
> If you collect and display them with a plotting program (log scale maybe), it would become obvious where the right cutoff should be.  I'm thinking 3-10 seconds should be enough.

Right, I'll probably log all the data for a start and start
investigating from there.

	Rainer
Rainer Orth Feb. 2, 2011, 6:19 p.m. UTC | #26
"Joseph S. Myers" <joseph@codesourcery.com> writes:

> For the general issue: a slow test appears to have served its purpose by 
> showing up a (target-specific) bug in the compiler.  And in general you 
> need to consider whether a resource-hungry test is actually showing up a 
> bug and should not be so resource-hungry, before reducing the test size or 

Right: I had such a case recently where one testcase was slower by a
factor of 3 on one particular x86 CPU:

	http://gcc.gnu.org/ml/gcc-patches/2011-01/msg01234.html

I'll probably revisit this one with the Studio profiling tools.

> only running it conditionally.  (You might still reduce it after finding 
> it shows a bug - but only after filing that bug in Bugzilla; not simply 
> blindly presume that the test is too big for the testsuite.)

Sure.  While this takes some effort, it can have considerable benefits
as this case has shown.  On the other hand, spending literally 45
minutes in a single fortran testcase run as a torture test when that
isn't necessary seems to server no one.

	Rainer
Mike Stump Feb. 18, 2011, 7:25 a.m. UTC | #27
On Jan 31, 2011, at 8:24 AM, Rainer Orth wrote:
> As I've mentioned before, I've long meant to convert the ACATS testsuite
> to DejaGnu to provide all dg features (timeouts, xfails, multilib
> support, don't copy all sources into the build dir).  After the gnat.dg
> cleanup patch (and requiring it), here's the first version of a patch
> that does this.  It is by no means ready or polished, but I'm asking for
> general comments, suggestions for fixes or improvements, and testers.

So, there is a good chance this just doesn't work with canadian crosses...

So, lines like:

> +    file mkdir tests
> +    file mkdir support

tend to be wrong.  The build machine, typically doesn't have much on it, and so there are few filesystem operations that apply to it.  Typically, most go to the host or the target.  See remote_file from testsuite/*.exp for ideas.

Now, that said, if people have never tested that way for this testssuite, well, you can skip that as a feature before putting it in, but... at some point, it would be nice to set up a cross and test it, and a canadian cross and test it.


+    # FIXME: How to properly locate host CC?
+    # Place into support subdir.
+    remote_exec host [which gcc] "-c $srcdir/cd/cd300051.c -o support/cd300051.o"

This is non-sensical.  You want the path on the local machine, which is unrelated to the host machine and unrelated to the target machine, and then you want to use that on an unrelated machine...  Oops.  You do this systematically though out the patch.

if ![is_remote host] you can do this, this way, otherwise, this won't work.  See default_gcc_version in gcc.exp for example.  Now, that said, this will work 99% of the time, so you can do that to start as expedient, but it is still wrong.  Using just a simple tool name would be better, then, just document that the testing environment must contain that command in the path for the testing to work.


+# FIXME: CFLAGS seems wrong for Ada, cf. gcc/ada/Make*.

No, CFLAGS is fine, the C stands for compilation, don't you know...  :-)  I think this is right, if you want to retain the functionality of the rest of the infrastructure that can set DEFAULT_CFLAGS.


+    # FIXME: Better use set_board_info, unset_board_info from targetdb.exp?
+    # Or global var or uplevel N info proc ...?
+    set board_info(gnat,acats) 1

+    # FIXME: What's right here, target_info or board_info?
+    if [info exists board_info(gnat,acats)] {
+	# Pass -Isupport to locate support files.
+	# FIXME: Why -gnatws?
+	lappend options "additional_flags=-Isupport -gnatws"
+    }

Kinda a nasty way to do this...  Others have code like:

    if { [istarget "i?86-*-*"]
         || [istarget "m68k-*-*"] } then {
      uplevel 1 lappend additional_flags "-ffloat-store"

or

    if { [string match "*-*-darwin*" $target_triplet] } {
        lappend ALWAYS_CXXFLAGS "ldflags=-multiply_defined suppress"
       }

to set up specific flags for the compiler or for ld.  I'd think you could just set a normal variable and use that variable down below...  Don't see the need to drop into board_info, as this data isn't about the board.  It is about the testcase.


+	switch -glob $basename {
+	    "cxb30*" {
+		# FIXME: Handle via
+		# -- { dg-additional-files "cxb30040.o cxb30060.o cxb30130.o cxb30131.o" }
+		# but already passes without!?

This is nasty.  Generally we put in .x files, that if present, they are run, and they can do whatever you need to.


+    switch $target_triplet {
+	"ia64*-*-*" -
+	"s390*-*-*" {
+	    set target_insn "nop 0"
+	}
+	"mmix-*-*" {
+	    set target_insn "swym 0"
+	}
+	default {
+	    set target_insn "nop"
+	}
+    }

This is nasty...  I'm sure you know why...  I think breaking this out to a target.exp, and then running it here, would be better.


You can have both infrastructures side by side and leave intact the old method.  You can wire up testing to run both methods, and report differences.  Twice the testing time, but trivial to spot unintentional divergences, and possibly a whole lot more testing.  If you do this, you can have a single flag you can flip to use the old scheme, the new scheme, or both schemes.  With that, you can push the changes into the repo with the new scheme off (old on), and not worry about impacting people.  People that want to help test but are two lazy to download your patch, can just flip it on.  Also, if we weren't in stage4, you could flip it on for a week with both running, watch the results mailing lists, and see if there were any faults.

I think the most progress will be made the fastest, when you just start putting it in the tree with it on, or both on.  The only problem with that right now, is the poor timing wrt the release.  If you can build consensus with the Ada people and possibly the RMs on timing issues, you could run experiments in trunk, but...  I think I'd say don't even try.

I would encourage you, if there is a way to do the changes to be acceptable to the Ada folks in terms of safety (can be mitigated by interested parties trying it out), on put all the base infrastructure in and off (for now) and encourage people to turn it on in their environments.  If it prove safe enough to the Ada folks, you could then seek to flip the switch.


Also, be sure to do a make -j16 check to ensure it works (or have someone else do this)...  easy for it not to, and by the time you flip it on, you'd want that to be a known to work feature.


The Ada people will have to weigh in on the addition of -O2 to the files in the testsuite.

Otherwise, looks like a reasonable start.
Arnaud Charlet Feb. 21, 2011, 4:43 p.m. UTC | #28
> I think the most progress will be made the fastest, when you just start
> putting it in the tree with it on, or both on.  The only problem with that right
> now, is the poor timing wrt the release.  If you can build consensus with the
> Ada people and possibly the RMs on timing issues, you could run experiments
> in trunk, but...  I think I'd say don't even try.

Right, my feeling is that this kind of change is really more suitable for
stage1 rather than stage4.

> The Ada people will have to weigh in on the addition of -O2 to the files in the
> testsuite.

I haven't seen this part, are we talking about changing a couple of files or
changing hundreds of files?

If a couple of files, then that's OK. If we're talking about hundreds of
files, then that's not a good idea.

Arno
Mike Stump Feb. 21, 2011, 9:10 p.m. UTC | #29
On Feb 21, 2011, at 8:43 AM, Arnaud Charlet wrote:
> I haven't seen this part, are we talking about changing a couple of files or
> changing hundreds of files?
> 
> If a couple of files, then that's OK. If we're talking about hundreds of
> files, then that's not a good idea.

Virtually all of them (hundreds) was my take.  I think one can look to the g++.dg testsuite, in dg.exp:

# If a testcase doesn't have special options, use these.                                    
global DEFAULT_CXXFLAGS
if ![info exists DEFAULT_CXXFLAGS] then {
    set DEFAULT_CXXFLAGS " -ansi -pedantic-errors -Wno-long-long"
}


here we set the default flags to use for testcases in this part of the directory hierarchy.  If the Ada tests can be partitioned into groups of similar test cases with respect to the base flags, then one can put in that driver for that part, the base flags to use.  The benefit, no testcase needs an options line added, unless it truly is special.
Arnaud Charlet Feb. 21, 2011, 9:12 p.m. UTC | #30
> Virtually all of them (hundreds) was my take.  I think one can look to the
> g++.dg testsuite, in dg.exp:
> 
> # If a testcase doesn't have special options, use these.
> global DEFAULT_CXXFLAGS
> if ![info exists DEFAULT_CXXFLAGS] then {
>     set DEFAULT_CXXFLAGS " -ansi -pedantic-errors -Wno-long-long"
> }
> 
> 
> here we set the default flags to use for testcases in this part of the
> directory hierarchy.  If the Ada tests can be partitioned into groups of
> similar test cases with respect to the base flags, then one can put in that
> driver for that part, the base flags to use.  The benefit, no testcase needs an
> options line added, unless it truly is special.

Exactly. All tests should use the same base '-O2' flag, so it's really
wrong to put -O2 in the test itself and this should be done as you mentioned
above.
Rainer Orth Feb. 22, 2011, 5:40 p.m. UTC | #31
Mike Stump <mikestump@comcast.net> writes:

> On Jan 31, 2011, at 8:24 AM, Rainer Orth wrote:
>> As I've mentioned before, I've long meant to convert the ACATS testsuite
>> to DejaGnu to provide all dg features (timeouts, xfails, multilib
>> support, don't copy all sources into the build dir).  After the gnat.dg
>> cleanup patch (and requiring it), here's the first version of a patch
>> that does this.  It is by no means ready or polished, but I'm asking for
>> general comments, suggestions for fixes or improvements, and testers.
>
> So, there is a good chance this just doesn't work with canadian crosses...
>
> So, lines like:
>
>> +    file mkdir tests
>> +    file mkdir support
>
> tend to be wrong.  The build machine, typically doesn't have much on it, and so there are few filesystem operations that apply to it.  Typically, most go to the host or the target.  See remote_file from testsuite/*.exp for ideas.

This is exactly the kind of information I'm looking for: which
operations are supposed to run on the build, host and target systems and
do those three (or only build and host) share a common view of the
filesystem (either in general or as a GCC-specific restriction in
particular)?

> Now, that said, if people have never tested that way for this testssuite, well, you can skip that as a feature before putting it in, but... at some point, it would be nice to set up a cross and test it, and a canadian cross and test it.

Right: this might be even something as simple as a cross from
Solaris/SPARC to Solaris/x86: this should catch many issues already.

> +    # FIXME: How to properly locate host CC?
> +    # Place into support subdir.
> +    remote_exec host [which gcc] "-c $srcdir/cd/cd300051.c -o support/cd300051.o"
>
> This is non-sensical.  You want the path on the local machine, which is unrelated to the host machine and unrelated to the target machine, and then you want to use that on an unrelated machine...  Oops.  You do this systematically though out the patch.

That's what I feared and why I was asking for review/comment.  I was
trying to redo what the current non-dg ACATS testsuite is doing, but it
doesn't deal with the canadian-cross case.

> if ![is_remote host] you can do this, this way, otherwise, this won't work.  See default_gcc_version in gcc.exp for example.  Now, that said, this will work 99% of the time, so you can do that to start as expedient, but it is still wrong.  Using just a simple tool name would be better, then, just document that the testing environment must contain that command in the path for the testing to work.

Again, I'd rather get this right from the start, rather than rush in
something that's only 70 (or even 90)% ready.

> +# FIXME: CFLAGS seems wrong for Ada, cf. gcc/ada/Make*.
>
> No, CFLAGS is fine, the C stands for compilation, don't you know...  :-)  I think this is right, if you want to retain the functionality of the rest of the infrastructure that can set DEFAULT_CFLAGS.

I don't think this is compilation flags in general: AFAIK this is from
the default make rules, and they have separate CFLAGS, FFLAGS, PFLAGS
and several more.

> +    # FIXME: Better use set_board_info, unset_board_info from targetdb.exp?
> +    # Or global var or uplevel N info proc ...?
> +    set board_info(gnat,acats) 1
>
> +    # FIXME: What's right here, target_info or board_info?
> +    if [info exists board_info(gnat,acats)] {
> +	# Pass -Isupport to locate support files.
> +	# FIXME: Why -gnatws?
> +	lappend options "additional_flags=-Isupport -gnatws"
> +    }
>
> Kinda a nasty way to do this...  Others have code like:
>
>     if { [istarget "i?86-*-*"]
>          || [istarget "m68k-*-*"] } then {
>       uplevel 1 lappend additional_flags "-ffloat-store"
>
> or
>
>     if { [string match "*-*-darwin*" $target_triplet] } {
>         lappend ALWAYS_CXXFLAGS "ldflags=-multiply_defined suppress"
>        }

But this is per-target, not per (section of a) testsuite.

> to set up specific flags for the compiler or for ld.  I'd think you could just set a normal variable and use that variable down below...  Don't see the need to drop into board_info, as this data isn't about the board.  It is about the testcase.

Again, I couldn't find a good explanation when to use board_info, when
target_info, ...

> +	switch -glob $basename {
> +	    "cxb30*" {
> +		# FIXME: Handle via
> +		# -- { dg-additional-files "cxb30040.o cxb30060.o cxb30130.o cxb30131.o" }
> +		# but already passes without!?
>
> This is nasty.  Generally we put in .x files, that if present, they are run, and they can do whatever you need to.

I'm using dg-additional-sources now.  The version of the patch I sent
was quite early.

> +    switch $target_triplet {
> +	"ia64*-*-*" -
> +	"s390*-*-*" {
> +	    set target_insn "nop 0"
> +	}
> +	"mmix-*-*" {
> +	    set target_insn "swym 0"
> +	}
> +	default {
> +	    set target_insn "nop"
> +	}
> +    }
>
> This is nasty...  I'm sure you know why...  I think breaking this out to a target.exp, and then running it here, would be better.

Certainly more general than embedding it in one particular testsuite.

> You can have both infrastructures side by side and leave intact the old method.  You can wire up testing to run both methods, and report differences.  Twice the testing time, but trivial to spot unintentional divergences, and possibly a whole lot more testing.  If you do this, you can have a single flag you can flip to use the old scheme, the new scheme, or both schemes.  With that, you can push the changes into the repo with the new scheme off (old on), and not worry about impacting people.  People that want to help test but are two lazy to download your patch, can just flip it on.  Also, if we weren't in stage4, you could flip it on for a week with both running, watch the results mailing lists, and see if there were any faults.

Ok: my latest patch just ripped out the old check-acats target, but I
can easily leave it in.  There may well be issues since the dg
infrastructure will do multilib testing whereas the old one only did the
default multilib.

> I think the most progress will be made the fastest, when you just start putting it in the tree with it on, or both on.  The only problem with that right now, is the poor timing wrt the release.  If you can build consensus with the Ada people and possibly the RMs on timing issues, you could run experiments in trunk, but...  I think I'd say don't even try.

I didn't even consider that and still don't :-)

> I would encourage you, if there is a way to do the changes to be acceptable to the Ada folks in terms of safety (can be mitigated by interested parties trying it out), on put all the base infrastructure in and off (for now) and encourage people to turn it on in their environments.  If it prove safe enough to the Ada folks, you could then seek to flip the switch.

Yup: I'll do it this way once trunk opens again for 4.7 if I'm satisfied
the patch is in a reasonable state.

> Also, be sure to do a make -j16 check to ensure it works (or have someone else do this)...  easy for it not to, and by the time you flip it on, you'd want that to be a known to work feature.

That has been one of my goals from the beginning: the current
parallelism os check-gnats is too small for many of my systems
(especially the SPARC boxes), and I even run make -j16 -k check on my
laptop (4 core Core-i7, hyperthreading enabled).  I was happy to notice
that testing both multilibs on Solaris 11/x86 with my patch didn't take
twice as long as the current testsuite, so this is going in the right
direction.

> The Ada people will have to weigh in on the addition of -O2 to the files in the testsuite.

Sure: I'll see how to handle this properly.

> Otherwise, looks like a reasonable start.

Thanks.
	Rainer
Rainer Orth Feb. 22, 2011, 5:44 p.m. UTC | #32
Arnaud Charlet <charlet@adacore.com> writes:

>> I think the most progress will be made the fastest, when you just start
>> putting it in the tree with it on, or both on.  The only problem with that right
>> now, is the poor timing wrt the release.  If you can build consensus with the
>> Ada people and possibly the RMs on timing issues, you could run experiments
>> in trunk, but...  I think I'd say don't even try.
>
> Right, my feeling is that this kind of change is really more suitable for
> stage1 rather than stage4.

Fully agreed.

>> The Ada people will have to weigh in on the addition of -O2 to the files in the
>> testsuite.
>
> I haven't seen this part, are we talking about changing a couple of files or
> changing hundreds of files?

It's 62 files in my current patch (to be posted shortly), exactly the
ones currently listed in the various *.lst files.  Since Laurent
mentioned he had been changing testsuite files for the current ACATS 2.5
integratation anyway (though I couldn't find the exact 2.5 update he'd
been working on), I thought it safe to add the dg comments to the code.
Of course, I'll have to check the ACATS-UG rules at least when upgrading
to ACATS 3.0.

> If a couple of files, then that's OK. If we're talking about hundreds of
> files, then that's not a good idea.

Absolutely: this would be a nightmare to maintain.  The reasoning was
that it would be easier to see which compilation flags apply if they
were embedded in the code, rather than stored in separate *.lst files.

	Rainer
Arnaud Charlet Feb. 22, 2011, 5:50 p.m. UTC | #33
> > changing hundreds of files?
> 
> It's 62 files in my current patch (to be posted shortly), exactly the
> ones currently listed in the various *.lst files.  Since Laurent
> mentioned he had been changing testsuite files for the current ACATS 2.5
> integratation anyway (though I couldn't find the exact 2.5 update he'd
> been working on), I thought it safe to add the dg comments to the code.
> Of course, I'll have to check the ACATS-UG rules at least when upgrading
> to ACATS 3.0.
> 
> > If a couple of files, then that's OK. If we're talking about hundreds of
> > files, then that's not a good idea.
> 
> Absolutely: this would be a nightmare to maintain.  The reasoning was
> that it would be easier to see which compilation flags apply if they
> were embedded in the code, rather than stored in separate *.lst files.

OK, if we're talking about special switches (such as -gnato and
-fstack-check) corresponding to *.lst files, then this is OK.

Still, having -O2 handled globally by the script would be more desirable.

Arno
Rainer Orth Feb. 22, 2011, 5:56 p.m. UTC | #34
Arnaud Charlet <charlet@adacore.com> writes:

> OK, if we're talking about special switches (such as -gnato and
> -fstack-check) corresponding to *.lst files, then this is OK.
>
> Still, having -O2 handled globally by the script would be more desirable.

Agreed.  This is a shortcoming of dg-options: there should be an
alternative tag that allows to add options to the default instead of
replacing them.  I'll certainly look at that, since this has utility
beyond Ada.

	Rainer
Mike Stump Feb. 22, 2011, 11:10 p.m. UTC | #35
On Feb 22, 2011, at 9:40 AM, Rainer Orth wrote:
> This is exactly the kind of information I'm looking for: which
> operations are supposed to run on the build, host and target systems and
> do those three (or only build and host) share a common view of the
> filesystem (either in general or as a GCC-specific restriction in
> particular)?

Nothing in common.  Also see remote_upload and remote_download.

>>    if { [istarget "i?86-*-*"]
>>         || [istarget "m68k-*-*"] } then {
>>      uplevel 1 lappend additional_flags "-ffloat-store"
>> 
>> or
>> 
>>    if { [string match "*-*-darwin*" $target_triplet] } {
>>        lappend ALWAYS_CXXFLAGS "ldflags=-multiply_defined suppress"
>>       }
> 
> But this is per-target, not per (section of a) testsuite.

So?  The target file and board files contain invariants.  If you want to vary them, clearly they are not invariants.  That's a good introduction, but, not comprehensive.  Transient state for a particular board, would go into the board_info for that board, but that's for state more related to the board.

>> to set up specific flags for the compiler or for ld.  I'd think you could just set a normal variable and use that variable down below...  Don't see the need to drop into board_info, as this data isn't about the board.  It is about the testcase.
> 
> Again, I couldn't find a good explanation when to use board_info, when
> target_info, ...

This relates them all:

proc target_info { op args } {
    return [eval "board_info target \"$op\" $args"]
}

proc host_info { op args } {
    return [eval "board_info host \"$op\" $args"]
}

So, what is the different between board_info and target_info, none, if you do it right.  If you have a testcase that is using 5 boards, trivially, you'd need to use board_info, so that you can ask and set state for each one individually.  When this matters if when one switches the config to the build or host machine, which changes name, then you'd want to be sure to use board_info.  Most of these details don't matter to any of the files in gcc/lib or beyond.  Most of those users could just be target_info directly.  I think they have just been cargo culting.
Rainer Orth March 25, 2011, 11:05 a.m. UTC | #36
Mark Mitchell <mark@codesourcery.com> writes:

> On 2/1/2011 6:24 PM, Joseph S. Myers wrote:
>
>> For the general issue: a slow test appears to have served its purpose by 
>> showing up a (target-specific) bug in the compiler. 
>
> Indeed.  However, that doesn't justify having lots of slow tests.  What
> it does justify is investigating the reasons behind a slow test before
> turning it off and/or simplifying it.
>
> Here is what I suggest as a policy.
>
> If a test takes longer than 30 seconds to execute (including both
> compilation and execution of the generated program) on ordinary
> workstation hardware, in a native configuration, then the test should be
> investigated.  If the problem is generic (i.e., not specific to a
> particular host or target) and nobody is actively developing a patch to
> solve the problem, then the test should be flagged as "expensive" and
> only when run when the user explicitly requests "expensive" testing.  If
> the slow execution is considered unreasonable then a PR should be filed,
> just as for any other bug.
>
> I realize that "ordinary workstation hardware" is not a well-defined
> term.  But, there's no need to specify this policy with a high degree of
> rigor; when there is a question, we can use our usual processes for
> reaching consensus, and err on the side of leaving the test as
> "inexpensive".
>
> This policy would help to eliminate the small handful of tests that take
> completely disproportionate amounts of time to execute.

If agreement on this policy could be reached, it would be good if it
could be documented somewhere on gcc.gnu.org.  I haven't found a good
place for that, though.

There's just another such set of expensive tests

testsuite/48283		gcc.dg/graphite/block-[3478].c timeouts

and

middle-end/31827	limits-exprparen.c: Pid 2297 received a SIGSEGV for stack growth failure

has excessive stack space requirements.

Thanks.
	Rainer
diff mbox

Patch

diff -r a3b3a8c53056 contrib/dg-extract-results.sh
--- a/contrib/dg-extract-results.sh	Sun Jan 30 16:27:16 2011 +0100
+++ b/contrib/dg-extract-results.sh	Sun Jan 30 22:24:35 2011 +0100
@@ -6,7 +6,7 @@ 
 # The resulting file can be used with test result comparison scripts for
 # results from tests that were run in parallel.  See usage() below.
 
-# Copyright (C) 2008, 2009, 2010 Free Software Foundation
+# Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation
 # Contributed by Janis Johnson <janis187@us.ibm.com>
 #
 # This file is part of GCC.
@@ -142,65 +142,6 @@ 
   fi
 fi
 
-if [ "$TOOL" = acats ]; then
-  # Acats *.sum or *.log files aren't dejagnu generated, and they have
-  # somewhat different format.
-  ACATS_AWK=${TMP}/acats.awk
-  cat <<EOF > $ACATS_AWK
-BEGIN {
-  print_prologue=1; curfile=""; insummary=0
-  passcnt=0; failcnt=0; unsupcnt=0; failures=""
-}
-/^[ \t]*=== acats configuration ===/ {
-  insummary=0
-  if (print_prologue) print
-  next
-}
-/^[ \t]*=== acats tests ===/ {
-  if (print_prologue) print
-  print_prologue=0
-  next
-}
-/^Running chapter / {
-  if (curfile) close (curfile)
-  curfile="${TMP}/chapter-"\$3
-  print >> curfile
-  next
-}
-/^[ \t]*=== acats Summary ===/ {
-  if (curfile) close (curfile)
-  curfile=""
-  insummary=1
-  next
-}
-/^# of expected passes/		{ if (insummary == 1) passcnt += \$5; next; }
-/^# of unexpected failures/	{ if (insummary == 1) failcnt += \$5; next; }
-/^# of unsupported tests/	{ if (insummary == 1) unsupcnt += \$5; next; }
-/^\*\*\* FAILURES: / {
-  if (insummary == 1) {
-    if (failures) sub(/^\*\*\* FAILURES:/,"")
-    failures=failures""\$0
-  }
-}
-{
-  if (print_prologue) { print; next }
-  if (curfile) print >> curfile
-}
-END {
-  system ("cat ${TMP}/chapter-*")
-  print "		=== acats Summary ==="
-  print "# of expected passes		" passcnt
-  print "# of unexpected failures	" failcnt
-  if (unsupcnt) print "# of unsupported tests		" unsupcnt
-  if (failures) print failures
-}
-EOF
-
-  rm -f ${TMP}/chapter-*
-  $AWK -f $ACATS_AWK $SUM_FILES
-  exit 0
-fi
-
 # If no variants were specified, find all variants in the remaining
 # summary files.  Otherwise, ignore specified variants that aren't in
 # any of those summary files.
diff -r a3b3a8c53056 gcc/ada/gcc-interface/Make-lang.in
--- a/gcc/ada/gcc-interface/Make-lang.in	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/ada/gcc-interface/Make-lang.in	Sun Jan 30 22:24:35 2011 +0100
@@ -1,6 +1,6 @@ 
 # Top level -*- makefile -*- fragment for GNU Ada (GNAT).
 #   Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-#   2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+#   2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
 #   Free Software Foundation, Inc.
 
 #This file is part of GCC.
@@ -992,53 +992,28 @@ 
 	-$(MV) ada/*$(objext) ada/*.ali ada/b_*.c stagefeedback/ada
 	-$(MV) ada/stamp-* stagefeedback/ada
 
+check-ada: check-gnat
+check-ada-subtargets: check-gnat-subtargets
+
 lang_checks += check-gnat
-
-check-ada: check-acats check-gnat
-check-ada-subtargets: check-acats-subtargets check-gnat-subtargets
-
-ACATSDIR = $(TESTSUITEDIR)/ada/acats
-
-check_acats_targets = $(patsubst %,check-acats%, 0 1 2)
-
-check-acats:
-	@test -d $(ACATSDIR) || mkdir -p $(ACATSDIR); \
-	rootme=`${PWD_COMMAND}`; export rootme; \
-	EXPECT=$(EXPECT); export EXPECT; \
-	if [ -z "$(CHAPTERS)" ] && [ "$(filter -j, $(MFLAGS))" = "-j" ]; \
-	then \
-	  $(MAKE) $(check_acats_targets); \
-	  for idx in 0 1 2; do \
-	    mv -f $(ACATSDIR)$$idx/acats.sum $(ACATSDIR)$$idx/acats.sum.sep; \
-	    mv -f $(ACATSDIR)$$idx/acats.log $(ACATSDIR)$$idx/acats.log.sep; \
-	  done; \
-	  $(SHELL) $(srcdir)/../contrib/dg-extract-results.sh \
-	    $(ACATSDIR)0/acats.sum.sep $(ACATSDIR)1/acats.sum.sep \
-	    $(ACATSDIR)2/acats.sum.sep > $(ACATSDIR)/acats.sum; \
-	  $(SHELL) $(srcdir)/../contrib/dg-extract-results.sh -L \
-	    $(ACATSDIR)0/acats.log.sep $(ACATSDIR)1/acats.log.sep \
-	    $(ACATSDIR)2/acats.log.sep > $(ACATSDIR)/acats.log; \
-	  exit 0; \
-	fi; \
-	testdir=`cd ${srcdir}/${ACATSDIR} && ${PWD_COMMAND}`; \
-	export testdir; cd $(ACATSDIR) && $(SHELL) $${testdir}/run_acats $(CHAPTERS)
-
-check-acats-subtargets:
-	@echo $(check_acats_targets)
-
-# Parallelized check-acats
-$(check_acats_targets): check-acats%:
-	test -d $(ACATSDIR)$* || mkdir -p $(ACATSDIR)$*; \
-	testdir=`cd ${srcdir}/${ACATSDIR} && ${PWD_COMMAND}`; \
-	case "$*" in \
-	  0) chapters="`cd $$testdir/tests; echo [a-b]* c[0-4]*`";; \
-	  1) chapters="`cd $$testdir/tests; echo c[5-9ab]*`";; \
-	  2) chapters="`cd $$testdir/tests; echo c[c-z]* [d-z]*`";; \
-	esac; \
-	export testdir; cd $(ACATSDIR)$* && $(SHELL) $${testdir}/run_acats $$chapters
-
-.PHONY: check-acats $(check_acats_targets)
-
+lang_checks_parallelized += check-gnat
+# For description see comment above check_gcc_parallelize in gcc/Makefile.in.
+# FIXME: Adapt when ada/acats/tests gets moved to gnat.acats or simply omit
+# the directory.
+check_gnat_parallelize = acats.exp=tests/\[ab\]* \
+			acats.exp=tests/c\[1-2\]* \
+			acats.exp=tests/c3* \
+			acats.exp=tests/c4* \
+			acats.exp=tests/c\[567\]* \
+			acats.exp=tests/c8* \
+			acats.exp=tests/c9* \
+			acats.exp=tests/c\[ab\]* \
+			acats.exp=tests/cc* \
+			acats.exp=tests/cd* \
+			acats.exp=tests/ce* \
+			acats.exp=tests/c\[f-w\]* \
+			acats.exp=tests/c\[x-z\]* \
+			acats.exp=tests/\[d-z\]*
 
 # Bootstrapping targets for just GNAT - use the same stage directories
 gnatboot: force
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/support/impdef.a
--- a/gcc/testsuite/ada/acats/support/impdef.a	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/support/impdef.a	Sun Jan 30 22:24:35 2011 +0100
@@ -202,7 +202,7 @@ 
    function Cd30005_Proc (X : Integer) return Integer;
    pragma Import (C, Cd30005_Proc, "_cd30005_1");
  
-   pragma Linker_Options ("ACATS4GNATDIR/support/cd300051.o");
+   pragma Linker_Options ("support/cd300051.o");
  
    CD30005_1_Foreign_Address : constant System.Address:= Cd30005_Proc'Address;
  
@@ -315,7 +315,7 @@ 
    -- will expect to find the files to process at this location.
 
    Test_Path_Root : constant String :=
-     "ACATS4GNATDIR/tests/c2/";
+     "tests/";
    -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ --- MODIFY HERE AS NEEDED
 
    -- The following two strings must not be modified unless the .AW file
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/a/ac3106a.ada
--- a/gcc/testsuite/ada/acats/tests/a/ac3106a.ada	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/a/ac3106a.ada	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnat95" }
+
 -- AC3106A.ADA
 
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/c3/c34005p.ada
--- a/gcc/testsuite/ada/acats/tests/c3/c34005p.ada	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/c3/c34005p.ada	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnat95" }
+
 -- C34005P.ADA
 
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/c3/c34005r.ada
--- a/gcc/testsuite/ada/acats/tests/c3/c34005r.ada	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/c3/c34005r.ada	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnat95" }
+
 -- C34005R.ADA
 
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/c3/c34005s.ada
--- a/gcc/testsuite/ada/acats/tests/c3/c34005s.ada	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/c3/c34005s.ada	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnat95" }
+
 -- C34005S.ADA
 
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/c3/c34005u.ada
--- a/gcc/testsuite/ada/acats/tests/c3/c34005u.ada	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/c3/c34005u.ada	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnat95" }
+
 -- C34005U.ADA
 
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/c3/c34005v.ada
--- a/gcc/testsuite/ada/acats/tests/c3/c34005v.ada	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/c3/c34005v.ada	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnat95" }
+
 -- C34005V.ADA
 
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/c3/c34006g.ada
--- a/gcc/testsuite/ada/acats/tests/c3/c34006g.ada	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/c3/c34006g.ada	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnat95" }
+
 -- C34006G.ADA
 
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/c3/c34006j.ada
--- a/gcc/testsuite/ada/acats/tests/c3/c34006j.ada	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/c3/c34006j.ada	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnat95" }
+
 -- C34006J.ADA
 
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/c3/c34006l.ada
--- a/gcc/testsuite/ada/acats/tests/c3/c34006l.ada	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/c3/c34006l.ada	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnat95" }
+
 -- C34006L.ADA
 
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/c3/c34008a.ada
--- a/gcc/testsuite/ada/acats/tests/c3/c34008a.ada	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/c3/c34008a.ada	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnat95" }
+
 -- C34008A.ADA
 
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/c3/c3a0014.a
--- a/gcc/testsuite/ada/acats/tests/c3/c3a0014.a	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/c3/c3a0014.a	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnat95" }
+
 -- C3A0014.A
 --
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/c4/c41103b.ada
--- a/gcc/testsuite/ada/acats/tests/c4/c41103b.ada	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/c4/c41103b.ada	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnat95" }
+
 -- C41103B.ADA
 
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/c4/c41203b.ada
--- a/gcc/testsuite/ada/acats/tests/c4/c41203b.ada	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/c4/c41203b.ada	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnat95" }
+
 -- C41203B.ADA
 
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/c4/c41306a.ada
--- a/gcc/testsuite/ada/acats/tests/c4/c41306a.ada	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/c4/c41306a.ada	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnat95" }
+
 -- C41306A.ADA
 
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/c4/c45304a.ada
--- a/gcc/testsuite/ada/acats/tests/c4/c45304a.ada	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/c4/c45304a.ada	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnato" }
+
 -- C45304A.ADA
 
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/c4/c45304b.dep
--- a/gcc/testsuite/ada/acats/tests/c4/c45304b.dep	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/c4/c45304b.dep	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnato" }
+
 -- C45304B.DEP
 
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/c4/c45304c.dep
--- a/gcc/testsuite/ada/acats/tests/c4/c45304c.dep	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/c4/c45304c.dep	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnato" }
+
 -- C45304C.DEP
 
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/c4/c45504a.ada
--- a/gcc/testsuite/ada/acats/tests/c4/c45504a.ada	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/c4/c45504a.ada	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnato" }
+
 -- C45504A.ADA
 
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/c4/c45504b.dep
--- a/gcc/testsuite/ada/acats/tests/c4/c45504b.dep	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/c4/c45504b.dep	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnato" }
+
 -- C45504B.DEP
 
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/c4/c45504c.dep
--- a/gcc/testsuite/ada/acats/tests/c4/c45504c.dep	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/c4/c45504c.dep	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnato" }
+
 -- C45504C.DEP
 
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/c4/c45613a.ada
--- a/gcc/testsuite/ada/acats/tests/c4/c45613a.ada	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/c4/c45613a.ada	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnato" }
+
 -- C45613A.ADA
 
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/c4/c45613b.dep
--- a/gcc/testsuite/ada/acats/tests/c4/c45613b.dep	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/c4/c45613b.dep	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnato" }
+
 -- C45613B.DEP
 
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/c4/c45613c.dep
--- a/gcc/testsuite/ada/acats/tests/c4/c45613c.dep	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/c4/c45613c.dep	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnato" }
+
 -- C45613C.DEP
 
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/c4/c45632a.ada
--- a/gcc/testsuite/ada/acats/tests/c4/c45632a.ada	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/c4/c45632a.ada	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnato" }
+
 -- C45632A.ADA
 
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/c4/c45632b.dep
--- a/gcc/testsuite/ada/acats/tests/c4/c45632b.dep	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/c4/c45632b.dep	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnato" }
+
 -- C45632B.DEP
 
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/c4/c45632c.dep
--- a/gcc/testsuite/ada/acats/tests/c4/c45632c.dep	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/c4/c45632c.dep	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnato" }
+
 -- C45632C.DEP
 
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/c4/c460008.a
--- a/gcc/testsuite/ada/acats/tests/c4/c460008.a	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/c4/c460008.a	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnato" }
+
 -- C460008.A
 --
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/c4/c460011.a
--- a/gcc/testsuite/ada/acats/tests/c4/c460011.a	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/c4/c460011.a	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnato" }
+
 -- C460011.A
 --
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/c4/c46014a.ada
--- a/gcc/testsuite/ada/acats/tests/c4/c46014a.ada	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/c4/c46014a.ada	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnato" }
+
 -- C46014A.ADA
 
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/c4/c460a01.a
--- a/gcc/testsuite/ada/acats/tests/c4/c460a01.a	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/c4/c460a01.a	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnat95" }
+
 -- C460A01.A
 --
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/c4/c4a012b.ada
--- a/gcc/testsuite/ada/acats/tests/c4/c4a012b.ada	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/c4/c4a012b.ada	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnato" }
+
 -- C4A012B.ADA
 
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/c5/c52103x.ada
--- a/gcc/testsuite/ada/acats/tests/c5/c52103x.ada	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/c5/c52103x.ada	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -fstack-check" }
+
 -- C52103X.ADA
 
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/c5/c52104x.ada
--- a/gcc/testsuite/ada/acats/tests/c5/c52104x.ada	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/c5/c52104x.ada	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -fstack-check" }
+
 -- C52104X.ADA
 
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/c5/c52104y.ada
--- a/gcc/testsuite/ada/acats/tests/c5/c52104y.ada	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/c5/c52104y.ada	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -fstack-check" }
+
 -- C52104Y.ADA
 
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/c6/c650001.a
--- a/gcc/testsuite/ada/acats/tests/c6/c650001.a	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/c6/c650001.a	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnat95" }
+
 -- C650001.A
 --
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/c7/c731001.a
--- a/gcc/testsuite/ada/acats/tests/c7/c731001.a	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/c7/c731001.a	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnatE" }
+
 -- C731001.A
 --
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/c7/c74302b.ada
--- a/gcc/testsuite/ada/acats/tests/c7/c74302b.ada	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/c7/c74302b.ada	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnat95" }
+
 -- C74302B.ADA
 
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/c7/c74306a.ada
--- a/gcc/testsuite/ada/acats/tests/c7/c74306a.ada	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/c7/c74306a.ada	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnat95" }
+
 -- C74306A.ADA
 
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/c8/c85014a.ada
--- a/gcc/testsuite/ada/acats/tests/c8/c85014a.ada	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/c8/c85014a.ada	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnat95" }
+
 -- C85014A.ADA
 
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/c8/c85014b.ada
--- a/gcc/testsuite/ada/acats/tests/c8/c85014b.ada	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/c8/c85014b.ada	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnat95" }
+
 -- C85014B.ADA
 
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/c8/c85014c.ada
--- a/gcc/testsuite/ada/acats/tests/c8/c85014c.ada	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/c8/c85014c.ada	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnat95" }
+
 -- C85014C.ADA
 
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/c8/c854002.a
--- a/gcc/testsuite/ada/acats/tests/c8/c854002.a	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/c8/c854002.a	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnatE" }
+
 -- C854002.A
 --
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/c8/c87b26b.ada
--- a/gcc/testsuite/ada/acats/tests/c8/c87b26b.ada	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/c8/c87b26b.ada	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnat95" }
+
 -- C87B26B.ADA
 
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/c8/c87b41a.ada
--- a/gcc/testsuite/ada/acats/tests/c8/c87b41a.ada	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/c8/c87b41a.ada	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnat95" }
+
 -- C87B41A.ADA
 
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/c9/c99004a.ada
--- a/gcc/testsuite/ada/acats/tests/c9/c99004a.ada	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/c9/c99004a.ada	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnat95" }
+
 -- C99004A.ADA
 
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/ca/ca11018.a
--- a/gcc/testsuite/ada/acats/tests/ca/ca11018.a	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/ca/ca11018.a	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnatE" }
+
 -- CA11018.A
 --
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/ca/ca11019.a
--- a/gcc/testsuite/ada/acats/tests/ca/ca11019.a	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/ca/ca11019.a	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnatE" }
+
 -- CA11019.A
 --
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/ca/ca5006a.ada
--- a/gcc/testsuite/ada/acats/tests/ca/ca5006a.ada	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/ca/ca5006a.ada	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnatE" }
+
 -- CA5006A.ADA
 
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/cb/cb1010a.ada
--- a/gcc/testsuite/ada/acats/tests/cb/cb1010a.ada	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/cb/cb1010a.ada	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -fstack-check" }
+
 -- CB1010A.ADA
 
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/cb/cb1010c.ada
--- a/gcc/testsuite/ada/acats/tests/cb/cb1010c.ada	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/cb/cb1010c.ada	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -fstack-check" }
+
 -- CB1010C.ADA
 
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/cb/cb1010d.ada
--- a/gcc/testsuite/ada/acats/tests/cb/cb1010d.ada	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/cb/cb1010d.ada	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -fstack-check" }
+
 -- CB1010D.ADA
 
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/cb/cb40005.a
--- a/gcc/testsuite/ada/acats/tests/cb/cb40005.a	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/cb/cb40005.a	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnat95" }
+
 -- CB40005.A
 --
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/cc/cc3019c0.ada
--- a/gcc/testsuite/ada/acats/tests/cc/cc3019c0.ada	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/cc/cc3019c0.ada	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnat95" }
+
 -- CC3019C0.ADA
 
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/cc/cc51b03.a
--- a/gcc/testsuite/ada/acats/tests/cc/cc51b03.a	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/cc/cc51b03.a	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnat95" }
+
 -- CC51B03.A
 --
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/cc/cc51d02.a
--- a/gcc/testsuite/ada/acats/tests/cc/cc51d02.a	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/cc/cc51d02.a	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnat95" }
+
 -- CC51D02.A
 --
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/cd/cd10002.a
--- a/gcc/testsuite/ada/acats/tests/cd/cd10002.a	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/cd/cd10002.a	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnat95" }
+
 -- CD10002.A
 --
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/cd/cdd2a03.a
--- a/gcc/testsuite/ada/acats/tests/cd/cdd2a03.a	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/cd/cdd2a03.a	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnat95" }
+
 -- CDD2A03.A
 --
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/cxa/cxac005.a
--- a/gcc/testsuite/ada/acats/tests/cxa/cxac005.a	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/cxa/cxac005.a	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -gnat95" }
+
 -- CXAC005.A
 --
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/ada/acats/tests/cxh/cxh1001.a
--- a/gcc/testsuite/ada/acats/tests/cxh/cxh1001.a	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/ada/acats/tests/cxh/cxh1001.a	Sun Jan 30 22:24:35 2011 +0100
@@ -1,3 +1,5 @@ 
+-- { dg-options "-O2 -a -f" }
+--
 -- CXH1001.A
 --
 --                             Grant of Unlimited Rights
diff -r a3b3a8c53056 gcc/testsuite/gnat.acats/acats.exp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gcc/testsuite/gnat.acats/acats.exp	Sun Jan 30 22:24:35 2011 +0100
@@ -0,0 +1,55 @@ 
+# Copyright (C) 2011 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+# Load support procs.
+load_lib gnat-dg.exp
+
+# If a testcase doesn't have special options, use these.
+# FIXME: CFLAGS seems wrong for Ada, cf. gcc/ada/Make*.
+global DEFAULT_CFLAGS
+if ![info exists DEFAULT_CFLAGS] then {
+    set DEFAULT_CFLAGS "-O2"
+}
+
+# The ACATS tests are all run tests.
+set saved-dg-do-what ${dg-do-what-default}
+set dg-do-what-default run
+
+# FIXME: Look in old ACATS directory for the moment.
+set saved-srcdir $srcdir
+set srcdir "$srcdir/ada/acats/tests"
+
+# Initialize `dg'
+dg-init
+gnat-acats-init
+
+# Main loop.
+# Some source files are preprocessed, so search testdir, too.
+# Only use first one of multifile testcases.
+gnat-dg-acats-runtest [lsort \
+	[glob -nocomplain $srcdir/*/???????{,0}.{a,ada,adt,am,dep} \
+		tests/???????{,0}.{a,ada,adt,am,dep}]] \
+	"" "$DEFAULT_CFLAGS"
+
+set srcdir ${saved-srcdir}
+set dg-do-what-default ${saved-dg-do-what}
+
+# All done.
+dg-finish
+gnat-acats-finish
+
+# Unset again so gnat.dg isn't affected.
+unset DEFAULT_CFLAGS
diff -r a3b3a8c53056 gcc/testsuite/lib/gnat-dg.exp
--- a/gcc/testsuite/lib/gnat-dg.exp	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/lib/gnat-dg.exp	Sun Jan 30 22:24:35 2011 +0100
@@ -33,16 +33,18 @@ 
 
     # Remove additional output files apart from $output_file, which may be
     # needed by dg-final.
+    # FIXME: Don't clean ACATS support files.
     set output_file [lindex $result 1]
     set basename [file rootname $output_file]
     set clean_result [remote_exec host [find_gnatclean] "-c -q -n $basename"]
     if { [lindex $clean_result 0] != -1 } {
 	set clean_files [lindex $clean_result 1]
 	# Purge NL from clean_files.
-	regsub -all "\[\r\n\]+" $clean_files " " clean_files
+	regsub -all "\[\n\r\]+" $clean_files " " clean_files
 	# Remove ./ so lremove works.
 	regsub -all "\./" $clean_files "" clean_files
 	lremove clean_files $output_file
+	verbose -log "clean_files = $clean_files"
 	eval remote_file host delete $clean_files
     }
 
@@ -57,9 +59,142 @@ 
     lappend additional_prunes "fatal error: maximum errors reached"
     lappend additional_prunes "linker input file"
 
+    # FIXME: Explain.
+    # Probably unnecessary with -gnato -gnatE for support files, but maybe
+    # need to move support files to subdir to avoid cleaning them.
+    #lappend additional_prunes "report.adb:312"
+
     return [gcc-dg-prune $system $text]
 }
 
+proc acats-get-options { src } {
+    # dg-options sets a variable called dg-extra-tool-flags.
+    set dg-extra-tool-flags ""
+
+    # current_compiler_flags reads tool_flags from the same stack frame
+    # as dg-extra-tool-flags
+    set tool_flags ""
+
+    set tmp [dg-get-options $src]
+    foreach op $tmp {
+	set cmd [lindex $op 0]
+	if { ![string compare "dg-options" $cmd] } {
+	    set status [catch "$op" errmsg]
+	    if { $status != 0 } {
+		perror "$src: $errmsg for \"$op\"\n"
+		unresolved "$src: $errmsg for \"$op\""
+		return
+	    }
+	} else {
+	    # Ignore unrecognized dg- commands, but warn about them.
+	    warning "gnat-dg.exp does not support $cmd"
+	}
+    }
+
+    # Return flags to use for compiling the primary source file and for
+    # linking.
+    return ${dg-extra-tool-flags}
+}
+
+proc gnat-dg-acats-runtest { testcases flags default-extra-flags } {
+    global runtests
+    global board_info
+
+    # FIXME: Better use set_board_info, unset_board_info from targetdb.exp?
+    # Or global var or uplevel N info proc ...?
+    set board_info(gnat,acats) 1
+
+    verbose -log "testcases = $testcases"
+    foreach testcase $testcases {
+	# If we're only testing specific files and this isn't one of them,
+	# skip it.
+	if ![runtest_file_p $runtests $testcase] {
+	    continue
+	}
+	verbose "Testing [file tail [file dirname $testcase]]/[file tail $testcase]"
+	
+	verbose -log "testcase = $testcase"
+
+	if [string match "*/???????0.*" $testcase] {
+	    regsub "0\\..*" $testcase "?.{a,ada,adt,am,dep}" testpattern
+	    set testfiles [lsort [glob -nocomplain $testpattern]]
+	} else {
+	    set testfiles $testcase
+	}
+	verbose -log "testfiles = $testfiles"
+
+	# FIXME: Perhaps move to gnat_init?
+	gnat_set_ada_env_vars
+
+	# FIXME: Determine options from testcase source.
+	set extra_flags [acats-get-options $testcase]
+	if { $extra_flags != "" } {
+	    set save_flags $flags
+	    eval lappend flags $extra_flags
+	}
+
+	set chop_result [remote_exec target [find_gnatchop] "-c -w $testfiles"]
+	if { [lindex $chop_result 0] != -1 } {
+	    set chop_files [lindex $chop_result 1]
+	    # Filter out comments so sources are not removed.
+	    regsub -all "splitting \[^\n\r\]+ into:\[\n\r\]+" $chop_files "" chop_files
+	    # FIXME: Filter out "warning:.*", "<N> warning(s)"
+	    # Purge NL from chop_files.
+	    regsub -all "\[\n\r\]+" $chop_files " " chop_files
+	    verbose -log "chop_files = $chop_files"
+	}
+
+	set basename [file rootname [file tail $testcase]]
+	verbose -log "basename = $basename"
+	switch -glob $basename {
+	    "cxb30*" {
+		# FIXME: Handle via
+		# -- { dg-additional-files "cxb30040.o cxb30060.o cxb30130.o cxb30131.o" }
+		# but already passes without!?
+		
+	    }
+	    "ca1020e*" {
+		remote_file host delete ca1020e_func1.adb ca1020e_func2.adb \
+		    ca1020e_proc1.adb ca1020e_proc2.adb
+	    }
+	    "ca14028*" {
+		remote_file host delete ca14028_func2.ads ca14028_func3.ads \
+		    ca14028_proc1.ads ca14028_proc3.ads
+	    }
+	    "cxh1001*" {
+		set out [open gnat.adc w]
+		puts $out "pragma Normalize_Scalars;"
+		close $out
+		# FIXME: Rename to clean_files.
+		lappend chop_files gnat.adc
+	    }
+	}
+
+	# Change testcase to reflect this.
+	# FIXME: use gnatls -u instead?
+	set basename [file rootname [file tail $testcase]]
+	# Take only 7 characters.
+	set basename [string range $basename 0 6]
+	verbose -log "basename = $basename"
+	set mainfiles [lsort [glob -nocomplain $basename?.adb]]
+	eval lappend mainfiles [lsort [glob -nocomplain $basename*m.adb]]
+	eval lappend mainfiles [lsort [glob -nocomplain $basename.adb]]
+	set testcase [lindex $mainfiles [expr [llength $mainfiles]-1]]
+	verbose -log "testcase = $testcase"
+
+	dg-test $testcase $flags ${default-extra-flags}
+
+	eval remote_file host delete $chop_files
+
+	# Restore flags for next testcase.
+	if { $extra_flags != "" } {
+	    set flags $save_flags
+	}
+    }
+
+    unset board_info(gnat,acats)
+}
+
 # Utility routines.
 
 #
@@ -79,7 +214,23 @@ 
 	if { [regexp "tasking not implemented" $output] } {
 	    return [list "unsupported" $output]
 	}
-	return $result
+
+	#
+	# For ACATS tests, PASS or FAIL doesn't depend on exit status, but
+	# on test output.  Cf. report.adb:
+	#
+	# status		pattern
+	#
+	# PASS			==== 
+	# DOES_NOT_APPLY	++++ 
+	# ACTION_REQUIRED	!!!! 
+	# OTHERS		**** 
+	#
+	if { [regexp {==== |\+\+\+\+ |!!!! } $output] } {
+	    return [list "pass" $output]
+	} else {
+	    return $result
+	}
     }
 }
 
diff -r a3b3a8c53056 gcc/testsuite/lib/gnat.exp
--- a/gcc/testsuite/lib/gnat.exp	Sun Jan 30 16:27:16 2011 +0100
+++ b/gcc/testsuite/lib/gnat.exp	Sun Jan 30 22:24:35 2011 +0100
@@ -25,6 +25,7 @@ 
 load_lib gcc-defs.exp
 load_lib gcc.exp
 load_lib timeout.exp
+load_lib copy-file.exp
 
 #
 # GNAT_UNDER_TEST is the compiler under test.
@@ -107,14 +108,172 @@ 
     }
 }
 
+# Build ACATS support files first, but not in gnat_init which is generic.
+proc gnat-acats-init { } {
+    global srcdir
+    global target_triplet
+    global env
+
+    # FIXME: Explain.  Adapt later.
+    set support $srcdir/../support
+
+    # FIXME: Only put *.tst files from tests into ., place support file in
+    # support subdir?
+    # FIXME: subdir necessary?  Doesn't show up in test names anyway, but
+    # helps to distinguish testcases from support files.
+    #remote_load host [which mkdir] c2
+    file mkdir tests
+    file mkdir support
+
+    gnat_target_compile $support/impbit.adb impbit executable ""
+    set result [remote_exec target impbit "" ""]
+    if { [lindex $result 0] != -1 } {
+	set target_bit [lindex $result 1]
+	# Purge NL from target_bit.
+	regsub -all "\[\r\n\]+" $target_bit "" target_bit
+	verbose -log "target_bit = $target_bit"
+    }
+    # FIXME: Cleanup.
+    # Currently handled in gnat-dg-test, move elsewhere, perhaps
+    # gnat_target_compile?
+    eval remote_exec target [find_gnatclean] impbit
+
+    switch $target_triplet {
+	"ia64*-*-*" -
+	"s390*-*-*" {
+	    set target_insn "nop 0"
+	}
+	"mmix-*-*" {
+	    set target_insn "swym 0"
+	}
+	default {
+	    set target_insn "nop"
+	}
+    }
+    verbose -log "target_insn = $target_insn"
+
+    # Unset environment variables that interfere with host compiler.
+    if { [info exists env(ADA_INCLUDE_PATH)] } {
+	verbose -log "unsetting ADA_INCLUDE_PATH"
+	set orig_ada_include_path $env(ADA_INCLUDE_PATH)
+	unsetenv ADA_INCLUDE_PATH
+    }
+    if { [info exists env(ADA_OBJECTS_PATH)] } {
+	verbose -log "unsetting ADA_OBJECTS_PATH"
+	set orig_ada_objects_path $env(ADA_OBJECTS_PATH)
+	unsetenv ADA_OBJECTS_PATH
+    }
+    if { [info exists env(GCC_EXEC_PREFIX)] } {
+	verbose -log "unsetting GCC_EXEC_PREFIX"
+	set orig_gcc_exec_prefix $env(GCC_EXEC_PREFIX)
+	unsetenv GCC_EXEC_PREFIX
+    }
+
+    # FIXME: Loop to avoid overflowing command line.
+    remote_exec host [which gnatchop] \
+	"-c -w [glob -nocomplain $support/*.{a,ada}] support"
+
+    set inp [open $support/macro.dfs r]
+    set out [open MACRO.DFS w]
+    while { [gets $inp line] >= 0 } {
+	regsub -all "ACATS4GNATBIT" $line $target_bit line
+	regsub -all "ACATS4GNATINSN" $line $target_insn line
+	puts $out $line
+    }
+    close $inp
+    close $out
+
+    gcc_copy_files [glob -nocomplain $srcdir/*/*.tst] tests
+    gcc_copy_files [glob -nocomplain $support/*.tst] support
+    set out [open TSTTESTS.DAT w]
+    foreach tst [glob -nocomplain */*.tst] {
+	puts $out $tst
+    }
+    close $out
+
+    remote_exec host [which gnatmake] "-q -gnatws support/macrosub.adb"
+    remote_load host ./macrosub
+    eval remote_exec host [which gnatclean] macrosub
+    file_on_host delete MACRO.DFS
+    file_on_host delete TSTTESTS.DAT
+
+    # FIXME: How to properly locate host CC?
+    # Place into support subdir.
+    remote_exec host [which gcc] "-c $srcdir/cd/cd300051.c -o support/cd300051.o"
+
+    # Copy c2/c25000[12].aw into build dir.
+    gcc_copy_files [glob -nocomplain $srcdir/c2/*.aw] tests
+
+    remote_exec host [which gnatmake] "-q -gnatws support/widechr.adb"
+    remote_load host ./widechr
+    eval remote_exec host [which gnatclean] widechr
+
+    # Restore environment variables.
+    if { $orig_ada_include_path != "" } {
+	setenv ADA_INCLUDE_PATH $orig_ada_include_path
+    }
+    if { $orig_ada_objects_path != "" } {
+	setenv ADA_OBJECTS_PATH $orig_ada_objects_path
+    }
+    if { $orig_gcc_exec_prefix != "" } {
+	setenv GCC_EXEC_PREFIX $orig_gcc_exec_prefix
+    }
+
+    foreach src [glob -nocomplain $srcdir/*/*.c] {
+	set obj support/[file rootname [file tail $src]].o
+	gnat_target_compile $src $obj object ""
+    }
+
+    # FIXME: Loop to avoid overflowing command line?
+    remote_exec target [find_gnatchop] \
+	"-c -w [glob -nocomplain tests/*.adt tests]"
+    remote_exec target [find_gnatchop] \
+	"-c -w [glob -nocomplain support/*.adt support]"
+
+    # FIXME: Really compile *.ads?
+    # Compile all at once?
+    # Two loops, first over *.ads, then over *.adb?
+    lappend opts "additional_flags=-gnatws -O2 -gnato -gnatE -D support"
+    foreach src [glob -nocomplain support/*.ad\[sb\]] {
+	set obj [file rootname [file tail $src]].o
+	gnat_target_compile $src $obj object $opts
+    }
+}
+
+# Cleanup ACATS support files.
+proc gnat-acats-finish { } {
+    # FIXME: Maybe remember file lists in gnat-acats-init?
+    # Simply remove support and tests subdirs.
+}
+
+proc gnat_set_ada_env_vars { } {
+    global rtsdir
+
+    if [info exists TOOL_OPTIONS] {
+	set rtsdir "[get_multilibs ${TOOL_OPTIONS}]/libada"
+    } else {
+	set rtsdir "[get_multilibs]/libada"
+    }
+
+    # gnatlink looks for system.ads itself and has no --RTS option, so
+    # specify via environment
+    setenv ADA_INCLUDE_PATH "$rtsdir/adainclude"
+    setenv ADA_OBJECTS_PATH "$rtsdir/adainclude"
+    # Always log so compilations can be repeated manually.
+    verbose -log "ADA_INCLUDE_PATH=$rtsdir/adainclude"
+    verbose -log "ADA_OBJECTS_PATH=$rtsdir/adainclude"
+}
+
 proc gnat_target_compile { source dest type options } {
     global rootme
     global tmpdir
     global gluefile wrap_flags
     global srcdir
+    global rtsdir
     global GNAT_UNDER_TEST
     global TOOL_OPTIONS
     global gnat_target_current
+    global board_info
 
     # dg-require-effective-target tests must be compiled as C.
     if [ string match "*.c" $source ] then {
@@ -125,30 +284,29 @@ 
     # GNAT_UNDER_TEST and the appropriate RTS.
     if { $gnat_target_current!="[current_target_name]" } {
 	set gnat_target_current "[current_target_name]"
-	if [info exists TOOL_OPTIONS] {
-	    set rtsdir "[get_multilibs ${TOOL_OPTIONS}]/libada"
-	} else {
-	    set rtsdir "[get_multilibs]/libada"
-	}
+
+	gnat_set_ada_env_vars
+
 	if [info exists TOOL_EXECUTABLE] {
 	    set GNAT_UNDER_TEST "$TOOL_EXECUTABLE"
 	} else {
 	    set GNAT_UNDER_TEST "[local_find_gnatmake]"
 	}
         set GNAT_UNDER_TEST "$GNAT_UNDER_TEST --RTS=$rtsdir"
-
-	# gnatlink looks for system.ads itself and has no --RTS option, so
-	# specify via environment
-	setenv ADA_INCLUDE_PATH "$rtsdir/adainclude"
-	setenv ADA_OBJECTS_PATH "$rtsdir/adainclude"
-	# Always log so compilations can be repeated manually.
-	verbose -log "ADA_INCLUDE_PATH=$rtsdir/adainclude"
-	verbose -log "ADA_OBJECTS_PATH=$rtsdir/adainclude"
     }
 
-    lappend options "compiler=$GNAT_UNDER_TEST -q -f"
+    # FIXME: Is -f necessary/desirable for gnat.dg?  It hurts for gnat.acats.
+    #lappend options "compiler=$GNAT_UNDER_TEST -q -f"
+    lappend options "compiler=$GNAT_UNDER_TEST -q"
     lappend options "timeout=[timeout_value]"
 
+    # FIXME: What's right here, target_info or board_info?
+    if [info exists board_info(gnat,acats)] {
+	# Pass -Isupport to locate support files.
+	# FIXME: Why -gnatws?
+	lappend options "additional_flags=-Isupport -gnatws"
+    }
+
     if { [target_info needs_status_wrapper]!="" && [info exists gluefile] } {
 	lappend options "libs=${gluefile}"
 	lappend options "ldflags=$wrap_flags"
@@ -234,6 +392,26 @@ 
     return $gnatclean
 }
 
+proc find_gnatchop {} {
+    global tool_root_dir
+
+    if ![is_remote host] {
+        set file [lookfor_file $tool_root_dir gnatchop]
+        if { $file == "" } {
+	    set file [lookfor_file $tool_root_dir gcc/gnatchop]
+        }
+        if { $file != "" } {
+	    set root [file dirname $file]
+	    set CC "$file --GCC=$root/xgcc";
+        } else {
+	    set CC [transform gnatchop]
+        }
+    } else {
+        set CC [transform gnatchop]
+    }
+    return $CC
+}
+
 # Local Variables:
 # tcl-indent-level:4
 # End: