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, testsuite] Fix PASS->UNSUPPORTED on g++.dg/tls/static-1.C


The patch in http://gcc.gnu.org/ml/gcc-patches/2006-09/msg00763.html
introduced the above transition.

The problem is that ${tool}_target_compile compiles not only the
SOURCE file that is passed to it but also files mentioned in
dg-additional-source.  It finds these and the files in
dg-additional-file relative to SOURCE.  When running feature tests in
target-supports.exp SOURCE is generated and resides in the testsuite
directory so additional files are not found.

My patch derives a new function ${tool}_target_compile_file that
clears the value of dg-additional-* temporarily before calling
${tool}_target_compile.

Tested on x86_64-unknown-linux-gnu and mipsisa64-elf.

OK for mainline and release branches?

Adam

	* testsuite/lib/target-supports.exp (${tool}_target_compile_file):
	New function.
	(get_compiler_messages, check_alias_available,
	check_gc_sections_available, check_effective_target_tls,
	check_effective_target_tls_runtime,
	check_effective_target_fstack_protector, check_iconv_available,
	check_effective_target_fortran_large_real,
	check_effective_target_fortran_large_int,
	check_effective_target_static_libgfortran, check_vmx_hw_available,
	check_effective_target_broken_cplxf_arg,
	check_alpha_max_hw_available, check_function_available,
	check_cxa_atexit_available, check_effective_target_dfprt_nocache):
	Use it instead of ${tool}_target_compile.

Index: lib/target-supports.exp
===================================================================
--- lib/target-supports.exp	(revision 124848)
+++ lib/target-supports.exp	(working copy)
@@ -20,6 +20,37 @@
 
 # This file defines procs for determining features supported by the target.
 
+# Derive a variant of ${tool}_target_comile_file which does not
+# include files from dg-additional-sources and dg-additional-files.
+# This should be used with generated files in target tests.
+# Additional files are assumed to be next to the SOURCE which is not
+# the case for generated files.
+proc ${tool}_target_compile_file { source dest type options } {
+    global tool
+    global additional_sources
+    global additional_files
+
+    if [info exists additional_sources] {
+	set orig_sources $additional_sources
+	set additional_sources ""
+    }
+    if [info exists additional_files] {
+	set orig_files $additional_files
+	set additional_files ""
+    }
+
+    set r [${tool}_target_compile $source $dest $type $options]
+
+    if [info exists orig_sources] {
+	set additional_sources $orig_sources
+    }
+    if [info exists orig_files] {
+	set additional_files $orig_files
+    }
+
+    return $r
+}
+
 # Try to compile some code and return the messages printed by the compiler,
 # and optionally the contents for assembly files.  Either a string or
 # a list of two strings are returned, depending on WANT_OUTPUT.
@@ -50,7 +81,7 @@ proc get_compiler_messages {basename wan
     set f [open $src "w"]
     puts $f $contents
     close $f
-    set lines [${tool}_target_compile $src $output $type "$options"]
+    set lines [${tool}_target_compile_file $src $output $type "$options"]
     file delete $src
 
     if { $want_output } {
@@ -236,7 +267,7 @@ proc check_alias_available { } {
 	puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
 	puts $f "void g() {} void f() __attribute__((alias(\"g\")));"
 	close $f
-	set lines [${tool}_target_compile $src $obj object ""]
+	set lines [${tool}_target_compile_file $src $obj object ""]
 	file delete $src
 	remote_file build delete $obj
 
@@ -303,9 +334,10 @@ proc check_gc_sections_available { } {
 	}
 
 	# Check if the ld used by gcc supports --gc-sections.
-	set gcc_spec [${tool}_target_compile "-dumpspecs" "" "none" ""]
+	set gcc_spec [${tool}_target_compile_file "-dumpspecs" "" "none" ""]
 	regsub ".*\n\*linker:\[ \t\]*\n(\[^ \t\n\]*).*" "$gcc_spec" {\1} linker
-	set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=$linker" "" "none" ""] 0]
+	set gcc_ld [lindex [${tool}_target_compile_file \
+				"-print-prog-name=$linker" "" "none" ""] 0]
 	set ld_output [remote_exec host "$gcc_ld" "--help"]
 	if { [ string first "--gc-sections" $ld_output ] >= 0 } {
 	    set gc_sections_available_saved 1
@@ -432,7 +464,7 @@ proc check_effective_target_tls {} {
 	close $f
 
 	# Test for thread-local data supported by the platform.
-	set comp_output [${tool}_target_compile $src $asm assembly ""]
+	set comp_output [${tool}_target_compile_file $src $asm assembly ""]
 	file delete $src
 	if { [string match "*not supported*" $comp_output] } {
 	    set et_tls_saved 0
@@ -475,7 +507,7 @@ proc check_effective_target_tls_runtime 
 	close $f
 
 	set comp_output \
-	    [${tool}_target_compile $src $exe executable ""]
+	    [${tool}_target_compile_file $src $exe executable ""]
 	file delete $src
 
 	if [string match "" $comp_output] then {
@@ -523,7 +555,7 @@ proc check_effective_target_fstack_prote
     close $f
 
     set opts "additional_flags=-fstack-protector"
-    set lines [${tool}_target_compile $src $exe executable "$opts" ]
+    set lines [${tool}_target_compile_file $src $exe executable "$opts" ]
     file delete $src
 
     if [string match "" $lines] then {
@@ -620,7 +652,8 @@ proc check_iconv_available { test_what }
     if { ![info exists libiconv] } {
 	set libiconv "-liconv"
     }
-    set lines [${tool}_target_compile $src $exe executable "libs=$libiconv" ]
+    set lines \
+	[${tool}_target_compile_file $src $exe executable "libs=$libiconv" ]
     file delete $src
 
     if [string match "" $lines] then {
@@ -693,7 +726,7 @@ proc check_effective_target_fortran_larg
 	close $f
 
 	verbose "check_effective_target_fortran_large_real compiling testfile $src" 2
-	set lines [${tool}_target_compile $src $exe executable ""]
+	set lines [${tool}_target_compile_file $src $exe executable ""]
 	file delete $src
 
 	if [string match "" $lines] then {
@@ -750,7 +783,7 @@ proc check_effective_target_fortran_larg
 	close $f
 
 	verbose "check_effective_target_fortran_large_int compiling testfile $src" 2
-	set lines [${tool}_target_compile $src $exe executable ""]
+	set lines [${tool}_target_compile_file $src $exe executable ""]
 	file delete $src
 
 	if [string match "" $lines] then {
@@ -805,7 +838,7 @@ proc check_effective_target_static_libgf
        close $f
 
        verbose "check_effective_target_static_libgfortran compiling testfile $src" 2
-       set lines [${tool}_target_compile $src $exe executable "$opts"]
+       set lines [${tool}_target_compile_file $src $exe executable "$opts"]
        file delete $src
 
        if [string match "" $lines] then {
@@ -862,7 +895,7 @@ proc check_vmx_hw_available { } {
 	}
 
 	verbose "check_vmx_hw_available  compiling testfile $src" 2
-	set lines [${tool}_target_compile $src $exe executable "$opts"]
+	set lines [${tool}_target_compile_file $src $exe executable "$opts"]
 	file delete $src
 
 	if [string match "" $lines] then {
@@ -948,7 +981,7 @@ proc check_effective_target_broken_cplxf
 	puts $f "}"
 	close $f
 
-	set lines [${tool}_target_compile $src $exe executable "-lm"]
+	set lines [${tool}_target_compile_file $src $exe executable "-lm"]
 	file delete $src
 
 	if [string match "" $lines] {
@@ -988,7 +1021,7 @@ proc check_alpha_max_hw_available { } {
 	close $f
 
 	verbose "check_alpha_max_hw_available compiling testfile $src" 2
-	set lines [${tool}_target_compile $src $exe executable ""]
+	set lines [${tool}_target_compile_file $src $exe executable ""]
 	file delete $src
 
 	if [string match "" $lines] then {
@@ -1031,7 +1064,7 @@ proc check_function_available { function
 	puts $f "int main () { $function (); }"
 	close $f
 
-	set lines [${tool}_target_compile $src $exe executable ""]
+	set lines [${tool}_target_compile_file $src $exe executable ""]
 	file delete $src
 	file delete $exe
 
@@ -1131,7 +1164,7 @@ proc check_cxa_atexit_available { } {
 	puts $f "{ return 0; }"
 	close $f
 
-	set lines [${tool}_target_compile $src $exe executable ""]
+	set lines [${tool}_target_compile_file $src $exe executable ""]
 	file delete $src
 
 	if [string match "" $lines] {
@@ -1250,7 +1283,7 @@ proc check_effective_target_dfprt_nocach
     close $f
 
     verbose "check_effective_target_dfprt_nocache: compiling testfile $src" 2
-    set lines [${tool}_target_compile $src $exe executable ""]
+    set lines [${tool}_target_compile_file $src $exe executable ""]
     file delete $src
 
     if [string match "" $lines] then {


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