From patchwork Fri Oct 29 19:03:49 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Kleen X-Patchwork-Id: 69623 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 BB447B70D5 for ; Sat, 30 Oct 2010 06:04:00 +1100 (EST) Received: (qmail 15704 invoked by alias); 29 Oct 2010 19:03:58 -0000 Received: (qmail 15694 invoked by uid 22791); 29 Oct 2010 19:03:57 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, TW_XG, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from one.firstfloor.org (HELO one.firstfloor.org) (213.235.205.2) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 29 Oct 2010 19:03:53 +0000 Received: from basil.firstfloor.org (p5B3C9619.dip0.t-ipconnect.de [91.60.150.25]) by one.firstfloor.org (Postfix) with ESMTP id 531C61A98052; Fri, 29 Oct 2010 21:03:50 +0200 (CEST) Received: by basil.firstfloor.org (Postfix, from userid 1000) id 95DF0DF50D; Fri, 29 Oct 2010 21:03:49 +0200 (CEST) Date: Fri, 29 Oct 2010 21:03:49 +0200 From: Andi Kleen To: "H.J. Lu" Cc: Andi Kleen , gcc-patches@gcc.gnu.org, Andi Kleen Subject: Re: [PATCH 2/2] Add gcc-ar, gcc-ranlib, gcc-ld wrappers v2 Message-ID: <20101029190349.GB12649@basil.fritz.box> References: <1288376060-12168-1-git-send-email-andi@firstfloor.org> <1288376060-12168-2-git-send-email-andi@firstfloor.org> <20101029184124.GA12649@basil.fritz.box> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) 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 On Fri, Oct 29, 2010 at 11:46:01AM -0700, H.J. Lu wrote: > On Fri, Oct 29, 2010 at 11:41 AM, Andi Kleen wrote: > >> > >> exec $AR -s --plugin `$BINDIR/gcc -print-lto-plugin` "$@" > > > > Yes you're right of course. Fixed. > > gcc-ranlib have the same problem. Don't we also need "gcc -nm"? I fixed both. I can add a nm in the same way if people want. I personally didn't need it because i have an own utility to dump the lto symbol tables that I typically use. Current version appended. -Andi From: Andi Kleen Subject: [PATCH] Add gcc-ar, gcc-ranlib, gcc-ld wrappers v3 [Updated version, see changelog below. I decided to drop gcc-ld for now because that one seemed to be problematic and is only needed for some specific project. I guess I can keep it separate.] Earlier review resulted in a request for having gcc-... wrappers to handle the LTO symbol tables for ranlib/ar. This is needed for slim lto files, because these tools cannot read the symbol table otherwise. Essentially they just call binutils with the LTO plugin specified. Other compilers with LTO support tend to have similar tools. This patch implements those wrappers. The wrappers are also needed for a LTO slim of gcc. Right now they have to be manually specified for that. The wrappers require uptodate binutils (the upcoming release) with plugin support enabled. There is currently no autoconf support to detect that. The wrappers query the gcc driver in an attempt to handle cross compilation and so naming everywhere v2: drop gcc-ld for now. support relocated installation trees. v3: fix typo, support xgcc gcc/lto/ 2010-10-26 Andi Kleen * Make-lang.in (AR_INSTALL_NAME, RANLIB_INSTALL_NAME, LTO_WRAPPERS): Add. (lto.all.cross, lto.start.cross): Add dependency to LTO_WRAPPERS. (lto.install.common): Install wrappers. (lto.mostlyclean): Clean wrappers. * gcc-ar, gcc-ranlib.in: Add. gcc/ 2010-10-26 Andi Kleen * doc/invoke.texi (gcc-ar, gcc-ranlib): Document. diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index d6784ad..5cae0e4 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -7565,6 +7565,9 @@ be exported, it is possible to combine @option{-flto} and interprocedural optimizers to use more aggressive assumptions which may lead to improved optimization opportunities. +In some cases you may need to use the @command{gcc-ar} and +@command{gcc-ranlib} commands to manage ar files of LTO objects. + Regarding portability: the current implementation of LTO makes no attempt at generating bytecode that can be ported between different types of hosts. The bytecode files are versioned and there is a diff --git a/gcc/lto/Make-lang.in b/gcc/lto/Make-lang.in index 2dc6409..56f126d 100644 --- a/gcc/lto/Make-lang.in +++ b/gcc/lto/Make-lang.in @@ -28,16 +28,29 @@ LTO_H = lto/lto.h $(HASHTAB_H) LINKER_PLUGIN_API_H = $(srcdir)/../include/plugin-api.h LTO_TREE_H = lto/lto-tree.h $(LINKER_PLUGIN_API_H) +AR_INSTALL_NAME := $(shell echo gcc-ar|sed '$(program_transform_name)') +RANLIB_INSTALL_NAME := $(shell echo gcc-ranlib|sed '$(program_transform_name)') + +ifeq ($(enable_plugin),yes) +LTO_WRAPPERS = lto/gcc-ar lto/gcc-ranlib +else +LTO_WRAPPERS = +endif # Rules # These hooks are used by the main GCC Makefile. Consult that # Makefile for documentation. -lto.all.cross: $(LTO_EXE) -lto.start.encap: $(LTO_EXE) +lto.all.cross: $(LTO_EXE) $(LTO_WRAPPERS) +lto.start.encap: $(LTO_EXE) $(LTO_WRAPPERS) lto.rest.encap: lto.tags: lto.install-common: +ifeq ($(enable_plugin),yes) + $(INSTALL_SCRIPT) lto/gcc-ar $(DESTDIR)$(bindir)/$(AR_INSTALL_NAME) + $(INSTALL_SCRIPT) lto/gcc-ranlib $(DESTDIR)$(bindir)/$(RANLIB_INSTALL_NAME) +endif + lto.install-man: lto.install-info: lto.dvi: diff --git a/gcc/lto/gcc-ar b/gcc/lto/gcc-ar new file mode 100755 index 0000000..892a0c0 --- /dev/null +++ b/gcc/lto/gcc-ar @@ -0,0 +1,18 @@ +#!/bin/sh +# wrapper for ar with GCC LTO support +# requires binutils 2.21+ + +BASE=`readlink -f $0` +BINDIR=`dirname $BASE` + +if [ -x "$BINDIR/xgcc" ] ; then + GCC=xgcc + ARG=-B$BINDIR +else + GCC=gcc + ARG= +fi + +AR=${AR:-`"$BINDIR/$GCC" -print-prog-name=ar`} + +exec $AR --plugin `$BINDIR/$GCC $ARG -print-lto-plugin` "$@" diff --git a/gcc/lto/gcc-ranlib b/gcc/lto/gcc-ranlib new file mode 100644 index 0000000..d8482cc --- /dev/null +++ b/gcc/lto/gcc-ranlib @@ -0,0 +1,18 @@ +#!/bin/sh +# wrapper for ranlib with GCC LTO support +# requires binutils 2.21+ + +BASE=`readlink -f $0` +BINDIR=`dirname $BASE` + +if [ -x "$BINDIR/xgcc" ] ; then + GCC=xgcc + ARG=-B$BINDIR +else + GCC=gcc + ARG= +fi + +AR=${AR:-`"$BINDIR/$GCC" -print-prog-name=ar`} + +exec $AR -s --plugin `$BINDIR/$GCC $ARG -print-lto-plugin` "$@"