From patchwork Thu Aug 20 18:45:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Maciej W. Rozycki" X-Patchwork-Id: 1348564 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=QUA/tUGg; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BXYWR0YYpz9sPB for ; Fri, 21 Aug 2020 04:45:55 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 12C73387089B; Thu, 20 Aug 2020 18:45:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 12C73387089B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1597949153; bh=ZOYFkFmxECagaYJTkAk0sP6rIyWD7TO8r06uOX/rdC8=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=QUA/tUGgm4eRhejTn59xlfp7PPC6LoQrIAojcrXsXWAINkVpMXYhtRle8z51qhfIw ZO7TrkHEuJB8TAKdbs46oVD8YWrJM2GO1IecalY76QxQwZ3AxHzqeT/mp+3V5fLrMJ h2AsWti+lY0lNRlAdARxXov3c+SfalFR3G4RZBKM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa4.hgst.iphmx.com (esa4.hgst.iphmx.com [216.71.154.42]) by sourceware.org (Postfix) with ESMTPS id 5FA71386F421 for ; Thu, 20 Aug 2020 18:45:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 5FA71386F421 IronPort-SDR: R53KKyR/wQlNoRHmw2OFyJ5d98gKp3L5wU33Wukdv0YOLd9WY2icnV88/9izhCPXNj11N+jn1G N5GeP8hLUNAIN9LG0mDE4SnTduZsVKK0GxURjyXR9QJ3KMnYYfF22uTnlksk4QMR3hu1+GLDwX J/uBTjDbHoKfLePcVGGr5d0capBP5b1EXQznO8xNMMF1QZZHj0bOQ6nyzIJ3E+xl8Xomro6VJ0 hBBCvURWumn6GLwIBG1F6irqkvROJuBINHEaoUVZfen6Fn6/ktGpk2FOstOthw1lS//tz+Ssx7 gEk= X-IronPort-AV: E=Sophos;i="5.76,334,1592841600"; d="scan'208";a="145394105" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 21 Aug 2020 02:45:47 +0800 IronPort-SDR: X+dii2zQ/f+kvO3dfCuCx/ugPX5p/kJA0LUGFbprmUhGuzmQHFOinjweXW4QOQwQGzJmknXSvg +PUO2tT7C7EA== Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 11:33:29 -0700 IronPort-SDR: 6bjCbiXUSq/FULVudl9/q+kS3G2M6D0yBg8P2cfEAHWx003WqyJfCkB1UsdCwWxfMeVTlnhSAG YF2vZXG9yOlA== WDCIronportException: Internal Received: from unknown (HELO redsun52) ([10.149.66.28]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 11:45:46 -0700 Date: Thu, 20 Aug 2020 19:45:41 +0100 (BST) To: gcc-patches@gcc.gnu.org Subject: [PATCH v3] libgcc: Use `-fasynchronous-unwind-tables' for LIB2_DIVMOD_FUNCS Message-ID: User-Agent: Alpine 2.21 (LFD 202 2017-01-01) MIME-Version: 1.0 X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_ASCII_DIVIDERS, KAM_SHORT, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: "Maciej W. Rozycki via Gcc-patches" From: "Maciej W. Rozycki" Reply-To: "Maciej W. Rozycki" Cc: Andrew Waterman , Kito Cheng , Andreas Schwab Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Complement commit b932f770f70d ("x86_64 frame unwind info"), SVN r46374, , and replace `-fexceptions -fnon-call-exceptions' with `-fasynchronous-unwind-tables' in LIB2_DIVMOD_FUNCS compilation flags so as to provide unwind tables for the affected functions while not pulling the unwinder proper, which is not required here. Beyond saving program space it fixes a RISC-V glibc build error due to unsatisfied `malloc' and `free' references from the unwinder causing link errors with `ld.so' where libgcc has been built at -O0. gcc/ * testsuite/gcc.target/arm/div64-unwinding.c: Rename to... * testsuite/gcc.dg/div64-unwinding.c: ... this. libgcc/ * Makefile.in [!LIB2_DIVMOD_EXCEPTION_FLAGS] (LIB2_DIVMOD_EXCEPTION_FLAGS): Replace `-fexceptions -fnon-call-exceptions' with `-fasynchronous-unwind-tables'. --- Hi, No change from v2 except for the removal of the ARM parts; hence no need to retest. OK to apply? Maciej Changes from v2: - Removal of the ARM overrides removed. Changes from v1: - ChangeLog entries added. --- gcc/testsuite/gcc.dg/div64-unwinding.c | 25 +++++++++++++++++++++++++ gcc/testsuite/gcc.target/arm/div64-unwinding.c | 25 ------------------------- libgcc/Makefile.in | 2 +- 3 files changed, 26 insertions(+), 26 deletions(-) gcc-libgcc-divmod-asynchronous-unwind-tables.diff Index: gcc/gcc/testsuite/gcc.dg/div64-unwinding.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/div64-unwinding.c @@ -0,0 +1,25 @@ +/* Performing a 64-bit division should not pull in the unwinder. */ + +/* { dg-do run { target { { ! *-*-linux* } && { ! *-*-uclinux* } } } } */ +/* { dg-skip-if "load causes weak symbol resolution" { vxworks_kernel } } */ +/* { dg-options "-O0" } */ + +#include + +long long +foo (long long c, long long d) +{ + return c/d; +} + +long long x = 0; +long long y = 1; + +extern int (*_Unwind_RaiseException) (void *) __attribute__((weak)); + +int main(void) +{ + if (&_Unwind_RaiseException != NULL) + abort ();; + return foo (x, y); +} Index: gcc/gcc/testsuite/gcc.target/arm/div64-unwinding.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/arm/div64-unwinding.c +++ /dev/null @@ -1,25 +0,0 @@ -/* Performing a 64-bit division should not pull in the unwinder. */ - -/* { dg-do run { target { { ! *-*-linux* } && { ! *-*-uclinux* } } } } */ -/* { dg-skip-if "load causes weak symbol resolution" { vxworks_kernel } } */ -/* { dg-options "-O0" } */ - -#include - -long long -foo (long long c, long long d) -{ - return c/d; -} - -long long x = 0; -long long y = 1; - -extern int (*_Unwind_RaiseException) (void *) __attribute__((weak)); - -int main(void) -{ - if (&_Unwind_RaiseException != NULL) - abort ();; - return foo (x, y); -} Index: gcc/libgcc/Makefile.in =================================================================== --- gcc.orig/libgcc/Makefile.in +++ gcc/libgcc/Makefile.in @@ -533,7 +533,7 @@ endif ifeq ($(LIB2_DIVMOD_EXCEPTION_FLAGS),) # Provide default flags for compiling divmod functions, if they haven't been # set already by a target-specific Makefile fragment. -LIB2_DIVMOD_EXCEPTION_FLAGS := -fexceptions -fnon-call-exceptions +LIB2_DIVMOD_EXCEPTION_FLAGS := -fasynchronous-unwind-tables endif # Build LIB2_DIVMOD_FUNCS.