[testsuite] Clear hwcap_2 with Sun ld

Message ID yddd34vcq2b.fsf@manam.CeBiTec.Uni-Bielefeld.DE
State New
Headers show

Commit Message

Rainer Orth June 19, 2012, 2:51 p.m.
In recent Solaris 11 Update 1 builds, the Sun assembler tags AVX2 object
files with a hardware capability that isn't cleared by the current
gcc/testsuite/gcc.target/i386/clearcap.map file.  There are some new
capabilities in <sys/auxv_386.h> in AT_SUN_CAP_HW2, but unfortunately
the old linker map syntax has no support for setting/clearing hwcap_2,
and won't ever get it.

To deal with this situation, I've introduced a new mapfile using the v2
syntax which does support clearing hwcap_2, but now I need to determine
if the linker supports that syntax before using it.  Solaris 11 ld has
the necessary support, and it was backported to Solaris 10 Update 10.
Older Solaris 10 updates and Solaris 8/9 lack it, though.

The following patch does just that.  Tested with the appropriate runtest
invocation on i386-pc-solaris2.11 (ld v2 support), i386-pc-solaris2.9
(ld v1 support only), and x86_64-unknown-linux-gnu (GNU ld which doesn't
support either syntax).

Unless someone finds fault with the patch, I'll commit it in a day.


2012-06-19  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	* gcc.target/i386/clearcapv2.map: New file.
	* gcc.target/i386/i386.exp: Try it first before clearcap.map.


# HG changeset patch
# Parent 02789d700fe014df8358c45b8dc09a6b104fbb6b
Clear hwcap_2 with Sun ld

diff --git a/gcc/testsuite/gcc.target/i386/clearcapv2.map b/gcc/testsuite/gcc.target/i386/clearcapv2.map
new file mode 100644
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/clearcapv2.map
@@ -0,0 +1,7 @@ 
+# clear all hardware capabilities emitted by Sun as: the tests here
+# guard against execution at runtime
+# uses mapfile v2 syntax which is the only way to clear AT_SUN_CAP_HW2 flags
+$mapfile_version 2
+  HW = ;
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
@@ -256,12 +256,23 @@  proc check_effective_target_rtm { } {
 # If the linker used understands -M <mapfile>, pass it to clear hardware
 # capabilities set by the Sun assembler.
-set clearcap_ldflags "-Wl,-M,$srcdir/$subdir/clearcap.map"
+# 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 mapfile executable {
+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 ] {
+    } $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