From patchwork Wed Jan 31 09:36:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rainer Orth X-Patchwork-Id: 867875 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-472349-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="mGoADWrB"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zWdSv45lMz9ryv for ; Wed, 31 Jan 2018 20:37:34 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version:content-type; q=dns; s=default; b=NHz0Ln8/Vk+xkmbPtnsn6D2gEMHzcCJT6ROxIIEzSF95v8VupM jhgar9Qzv7IazqprefW1PytAW697TLhcJBrN0Fyy9+wBIFCdOIM6awm9MbMPQaLB bbxpLb5Ou7qFXO6tn5zenEPWw9qFPQ4DtmMGVxcHhuznqiXZpedQue8Lk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version:content-type; s= default; bh=79iEg9b+okmA2s+K6z1Z51g2w3c=; b=mGoADWrB/8+zsjYs35el BNkkA9owaQSNc3WLgeDx1+7oSBydgIo9UZcKyXvtszc4nSBP9NxYi9CjUkLE+h7A V4oOTz9CobktbQ44xt4WQe7ibj1FZQGn7Nkvt5t7slQ7Yd5WK4yt8gHIyDsl8AWf W1/oGcEyfcuydatc1IznpZU= Received: (qmail 61322 invoked by alias); 31 Jan 2018 09:37:26 -0000 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 Received: (qmail 61305 invoked by uid 89); 31 Jan 2018 09:37:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-19.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=Hx-languages-length:4809, readwrite X-HELO: smtp.CeBiTec.Uni-Bielefeld.DE Received: from smtp.CeBiTec.Uni-Bielefeld.DE (HELO smtp.CeBiTec.Uni-Bielefeld.DE) (129.70.160.84) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 31 Jan 2018 09:37:23 +0000 Received: from localhost (localhost.CeBiTec.Uni-Bielefeld.DE [127.0.0.1]) by smtp.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTP id 036B057B; Wed, 31 Jan 2018 10:37:06 +0100 (CET) Received: from smtp.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 DmPr2lCn1Sfk; Wed, 31 Jan 2018 10:37:02 +0100 (CET) Received: from lokon.CeBiTec.Uni-Bielefeld.DE (lokon.CeBiTec.Uni-Bielefeld.DE [129.70.161.152]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTPS id 5CCC6578; Wed, 31 Jan 2018 10:37:02 +0100 (CET) Received: (from ro@localhost) by lokon.CeBiTec.Uni-Bielefeld.DE (8.15.2+Sun/8.15.2/Submit) id w0V9amAJ006944; Wed, 31 Jan 2018 10:36:48 +0100 (MET) From: Rainer Orth To: gcc-patches@gcc.gnu.org Cc: Paolo Bonzini , Alexandre Oliva Subject: [build] Fix HAVE_GAS_CFI_DIRECTIVE for x86_64-pc-solaris2.* Date: Wed, 31 Jan 2018 10:36:48 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (usg-unix-v) MIME-Version: 1.0 X-IsSubscribed: yes When compiling MariaDB 10.2 (which uses cfi directives in inline asm, but gets the conditionals wrong) on Solaris 11.4 with an x86_64-pc-solaris2.11 gcc using gas, I noticed that this one incorrectly doesn't use cfi directives although it could/should. Looking closer, I noticed that the logic in gcc/configure.ac's gcc_cv_as_cfi_directive test is not only hard to follow due to deeply nested ifs, but plain wrong in the current case: for 64-bit Solaris/x86, the .eh_frame section is (and should be) read-only, unlike the 32-bit case, but is incorrectly rejected. Unlike what we currently do, configure.ac needs to verify that both the 32 and 64-bit .eh_frame sections are as the toolchain requires them to be, which is what the current patch does. Since .eh_frame section test already appeared repeatedly, making the whole code hard to read due to the redundancy, I've moved it to a shell function. While gcc/configure.ac itself currently doesn't use those directly, the generated configure already does, so we should be save here. Tested with a standalone script with the necessary boilerplate added on Solaris 10, 11.3 and 11.4 with /bin/as, bundled gas (2.15, 2.23.1, 2.29), and gas 2.30 on both sparc and x86. Also bootstrapped without regressions on i386-pc-solaris2.11 and sparc-sun-solaris2.11 (as/ld, gas/ld, both 32 and 64-bit). While this only touches Solaris-specific code, it would be nice if one of the build maintainers could have a look. Ok for mainline? Rainer # HG changeset patch # Parent f67a82dfb4ca8993e0153ceba8d8b064da71ad4d Fix HAVE_GAS_CFI_DIRECTIVE for x86_64-pc-solaris2.* diff --git a/gcc/configure.ac b/gcc/configure.ac --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -2754,6 +2754,13 @@ L2:], [AC_DEFINE(HAVE_AS_LEB128, 0, [Define if your assembler supports .sleb128 and .uleb128.])]) +# Determine if an .eh_frame section is read-only. +gcc_fn_eh_frame_ro () { + $gcc_cv_as $1 -o conftest.o conftest.s > /dev/null 2>&1 && \ + $gcc_cv_objdump -h conftest.o 2>/dev/null | \ + sed -e '/.eh_frame/!d' -e N | grep READONLY > /dev/null +} + # Check if we have assembler support for unwind directives. gcc_GAS_CHECK_FEATURE([cfi directives], gcc_cv_as_cfi_directive, ,, @@ -2769,41 +2776,41 @@ gcc_GAS_CHECK_FEATURE([cfi directives], # If the linker used on Solaris (like Sun ld) isn't capable of merging # read-only and read-write sections, we need to make sure that the # assembler used emits read-write .eh_frame sections. - if test "x$gcc_cv_ld_ro_rw_mix" != xread-write; then - if test "x$gcc_cv_objdump" != x; then - if $gcc_cv_objdump -h conftest.o 2>/dev/null | \ - sed -e /.eh_frame/!d -e N | grep READONLY > /dev/null; then - gcc_cv_as_cfi_directive=no - else - case "$target" in - i?86-*-solaris2.1[[0-9]]* | x86_64-*-solaris2.1[[0-9]]*) - # On Solaris/x86, make sure that GCC and assembler agree on using - # read-only .eh_frame sections for 64-bit. - if test x$gas = xyes; then - as_ix86_64_opt="--64" - else - as_ix86_64_opt="-xarch=amd64" - fi - if $gcc_cv_as $as_ix86_64_opt -o conftest.o conftest.s > /dev/null 2>&1 && \ - $gcc_cv_objdump -h conftest.o 2>/dev/null | \ - sed -e /.eh_frame/!d -e N | \ - grep READONLY > /dev/null; then - gcc_cv_as_cfi_directive=yes - else - gcc_cv_as_cfi_directive=no - fi - ;; - *) - gcc_cv_as_cfi_directive=yes - ;; - esac - fi + if test "x$gcc_cv_ld_ro_rw_mix" = xread-write; then + gcc_cv_as_cfi_directive=yes + elif test "x$gcc_cv_objdump" = x; then + # No objdump, err on the side of caution. + gcc_cv_as_cfi_directive=no + else + if test x$gas = xyes; then + as_32_opt="--32" + as_64_opt="--64" else - # no objdump, err on the side of caution - gcc_cv_as_cfi_directive=no + as_32_opt="-m32" + as_64_opt="-m64" fi - else - gcc_cv_as_cfi_directive=yes + case "$target" in + sparc*-*-solaris2.*) + # On Solaris/SPARC, .eh_frame sections should always be read-write. + if gcc_fn_eh_frame_ro $as_32_opt \ + || gcc_fn_eh_frame_ro $as_64_opt; then + gcc_cv_as_cfi_directive=no + else + gcc_cv_as_cfi_directive=yes + fi + ;; + i?86-*-solaris2.* | x86_64-*-solaris2.*) + # On Solaris/x86, make sure that GCC and assembler agree on using + # read-only .eh_frame sections for 64-bit. + if gcc_fn_eh_frame_ro $as_32_opt; then + gcc_cv_as_cfi_directive=no + elif gcc_fn_eh_frame_ro $as_64_opt; then + gcc_cv_as_cfi_directive=yes + else + gcc_cv_as_cfi_directive=no + fi + ;; + esac fi ;; *-*-*)