This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: Cause gnatlink in gnat.dg to call correct gcc


While running make check in a mainline tree on Solaris 11/x86 built to
use Sun as while I had GCC 4.4 built with gas in PATH, all 64-bit gnat
execution tests failed in a strange way:

FAIL: gnat.dg/abstract_with_anonymous_result.adb (test for excess errors)
Excess errors:
/usr/sfw/bin/gas: unrecognized option `-xarch=generic64'

Running the testsuite under truss reveals that gnatlink runs gcc from
PATH with a -B option pointing to the specs file of the freshly built
compiler, thus passing Sun as options to gas, which doesn't understand
that one.

The obvious solution is to avoid running gcc from PATH at all, but use
the just built gcc instead.  Unfortunately, this is more intricate than
it seems:

* We need to pass all of the full gcc pathname, the corresponding -B
  option, and the correct multilib flag, if present, via the --GCC
  option.  The tricky part here is to get this through the dejagnu exec
  machinery as a single option including the embedded whitespace.  The
  trick (thanks to Ben Elliston!) was to quote the embedded whitespace
  to handle the levels of evaluation involved.

* Since now the multilib flag is part of $GNAT_UNDER_TEST, we need to
  reinitialize that every time the target changes (e.g. when testing
  several multilibs).

* gnatlink looks for system.ads itself, and the only way to point it to
  the one in the just built tree is by setting
  ADA_INCLUDE_PATH/ADA_OBJECTS_PATH, just as ada/acats/run_acats does.

With those changes in place in gnat.exp, I was able to successfully run
the gnat.dg testsuite with RUNTESTFLAGS='--target_board "unix{,-m64}"'
in the configuration described above.

Ok for mainline?

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University


2010-02-10  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	* lib/gnat.exp (gnat_init): Remove GNAT_UNDER_TEST_ORIG.
	(gnat_target_compile): Likewise.
	Reinitialize GNAT_UNDER_TEST if target changes.
	Set ADA_INCLUDE_PATH, ADA_OBJECTS_PATH in environment.
	(local_find_gnatmake): Pass full --GCC to gnatlink.

diff -r 5620fb8a9d57 -r 624180462cb2 gcc/testsuite/lib/gnat.exp
--- a/gcc/testsuite/lib/gnat.exp	Thu Feb 11 23:19:26 2010 +0100
+++ b/gcc/testsuite/lib/gnat.exp	Wed Feb 17 09:03:51 2010 +0100
@@ -1,4 +1,4 @@
-# Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc.
+# Copyright (C) 2006, 2007, 2008, 2009, 2010 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
@@ -83,7 +83,6 @@
     global gluefile wrap_flags
     global gnat_initialized
     global GNAT_UNDER_TEST
-    global GNAT_UNDER_TEST_ORIG
     global TOOL_EXECUTABLE
     global gnat_libgcc_s_path
     global gnat_target_current
@@ -98,7 +97,6 @@
 	} else {
 	    set GNAT_UNDER_TEST "[local_find_gnatmake]"
 	}
-        set GNAT_UNDER_TEST_ORIG "$GNAT_UNDER_TEST"
     }
 
     if ![info exists tmpdir] then {
@@ -129,22 +127,31 @@
     global gluefile wrap_flags
     global srcdir
     global GNAT_UNDER_TEST
-    global GNAT_UNDER_TEST_ORIG
     global TOOL_OPTIONS
     global ld_library_path
     global gnat_libgcc_s_path
     global gnat_target_current
 
-    # If we detect a change of target we need to recompute
-    # the appropriate RTS by calling get_multilibs.
+    # If we detect a change of target, we need to recompute both
+    # 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 gnat_rts_opt "--RTS=[get_multilibs ${TOOL_OPTIONS}]/libada"
+	    set rtsdir "[get_multilibs ${TOOL_OPTIONS}]/libada"
 	} else {
-	    set gnat_rts_opt "--RTS=[get_multilibs]/libada"
+	    set rtsdir "[get_multilibs]/libada"
 	}
-        set GNAT_UNDER_TEST "$GNAT_UNDER_TEST_ORIG $gnat_rts_opt"
+	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"
     }
 
     set ld_library_path ".:${gnat_libgcc_s_path}"
@@ -263,7 +270,13 @@
         }
         if { $file != "" } {
     	set root [file dirname $file]
-    	set CC "$file --GCC=$root/xgcc --GNATBIND=$root/gnatbind --GNATLINK=$root/gnatlink -cargs -B$root -largs --LINK=$root/xgcc -B$root -margs";
+	# Need to pass full --GCC, including multilib flags, to gnatlink,
+	# otherwise gcc from PATH is invoked.
+	set dest [target_info name]
+	set gnatlink_gcc "--GCC=$root/xgcc -B$root [board_info $dest multilib_flags]"
+	# Escape blanks to get them through DejaGnu's exec machinery.
+	regsub -all {\s} "$gnatlink_gcc" {\\&} gnatlink_gcc
+    	set CC "$file --GCC=$root/xgcc --GNATBIND=$root/gnatbind --GNATLINK=$root/gnatlink -cargs -B$root -largs --LINK=$root/xgcc -B$root $gnatlink_gcc -margs";
         } else {
     	set CC [transform gnatmake]
         }


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