# HG changeset patch
# Parent 645b88e3e02144a637127f3a7c4842ef8afb2bcb
Clear hardware capabilities on libitm.so with Sun ld
@@ -21,7 +21,7 @@ AM_CFLAGS = $(XCFLAGS)
AM_CXXFLAGS = $(XCFLAGS) -std=gnu++0x -funwind-tables -fno-exceptions \
-fno-rtti $(abi_version)
AM_CCASFLAGS = $(XCFLAGS)
-AM_LDFLAGS = $(XLDFLAGS) $(SECTION_LDFLAGS) $(OPT_LDFLAGS)
+AM_LDFLAGS = $(XLDFLAGS) $(SECTION_LDFLAGS) $(OPT_LDFLAGS) $(HWCAP_LDFLAGS)
toolexeclib_LTLIBRARIES = libitm.la
nodist_toolexeclib_HEADERS = libitm.spec
@@ -261,6 +261,36 @@ AC_DEFUN([LIBITM_CHECK_LINKER_FEATURES],
dnl
+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
+dnl Defines:
+dnl HWCAP_LDFLAGS='-Wl,-M,clearcap.map' if possible
+dnl LD (as a side effect of testing)
+dnl
+AC_DEFUN([LIBITM_CHECK_LINKER_HWCAP], [
+ test -z "$HWCAP_LDFLAGS" && HWCAP_LDFLAGS=''
+ AC_REQUIRE([AC_PROG_LD])
+
+ ac_save_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LFLAGS -Wl,-M,$srcdir/clearcap.map"
+
+ 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
+ HWCAP_LDFLAGS="-Wl,-M,$srcdir/clearcap.map $HWCAP_LDFLAGS"
+ fi
+ AC_MSG_RESULT($ac_hwcap_ldflags)
+
+ LDFLAGS="$ac_save_LDFLAGS"
+
+ AC_SUBST(HWCAP_LDFLAGS)
+
+ AM_CONDITIONAL(HAVE_HWCAP, test $ac_hwcap_ldflags != no)
+])
+
+
+dnl
dnl Add version tags to symbols in shared library (or not), additionally
dnl marking other symbols as private/local (or not).
dnl
new file mode 100644
@@ -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
+#CAPABILITY {
+# HW -= AVX;
+#};
@@ -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.
GCC_CHECK_TLS
-# See what sort of export controls are availible.
+# See what sort of export controls are available.
LIBITM_CHECK_ATTRIBUTE_VISIBILITY
LIBITM_CHECK_ATTRIBUTE_DLLEXPORT
LIBITM_CHECK_ATTRIBUTE_ALIAS
+
+# Check linker hardware capability support.
+LIBITM_CHECK_LINKER_HWCAP
+# If defaulting to -mavx, don't clear hwcaps.
+AC_CHECK_DECL([__AVX__], [HWCAP_LDFLAGS=''])
+
LIBITM_ENABLE_SYMVERS
-
if test $enable_symvers = gnu; then
AC_DEFINE(LIBITM_GNU_SYMBOL_VERSIONING, 1,
[Define to 1 if GNU symbol versioning is used for libitm.])