Patchwork [libitm,build] Clear hardware capabilities on with Sun ld

mail settings
Submitter Rainer Orth
Date Jan. 16, 2012, 4:36 p.m.
Message ID <ydd4nvv7gg6.fsf@manam.CeBiTec.Uni-Bielefeld.DE>
Download mbox | patch
Permalink /patch/136310/
State New
Headers show


Rainer Orth - Jan. 16, 2012, 4:36 p.m.
Richard Henderson <> writes:

> On 11/21/2011 09:23 AM, Rainer Orth wrote:
>> Richard Henderson <> writes:
>>> This is only ok if the compiler and library are build with default options.
>>> If you use --with-arch=corei7-avx then we may well use AVX insns all through
>>> the library, not just in the one interface that will only be used if the 
>>> user of the library is using avx.
>>> Can you auto-foo this based on CC+CFLAGS?  E.g.  compile-time tests for the
>>> various __SSE__ / __AVX__ macros?
>> Probably, but it occured to me that it might be easier to just apply the
>> mapfile to x86_avx.o unconditionally before linking
> Possibly.  Though you'd want to do the same thing for x86_sse.o too.
> Again, that file is only used if the main program uses SSE.

The ld -r route for x86_avx.o has failed completely due to several
libtool bugs, so I'm back to your suggestion.  I didn't check for
__SSE__, though: Solaris 10 is the first release where both as and ld
have hwcap support, and it requires SSE-capable hardware to run.

The following patch has been bootstrapped without regressions on
i386-pc-solaris2.11 with as/ld, gas/ld, and gas/gld and fixes the
hwcap-related execution failures in the first case.  Besides, I've
configured libitm with CFLAGS='-g -O2 -mavx' and verified that
LDFLAGS_HWCAP is cleared/not applied in this case.

I've kept the LIBITM_CHECK_LINKER_HWCAP test and the __AVX__ check
separate since the former is generic (with the exception of the mapfile
name), while the latter is strictly libitm-specific.

Ok for mainline?


2011-11-18  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	* New file.
	* acinclude.m4 (LIBITM_CHECK_LINKER_HWCAP): New test.
	* Call it.
	Clear HWCAP_LDFLAGS if defaulting to -mavx.
	* configure: Regenerate.
	* Regenerate.
	* testsuite/ Regenerate.
Richard Henderson - Jan. 23, 2012, 12:44 a.m.
On 01/17/2012 03:36 AM, Rainer Orth wrote:
> 2011-11-18  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
> 	* New file.
> 	* acinclude.m4 (LIBITM_CHECK_LINKER_HWCAP): New test.
> 	* Call it.
> 	Clear HWCAP_LDFLAGS if defaulting to -mavx.
> 	* configure: Regenerate.
> 	* Regenerate.
> 	* testsuite/ Regenerate.




# HG changeset patch
# Parent 645b88e3e02144a637127f3a7c4842ef8afb2bcb
Clear hardware capabilities on with Sun ld

diff --git a/libitm/ b/libitm/
--- a/libitm/
+++ b/libitm/
@@ -21,7 +21,7 @@  AM_CFLAGS = $(XCFLAGS)
 AM_CXXFLAGS = $(XCFLAGS) -std=gnu++0x -funwind-tables -fno-exceptions \
 	-fno-rtti $(abi_version)
 toolexeclib_LTLIBRARIES =
 nodist_toolexeclib_HEADERS = libitm.spec
diff --git a/libitm/acinclude.m4 b/libitm/acinclude.m4
--- a/libitm/acinclude.m4
+++ b/libitm/acinclude.m4
+dnl Check if the linker used supports linker maps to clear hardware
+dnl capabilities.  This is only supported by Sun ld at the moment.
+dnl Defines:
+dnl  HWCAP_LDFLAGS='-Wl,-M,' if possible
+dnl  LD (as a side effect of testing)
+  ac_save_LDFLAGS="$LDFLAGS"
+  LDFLAGS="$LFLAGS -Wl,-M,$srcdir/"
+  AC_MSG_CHECKING([for ld that supports -Wl,-M,mapfile])
+  AC_TRY_LINK([], [return 0;], [ac_hwcap_ldflags=yes],[ac_hwcap_ldflags=no])
+  if test "$ac_hwcap_ldflags" = "yes"; then
+  fi
+  AC_MSG_RESULT($ac_hwcap_ldflags)
+  LDFLAGS="$ac_save_LDFLAGS"
+  AM_CONDITIONAL(HAVE_HWCAP, test $ac_hwcap_ldflags != no)
 dnl Add version tags to symbols in shared library (or not), additionally
 dnl marking other symbols as private/local (or not).
diff --git a/libitm/ b/libitm/
new file mode 100644
--- /dev/null
+++ b/libitm/
@@ -0,0 +1,14 @@ 
+# Clear hardware capabilities emitted by Sun as: calls to the x86_avx.c
+# functions are only emitted with -mavx.
+# The v1 mapfile syntax has no support for clearing specific capabilities,
+# so clear everything.
+hwcap_1 = V0x0 OVERRIDE;
+# If we can assume mapfile v2 syntax, we can specificially clear AVX.
+#$mapfile_version 2
+#	HW -= AVX;
diff --git a/libitm/ b/libitm/
--- a/libitm/
+++ b/libitm/
@@ -1,5 +1,5 @@ 
 # Process this file with autoreconf to produce a configure script.
-#   Copyright (C) 2011 Free Software Foundation, Inc.
+#   Copyright (C) 2011, 2012 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
@@ -208,12 +208,17 @@  GCC_LINUX_FUTEX(:)
 # See if we support thread-local storage.
-# See what sort of export controls are availible.
+# See what sort of export controls are available.
+# Check linker hardware capability support.
+# If defaulting to -mavx, don't clear hwcaps.
 if test $enable_symvers = gnu; then
 	    [Define to 1 if GNU symbol versioning is used for libitm.])