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: Clear hardware capabilities from gcc.target/i386 executables with Sun ld


Running the testsuite on Solaris 11/x86 after bootstrapping with Sun as
and Sun ld revealed many testsuite failures in gcc.target/i386:

ld.so.1: aesdec.exe: fatal: hardware capability unsupported: 0x4000000  [ AES ]
FAIL: gcc.target/i386/aesdec.c execution test

This happens because the Sun assembler encodes the instruction set
extensions used by the code as hardware capabilities in the object and
executable files to avoid trying to execute such code on platforms where
the hardware doesn't support the extension.

In the testsuite cases, this isn't a problem because it is guarded
against at runtime.

To avoid it if using the Sun linker, one can pass a mapfile which clears
all automatically created hardware capabilities from the resulting
executable.

The following patch does just that and allows all the affected testcases
to pass.  It also survived a bootstrap with GNU ld, which doesn't
support such mapfiles, to make sure they aren't broken.

Ok for mainline?

	Rainer

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


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

	* gcc.target/i386/clearcap.map: New file.
	* gcc.target/i386/i386.exp: Check for linker -M mapfile support.
	Pass clearcap.map by default if supported.

diff -r 85c2ff670d5b -r 2a01c32807cb gcc/testsuite/gcc.target/i386/clearcap.map
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gcc/testsuite/gcc.target/i386/clearcap.map	Thu Feb 11 23:19:26 2010 +0100
@@ -0,0 +1,3 @@
+# clear all hardware capabilities emitted by Sun as: the tests here
+# guard against execution at runtime
+hwcap_1 = V0x0 OVERRIDE;
diff -r 85c2ff670d5b -r 2a01c32807cb gcc/testsuite/gcc.target/i386/i386.exp
--- a/gcc/testsuite/gcc.target/i386/i386.exp	Thu Feb 11 23:19:25 2010 +0100
+++ b/gcc/testsuite/gcc.target/i386/i386.exp	Thu Feb 11 23:19:26 2010 +0100
@@ -1,4 +1,5 @@
-# Copyright (C) 1997, 2004, 2007, 2008, 2009 Free Software Foundation, Inc.
+# Copyright (C) 1997, 2004, 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
@@ -160,6 +161,17 @@
     } "-O2 -mxop" ]
 }
 
+# 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/$subdir/clearcap.map"
+
+if [check_no_compiler_messages mapfile executable {
+	int main (void) { return 0; }
+  } $clearcap_ldflags ] {
+  set FLAGS $clearcap_ldflags
+}
+
 # If a testcase doesn't have special options, use these.
 global DEFAULT_CFLAGS
 if ![info exists DEFAULT_CFLAGS] then {
@@ -184,7 +196,7 @@
 set tests [prune $tests $srcdir/$subdir/vect-args.c]
 
 # Main loop.
-dg-runtest $tests "" $DEFAULT_CFLAGS
+dg-runtest $tests $FLAGS $DEFAULT_CFLAGS
 
 # All done.
 dg-finish


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