[RFA:] Fix gomp testsuite FAILs for non-gomp targets, PR testsuite/25891

Hans-Peter Nilsson hans-peter.nilsson@axis.com
Mon Jan 23 05:41:00 GMT 2006


For a non-gomp non-thread target (where BTW target-libgomp isn't built),
all gomp tests fail with "xgcc: unrecognized option '-pthread'".  Creating
an effective_target_ function (instead of inlining the test in gomp.exp)
enables usage of "{ fopenmp }" as a target specifier in dg.exp tests
should the need arise.  See PR testsuite/25891.

Tested by "make check-gcc 'RUNTESTFLAGS=--target_board=cris-sim gomp.exp'"
for cris-axis-elf (non-gomp, non-thread) and cris-axis-linux-gnu (gomp)
and observing lack of FAILs for cris-axis-elf.

Ok to commit?

:ADDPATCH testsuite gomp:

gcc/testsuite:
	PR testsuite/25891
	* lib/target-supports.exp (check_effective_target_fopenmp): New proc.
	* gcc.dg/gomp/gomp.exp: Return without testing anything if
	check_effective_target_fopenmp returns 0.


Index: gcc.dg/gomp/gomp.exp
===================================================================
--- gcc.dg/gomp/gomp.exp	(revision 110008)
+++ gcc.dg/gomp/gomp.exp	(working copy)
@@ -3,6 +3,10 @@
 # Load support procs.
 load_lib gcc-dg.exp
 
+if ![check_effective_target_fopenmp] {
+  return
+}
+
 # Initialize `dg'.
 dg-init
 
Index: lib/target-supports.exp
===================================================================
--- lib/target-supports.exp	(revision 110008)
+++ lib/target-supports.exp	(working copy)
@@ -468,6 +468,41 @@ proc check_effective_target_tls_runtime 
     return $et_tls_runtime_saved
 }
 
+# Return 1 if compilation with -fopenmp is error-free for trivial
+# code, 0 otherwise.
+
+proc check_effective_target_fopenmp {} {
+    global et_fopenmp_saved
+    global et_fopenmp_target_name
+
+    if { ![info exists et_fopenmp_target_name] } {
+	set et_fopenmp_target_name ""
+    }
+
+    # If the target has changed since we set the cached value, clear it.
+    set current_target [current_target_name]
+    if { $current_target != $et_fopenmp_target_name } {
+	verbose "check_effective_target_fopenmp: `$et_fopenmp_target_name'" 2
+	set et_fopenmp_target_name $current_target
+	if [info exists et_fopenmp_saved] {
+	    verbose "check_effective_target_fopenmp: removing cached result" 2
+	    unset et_fopenmp_saved
+	}
+    }
+
+    if [info exists et_fopenmp_saved] {
+	verbose "check_effective_target_fopenmp: using cached result" 2
+    } else {
+	verbose "check_effective_target_fopenmp: compiling source" 2
+
+	set et_fopenmp_saved [string match "" [get_compiler_messages fopenmp object {
+	    void foo (void) { }
+	} "-fopenmp"]]
+    }
+    verbose "check_effective_target_fopenmp: returning $et_fopenmp_saved" 2
+    return $et_fopenmp_saved
+}
+
 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
 # emitted, 0 otherwise.  Whether a shared library can actually be built is
 # out of scope for this test.



More information about the Gcc-patches mailing list