From patchwork Mon Nov 21 13:53:33 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rainer Orth X-Patchwork-Id: 126792 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id EB80AB7212 for ; Tue, 22 Nov 2011 00:55:06 +1100 (EST) Received: (qmail 23592 invoked by alias); 21 Nov 2011 13:54:38 -0000 Received: (qmail 23279 invoked by uid 22791); 21 Nov 2011 13:54:28 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from snape.CeBiTec.Uni-Bielefeld.DE (HELO smtp-relay.CeBiTec.Uni-Bielefeld.DE) (129.70.160.84) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 21 Nov 2011 13:53:39 +0000 Received: from localhost (localhost.CeBiTec.Uni-Bielefeld.DE [127.0.0.1]) by smtp-relay.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTP id E8B0FFEA; Mon, 21 Nov 2011 14:53:37 +0100 (CET) Received: from smtp-relay.CeBiTec.Uni-Bielefeld.DE ([127.0.0.1]) by localhost (malfoy.CeBiTec.Uni-Bielefeld.DE [127.0.0.1]) (amavisd-new, port 10024) with LMTP id LsCukotUsUam; Mon, 21 Nov 2011 14:53:34 +0100 (CET) Received: from manam.CeBiTec.Uni-Bielefeld.DE (manam.CeBiTec.Uni-Bielefeld.DE [129.70.161.120]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp-relay.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTPS id A9CF2FE9; Mon, 21 Nov 2011 14:53:34 +0100 (CET) Received: (from ro@localhost) by manam.CeBiTec.Uni-Bielefeld.DE (8.14.5+Sun/8.14.5/Submit) id pALDrXu0015063; Mon, 21 Nov 2011 14:53:33 +0100 (MET) From: Rainer Orth To: gcc-patches@gcc.gnu.org Cc: Richard Henderson , Paolo Bonzini Subject: [libitm, build] Clear hardware capabilities on libitm.so with Sun ld Date: Mon, 21 Nov 2011 14:53:33 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (usg-unix-v) MIME-Version: 1.0 X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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 . * 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 * 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