This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

PATCH: ld/testsuite/ld-cdtest to handle g++ 3.0 and beyond


g++ 3.0 and beyond requires libsupc++ to be linked in unless all
objects were compiled without support for exceptions (and RTTI,
new/delete, etc).  It seems better to remove the requirement of this
library since these tests use no exotic C++ features.

Independently, soon after the release of g++ 3.0, Jason put support
for the Named Return Value optimization into g++.  I assume it will be
in the gcc 3.1 release and beyond.  I played with a few
implementations of this check.  I finally decided that it was best to
check one way and then check the other way (if the first way fails)
instead of attempting to guess whether the compiler implements NRV.
This approach seems safe since the test will still catch any cases
where the linker lost or misordered constructor calls.

I have tested this patch, by running `make check' in an already built
binutils 2.11 branch tree against gcc 2.95.3, gcc 3.0 and gcc mainline
on i386-unknown-freebsd4.3.

I have tested this patch in a binutils mainline tree against gcc
2.95.3, gcc 3.0 and gcc mainline on i386-unknown-freebsd4.3.  In this
case, I only ran configure in ld and then ran `make check' against an
already installed copy of binutils.

Before this patch, only use of gcc 2.95.3 allowed it to pass properly
even though when hand-checked 3.0 and mainline are producing results
which I think are OK.

[FYI, I was able to run ``cvs add'' in the binutils branch, but not
 mainline, with only my gcc write privs.  While preparing a patch for
 posting, I did it naturally.  I am sorry, if doing that caused any
 problems.  If this patch is approved, a binutils maintainer will need
 to install it.]

With this patch and another for ld/testsuite/ld-srec/srec.exp (to be
posted), I see only one failure with gcc mainline for binutils 2.11.X
(FAIL: selective4 due to g++ V3 ABI).

Regards,
Loren

2001-07-24  Loren J. Rittle  <ljrittle@acm.org>

	* ld-cdtest/cdtest-nrv.dat: New file.
	* ld-cdtest/cdtest.exp: Do not require any exception support
	library.  Check results against NRV.

Index: ld-cdtest/cdtest-nrv.dat
===================================================================
RCS file: cdtest-nrv.dat
diff -N cdtest-nrv.dat
*** /dev/null	Tue May  5 13:32:27 1998
--- cdtest-nrv.dat	Mon Jul 23 23:07:22 2001
***************
*** 0 ****
--- 1,13 ----
+ Constructing Foo(1) "static_foo"
+ Constructing Foo(2) "static_foo"
+ Constructing Foo(3) "automatic_foo"
+ Constructing Foo(4) "default-foo"
+ Constructing Foo(5) "other_foo1"
+ Constructing Foo(6) "other_foo2"
+ Copying Foo(5) "other_foo1" to Foo(6)
+ Destructing Foo(6) "other_foo1" (remaining foos: 5)
+ Destructing Foo(5) "other_foo1" (remaining foos: 4)
+ Destructing Foo(4) "default-foo" (remaining foos: 3)
+ Destructing Foo(3) "automatic_foo" (remaining foos: 2)
+ Destructing Foo(2) "static_foo" (remaining foos: 1)
+ Destructing Foo(1) "static_foo" (remaining foos: 0)
Index: ld-cdtest/cdtest.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-cdtest/cdtest.exp,v
retrieving revision 1.1.1.1.4.1
diff -c -r1.1.1.1.4.1 cdtest.exp
*** cdtest.exp	2001/06/07 03:17:18	1.1.1.1.4.1
--- cdtest.exp	2001/07/24 06:07:22
***************
*** 1,5 ****
  # Expect script for LD cdtest Tests
! #   Copyright 1993, 1994, 1995, 1997 Free Software Foundation, Inc.
  #
  # This file is free software; you can redistribute it and/or modify
  # it under the terms of the GNU General Public License as published by
--- 1,5 ----
  # Expect script for LD cdtest Tests
! #   Copyright 1993, 1994, 1995, 1997, 2001 Free Software Foundation, Inc.
  #
  # This file is free software; you can redistribute it and/or modify
  # it under the terms of the GNU General Public License as published by
***************
*** 35,48 ****
      return
  }
  
! if { ![ld_compile "$CXX $CXXFLAGS -fgnu-linker" $srcdir/$subdir/cdtest-foo.cc tmpdir/cdtest-foo.o]
!      || ![ld_compile "$CXX $CXXFLAGS -fgnu-linker" $srcdir/$subdir/cdtest-bar.cc tmpdir/cdtest-bar.o]
!      || ![ld_compile "$CXX $CXXFLAGS -fgnu-linker" $srcdir/$subdir/cdtest-main.cc tmpdir/cdtest-main.o] } {
      unresolved $test1
      unresolved $test2
      return
  }
  
  if ![ld_link $ld tmpdir/cdtest {tmpdir/cdtest-foo.o tmpdir/cdtest-bar.o tmpdir/cdtest-main.o}] {
      fail $test1
  } else {
--- 35,50 ----
      return
  }
  
! if { ![ld_compile "$CXX $CXXFLAGS -fgnu-linker -fno-exceptions" $srcdir/$subdir/cdtest-foo.cc tmpdir/cdtest-foo.o]
!      || ![ld_compile "$CXX $CXXFLAGS -fgnu-linker -fno-exceptions" $srcdir/$subdir/cdtest-bar.cc tmpdir/cdtest-bar.o]
!      || ![ld_compile "$CXX $CXXFLAGS -fgnu-linker -fno-exceptions" $srcdir/$subdir/cdtest-main.cc tmpdir/cdtest-main.o] } {
      unresolved $test1
      unresolved $test2
      return
  }
  
+ set expected_output "$srcdir/$subdir/cdtest.dat"
+ 
  if ![ld_link $ld tmpdir/cdtest {tmpdir/cdtest-foo.o tmpdir/cdtest-bar.o tmpdir/cdtest-main.o}] {
      fail $test1
  } else {
***************
*** 54,64 ****
  	verbose "$exec_output" 1
  	fail $test1
      } else {
! 	send_log "diff tmpdir/cdtest.out $srcdir/$subdir/cdtest.dat\n"
! 	verbose "diff tmpdir/cdtest.out $srcdir/$subdir/cdtest.dat"
! 	catch "exec diff tmpdir/cdtest.out $srcdir/$subdir/cdtest.dat" exec_output
  	set exec_output [prune_warnings $exec_output]
  
  	if [string match "" $exec_output] then {
  	    pass $test1
  	} else {
--- 56,78 ----
  	verbose "$exec_output" 1
  	fail $test1
      } else {
! 	send_log "diff tmpdir/cdtest.out $expected_output\n"
! 	verbose "diff tmpdir/cdtest.out $expected_output"
! 	catch "exec diff tmpdir/cdtest.out $expected_output" exec_output
  	set exec_output [prune_warnings $exec_output]
  
+ 	if ![string match "" $exec_output] then {
+ 	    send_log "$exec_output\n"
+ 	    verbose "$exec_output" 1
+ 	    send_log "Checking against Named Return Value optimization\n"
+ 	    verbose "Checking against Named Return Value optimization" 1
+ 	    set expected_output "$srcdir/$subdir/cdtest-nrv.dat"
+ 	    send_log "diff tmpdir/cdtest.out $expected_output\n"
+ 	    verbose "diff tmpdir/cdtest.out $expected_output"
+ 	    catch "exec diff tmpdir/cdtest.out $expected_output" exec_output
+ 	    set exec_output [prune_warnings $exec_output]
+ 	}
+ 
  	if [string match "" $exec_output] then {
  	    pass $test1
  	} else {
***************
*** 83,91 ****
  	    verbose "$exec_output" 1
  	    fail $test2
  	} else {
! 	    send_log "diff tmpdir/cdtest.out $srcdir/$subdir/cdtest.dat\n"
! 	    verbose "diff tmpdir/cdtest.out $srcdir/$subdir/cdtest.dat"
! 	    catch "exec diff tmpdir/cdtest.out $srcdir/$subdir/cdtest.dat" exec_output
  	    set exec_output [prune_warnings $exec_output]
  
  	    if [string match "" $exec_output] then {
--- 97,105 ----
  	    verbose "$exec_output" 1
  	    fail $test2
  	} else {
! 	    send_log "diff tmpdir/cdtest.out $expected_output\n"
! 	    verbose "diff tmpdir/cdtest.out $expected_output"
! 	    catch "exec diff tmpdir/cdtest.out $expected_output" exec_output
  	    set exec_output [prune_warnings $exec_output]
  
  	    if [string match "" $exec_output] then {


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]