The libitm execution tests are currently failing on Solaris 10 and up with Sun as/ld:
ld.so.1: cancel.exe: fatal: /var/gcc/regression/trunk/11-gcc/build/i386-pc-solaris2.11/./libitm/.libs/libitm.so.0: hardware capability (CA_SUNW_HW_1) unsupported: 0x20000000 [ AVX ] FAIL: libitm.c/cancel.c execution test This is the same issue solved by gcc/testsuite/gcc.target/i386/clearcap.map, and the following patch adresses it in the same way: * Detect if the linker used supports -M <map file>. * Use it when linking libitm.so. Right now, it is only possible to clear the hardware capabilities completely, while the new v2 mapfile syntax supports selectively adding and removing capabilities. It is only available in Solaris 11 and Solaris 10 Update 10, though, so I'm restricting us to the v1 syntax for now. It may make sense to move the test to toplevel config/ld-hwcap.m4 later, but for now libitm is the only user. Bootstrapped on i386-pc-solaris2.11 with Sun as/ld, gas/Sun ld, and gas/gld, on i386-pc-solaris2.8 to make sure it doesn't break the build with the old linker there, and on x86_64-unknown-linux-gnu. Ok for mainline? Rainer 2011-11-18 Rainer Orth <r...@cebitec.uni-bielefeld.de> * clearcap.map: New file. * acinclude.m4 (LIBITM_CHECK_LINKER_HWCAP): New test. * configure.ac: Call it. * Makefile.am (AM_LDFLAGS): Add $(HWCAP_LDFLAGS) * configure: Regenerate. * Makefile.in: Regenerate. * testsuite/Makefile.in: Regenerate.
# HG changeset patch # Parent fe631cce39f95ae2f718499a8e82260c18149752 Clear hardware capabilities on libitm.so with Sun ld diff --git a/libitm/Makefile.am b/libitm/Makefile.am --- a/libitm/Makefile.am +++ b/libitm/Makefile.am @@ -21,7 +21,7 @@ AM_CFLAGS = $(XCFLAGS) AM_CXXFLAGS = -std=gnu++0x -funwind-tables -fno-exceptions -fno-rtti \ $(XCFLAGS) $(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 diff --git a/libitm/acinclude.m4 b/libitm/acinclude.m4 --- a/libitm/acinclude.m4 +++ b/libitm/acinclude.m4 @@ -256,6 +256,34 @@ 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) +]) + + +dnl dnl Add version tags to symbols in shared library (or not), additionally dnl marking other symbols as private/local (or not). dnl diff --git a/libitm/clearcap.map b/libitm/clearcap.map new file mode 100644 --- /dev/null +++ b/libitm/clearcap.map @@ -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; +#}; diff --git a/libitm/configure.ac b/libitm/configure.ac --- a/libitm/configure.ac +++ b/libitm/configure.ac @@ -208,10 +208,11 @@ 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 +LIBITM_CHECK_LINKER_HWCAP LIBITM_ENABLE_SYMVERS if test $enable_symvers = gnu; then
-- ----------------------------------------------------------------------------- Rainer Orth, Center for Biotechnology, Bielefeld University