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]

[testsuite] Centralise clearing hardware capabilities with Sun ld


Prompted by the recent failures of c-c++-common/gomp/pr60823-2.c on
Solaris/x86 with Sun as

	http://gcc.gnu.org/ml/gcc-patches/2014-05/msg00943.html

I've reworked the clearing of hardware capabilities via linker maps for
Sun ld, which is currently replicated in several places all over the
testsuite.  I've chosen to use TEST_ALWAYS_FLAGS or ALWAYS_CXXFLAGS to
pass on the necessary linker flags.

Initial testing on i386-pc-solaris2.11 (just the affected .exp files)
was successful, full bootstraps on i386-pc-solaris2.10 (as/ld, gas/gld),
sparc-sun-solaris2.11, and x86_64-unknown-linux-gnu in progress.

Will commit to mainline once testing completed, backport to the 4.9
branch which is also affected later on.

	Rainer


2014-05-13  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	* lib/clearcap.exp: New file.
	* gcc.dg/gomp/gomp.exp: Load clearcap.exp.
	Call clearcap-init, clearcap-finish.
	* g++.dg/gomp/gomp.exp: Likewise
	* gcc.dg/vect/vect.exp: Load clearcap.exp.
	Remove clearcap_ldflags handling.
	Call clearcap-init, clearcap-finish.
	* gcc.target/i386/i386.exp: Likewise.
	* gcc.target/x86_64/abi/avx/abi-avx.exp: Likewise.
	* gcc.target/x86_64/abi/avx512f/abi-avx512f.exp: Likewise.

# HG changeset patch
# Parent 5d86fdfa234897877ba6e3a30076efeb52220a53
Centralise clearing hardware capabilities with Sun ld

diff --git a/gcc/testsuite/g++.dg/gomp/gomp.exp b/gcc/testsuite/g++.dg/gomp/gomp.exp
--- a/gcc/testsuite/g++.dg/gomp/gomp.exp
+++ b/gcc/testsuite/g++.dg/gomp/gomp.exp
@@ -18,6 +18,7 @@
 
 # Load support procs.
 load_lib g++-dg.exp
+load_lib clearcap.exp
 
 if ![check_effective_target_fopenmp] {
   return
@@ -25,6 +26,7 @@ if ![check_effective_target_fopenmp] {
 
 # Initialize `dg'.
 dg-init
+clearcap-init
 
 # Main loop.
 g++-dg-runtest [lsort [concat \
@@ -32,4 +34,5 @@ g++-dg-runtest [lsort [concat \
 	[find $srcdir/c-c++-common/gomp *.c]]] "-fopenmp"
 
 # All done.
+clearcap-finish
 dg-finish
diff --git a/gcc/testsuite/gcc.dg/gomp/gomp.exp b/gcc/testsuite/gcc.dg/gomp/gomp.exp
--- a/gcc/testsuite/gcc.dg/gomp/gomp.exp
+++ b/gcc/testsuite/gcc.dg/gomp/gomp.exp
@@ -20,6 +20,7 @@
 
 # Load support procs.
 load_lib gcc-dg.exp
+load_lib clearcap.exp
 
 if ![check_effective_target_fopenmp] {
   return
@@ -27,6 +28,7 @@ if ![check_effective_target_fopenmp] {
 
 # Initialize `dg'.
 dg-init
+clearcap-init
 
 # Main loop.
 dg-runtest [lsort [concat \
@@ -34,4 +36,5 @@ dg-runtest [lsort [concat \
 	[find $srcdir/c-c++-common/gomp *.c]]] "" "-fopenmp"
 
 # All done.
+clearcap-finish
 dg-finish
diff --git a/gcc/testsuite/gcc.dg/vect/vect.exp b/gcc/testsuite/gcc.dg/vect/vect.exp
--- a/gcc/testsuite/gcc.dg/vect/vect.exp
+++ b/gcc/testsuite/gcc.dg/vect/vect.exp
@@ -18,6 +18,7 @@
 
 # Load support procs.
 load_lib gcc-dg.exp
+load_lib clearcap.exp
 
 # Set up flags used for tests that don't specify options.
 global DEFAULT_VECTCFLAGS
@@ -41,30 +42,9 @@ if ![check_vect_support_and_set_flags] {
 # These flags are used for all targets.
 lappend DEFAULT_VECTCFLAGS "-ftree-vectorize" "-fno-vect-cost-model" "-fno-common"
 
-# If the linker used understands -M <mapfile>, pass it to clear hardware
-# capabilities set by the Sun assembler.
-# Try mapfile syntax v2 first which is the only way to clear hwcap_2 flags.
-set clearcap_ldflags "-Wl,-M,$srcdir/gcc.target/i386/clearcapv2.map"
-
-if ![check_no_compiler_messages mapfilev2 executable {
-    int main (void) { return 0; }
-} $clearcap_ldflags ] {
-    # If this doesn't work, fall back to the less capable v1 syntax.
-    set clearcap_ldflags "-Wl,-M,$srcdir/gcc.target/i386/clearcap.map"
-
-    if ![check_no_compiler_messages mapfile executable {
-	int main (void) { return 0; }
-    } $clearcap_ldflags ] {
-	unset clearcap_ldflags
-    }
-}
-
-if [info exists clearcap_ldflags] {
-    lappend DEFAULT_VECTCFLAGS $clearcap_ldflags
-}
-
 # Initialize `dg'.
 dg-init
+clearcap-init
 
 global VEC_FLAGS
 set VEC_FLAGS $DEFAULT_VECTCFLAGS
@@ -308,4 +288,5 @@ dg-runtest [lsort [glob -nocomplain $src
 set dg-do-what-default ${save-dg-do-what-default}
 
 # All done.
+clearcap-finish
 dg-finish
diff --git a/gcc/testsuite/gcc.target/i386/i386.exp b/gcc/testsuite/gcc.target/i386/i386.exp
--- a/gcc/testsuite/gcc.target/i386/i386.exp
+++ b/gcc/testsuite/gcc.target/i386/i386.exp
@@ -23,6 +23,7 @@ if { ![istarget i?86*-*-*] && ![istarget
 
 # Load support procs.
 load_lib gcc-dg.exp
+load_lib clearcap.exp
 
 # Return 1 if attribute ms_hook_prologue is supported.
 proc check_effective_target_ms_hook_prologue { } {
@@ -307,39 +308,6 @@ proc check_effective_target_sha { } {
     } "-O2 -msha" ]
 }
 
-# If the linker used understands -M <mapfile>, pass it to clear hardware
-# capabilities set by the Sun assembler.
-# Try mapfile syntax v2 first which is the only way to clear hwcap_2 flags.
-set clearcap_ldflags "-Wl,-M,$srcdir/$subdir/clearcapv2.map"
-
-if ![check_no_compiler_messages mapfilev2 executable {
-    int main (void) { return 0; }
-} $clearcap_ldflags ] {
-    # If this doesn't work, fall back to the less capable v1 syntax.
-    set clearcap_ldflags "-Wl,-M,$srcdir/$subdir/clearcap.map"
-
-    if ![check_no_compiler_messages mapfile executable {
-	int main (void) { return 0; }
-    } $clearcap_ldflags ] {
-	unset clearcap_ldflags
-    }
-}
-
-if [info exists clearcap_ldflags] {
-  if { [info procs gcc_target_compile] != [list] \
-	&& [info procs saved_gcc_target_compile] == [list] } {
-    rename gcc_target_compile saved_gcc_target_compile
-
-    proc gcc_target_compile { source dest type options } {
-      global clearcap_ldflags
-      # Always pass -Wl,-M,<mapfile>, but don't let it show up in gcc.sum.
-      lappend options "additional_flags=$clearcap_ldflags"
-
-      return [saved_gcc_target_compile $source $dest $type $options]
-    }
-  }
-}
-
 # If a testcase doesn't have special options, use these.
 global DEFAULT_CFLAGS
 if ![info exists DEFAULT_CFLAGS] then {
@@ -348,6 +316,7 @@ if ![info exists DEFAULT_CFLAGS] then {
 
 # Initialize `dg'.
 dg-init
+clearcap-init
 
 # Special case compilation of vect-args.c so we don't have to
 # replicate it 10 times.
@@ -367,4 +336,5 @@ set tests [prune $tests $srcdir/$subdir/
 dg-runtest $tests "" $DEFAULT_CFLAGS
 
 # All done.
+clearcap-finish
 dg-finish
diff --git a/gcc/testsuite/gcc.target/x86_64/abi/avx/abi-avx.exp b/gcc/testsuite/gcc.target/x86_64/abi/avx/abi-avx.exp
--- a/gcc/testsuite/gcc.target/x86_64/abi/avx/abi-avx.exp
+++ b/gcc/testsuite/gcc.target/x86_64/abi/avx/abi-avx.exp
@@ -20,6 +20,7 @@
 load_lib c-torture.exp
 load_lib target-supports.exp
 load_lib torture-options.exp
+load_lib clearcap.exp
 
 if { (![istarget x86_64-*-*] && ![istarget i?86-*-*])
      || ![is-effective-target lp64]
@@ -28,20 +29,10 @@ if { (![istarget x86_64-*-*] && ![istarg
 }
 
 
-# If the linker used understands -M <mapfile>, pass it to clear hardware
-# capabilities set by the Sun assembler.
-set flags ""
-set clearcap_ldflags "-Wl,-M,$srcdir/gcc.target/i386/clearcap.map"
-
-if [check_no_compiler_messages mapfile executable {
-	int main (void) { return 0; }
-  } $clearcap_ldflags ] {
-  set flags $clearcap_ldflags
-}
-
 torture-init
+clearcap-init
 set-torture-options $C_TORTURE_OPTIONS
-set additional_flags "-W -Wall -mavx $flags"
+set additional_flags "-W -Wall -mavx"
 
 foreach src [lsort [glob -nocomplain $srcdir/$subdir/test_*.c]] {
     if {[runtest_file_p $runtests $src]} {
@@ -58,4 +49,5 @@ foreach src [lsort [glob -nocomplain $sr
     }
 }
 
+clearcap-finish
 torture-finish
diff --git a/gcc/testsuite/gcc.target/x86_64/abi/avx512f/abi-avx512f.exp b/gcc/testsuite/gcc.target/x86_64/abi/avx512f/abi-avx512f.exp
--- a/gcc/testsuite/gcc.target/x86_64/abi/avx512f/abi-avx512f.exp
+++ b/gcc/testsuite/gcc.target/x86_64/abi/avx512f/abi-avx512f.exp
@@ -20,6 +20,7 @@
 load_lib c-torture.exp
 load_lib target-supports.exp
 load_lib torture-options.exp
+load_lib clearcap.exp
 
 if { (![istarget x86_64-*-*] && ![istarget i?86-*-*])
      || ![is-effective-target lp64]
@@ -28,20 +29,10 @@ if { (![istarget x86_64-*-*] && ![istarg
 }
 
 
-# If the linker used understands -M <mapfile>, pass it to clear hardware
-# capabilities set by the Sun assembler.
-set flags ""
-set clearcap_ldflags "-Wl,-M,$srcdir/gcc.target/i386/clearcap.map"
-
-if [check_no_compiler_messages mapfile executable {
-	int main (void) { return 0; }
-  } $clearcap_ldflags ] {
-  set flags $clearcap_ldflags
-}
-
 torture-init
+clearcap-init
 set-torture-options $C_TORTURE_OPTIONS
-set additional_flags "-W -Wall -mavx512f $flags"
+set additional_flags "-W -Wall -mavx512f"
 
 foreach src [lsort [glob -nocomplain $srcdir/$subdir/test_*.c]] {
     if {[runtest_file_p $runtests $src]} {
@@ -58,4 +49,5 @@ foreach src [lsort [glob -nocomplain $sr
     }
 }
 
+clearcap-finish
 torture-finish
diff --git a/gcc/testsuite/lib/clearcap.exp b/gcc/testsuite/lib/clearcap.exp
new file mode 100644
--- /dev/null
+++ b/gcc/testsuite/lib/clearcap.exp
@@ -0,0 +1,71 @@
+# Copyright (C) 2014 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/>.
+
+# If the linker used understands -M <mapfile>, pass it to clear hardware
+# capabilities set by the Sun assembler.
+# Try mapfile syntax v2 first which is the only way to clear hwcap_2 flags.
+set clearcap_ldflags "-Wl,-M,$srcdir/gcc.target/i386/clearcapv2.map"
+
+if ![check_no_compiler_messages mapfilev2 executable {
+    int main (void) { return 0; }
+} $clearcap_ldflags ] {
+    # If this doesn't work, fall back to the less capable v1 syntax.
+    set clearcap_ldflags "-Wl,-M,$srcdir/gcc.target/i386/clearcap.map"
+
+    if ![check_no_compiler_messages mapfile executable {
+	int main (void) { return 0; }
+    } $clearcap_ldflags ] {
+	unset clearcap_ldflags
+    }
+}
+
+#
+# clearcap-init -- called at the start of each subdir of tests
+#
+
+proc clearcap-init { args } {
+    global TEST_ALWAYS_FLAGS
+    global ALWAYS_CXXFLAGS
+    global clearcap_saved_TEST_ALWAYS_FLAGS
+    global clearcap_ldflags
+
+    if [info exists TEST_ALWAYS_FLAGS] {
+	set clearcap_saved_TEST_ALWAYS_FLAGS $TEST_ALWAYS_FLAGS
+    }
+    if [info exists clearcap_ldflags] {
+	if [info exists ALWAYS_CXXFLAGS] {
+	    set ALWAYS_CXXFLAGS [concat "{ldflags=$clearcap_ldflags}" $ALWAYS_CXXFLAGS]
+	} else {
+	    append TEST_ALWAYS_FLAGS " $clearcap_ldflags"
+	}
+    }
+    return 0
+}
+
+#
+# clearcap-finish -- called at the start of each subdir of tests
+#
+
+proc clearcap-finish { args } {
+    global TEST_ALWAYS_FLAGS
+    global clearcap_saved_TEST_ALWAYS_FLAGS
+
+    if [info exists clearcap_saved_TEST_ALWAYS_FLAGS] {
+	set TEST_ALWAYS_FLAGS $clearcap_saved_TEST_ALWAYS_FLAGS
+    } else {
+	unset TEST_ALWAYS_FLAGS
+    }
+}
-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

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