From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by sourceware.org (Postfix) with ESMTP id 34F433945C2C for ; Wed, 23 Sep 2020 00:17:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 34F433945C2C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=kernel.crashing.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=segher@kernel.crashing.org Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 08N0Gvke014523; Tue, 22 Sep 2020 19:16:57 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 08N0Gv1J014522; Tue, 22 Sep 2020 19:16:57 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Tue, 22 Sep 2020 19:16:57 -0500 From: Segher Boessenkool To: Alan Modra Cc: gcc-patches@gcc.gnu.org Subject: Re: [RS6000] Power10 libffi fixes Message-ID: <20200923001657.GQ28786@gate.crashing.org> References: <20200922003011.GB5452@bubble.grove.modra.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200922003011.GB5452@bubble.grove.modra.org> User-Agent: Mutt/1.4.2.3i X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, TXREP, T_SPF_HELO_PERMERROR, T_SPF_PERMERROR 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-List-Received-Date: Wed, 23 Sep 2020 00:17:59 -0000 Hi! On Tue, Sep 22, 2020 at 10:00:11AM +0930, Alan Modra wrote: > Power10 pc-relative code doesn't use or preserve r2 as a TOC pointer. > That means calling between pc-relative and TOC using code can't be > done without intervening linker stubs, and a call from TOC code to > pc-relative code must have a nop after the bl in order to restore r2. > > Now the PowerPC libffi assembly code doesn't use r2 except for the > implicit use when making calls back to C, ffi_closure_helper_LINUX64 > and ffi_prep_args64. So changing the assembly to interoperate with > pc-relative code without stubs is easily done. Controlling that is a > new built-in macro. > > Upstream libffi currently has a different patch applied to work around > the power10 build failure. I'll post a delta for upstream. > Bootstrapped and regression tested on power8, built for power10. > > gcc/ > * config/rs6000/rs6000-c.c (rs6000_target_modify_macros): > Conditionally define __PCREL__. Please do that as a separate (earlier) patch (because it *is*, and to simplify backports, etc). > libffi/ > * src/powerpc/linux64.S (ffi_call_LINUX64): Don't emit global > entry when __PCREL__. Call using @notoc. > (ffi_closure_LINUX64, ffi_go_closure_linux64): Likewise. This is okay for trunk, and for backports (possibly expedited, talk with Peter for what is wanted/needed for AT). Thanks! Segher