Message ID | 20101029190349.GB12649@basil.fritz.box |
---|---|
State | New |
Headers | show |
* Andi Kleen wrote on Fri, Oct 29, 2010 at 09:03:49PM CEST: > --- /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` "$@" If you're double-quoting $BINDIR before in this script for a reason, then you should do so here as well. Likewise in the gcc-ranlib script. Thanks, Ralf
On Fri, 29 Oct 2010, Andi Kleen wrote: > +if [ -x "$BINDIR/xgcc" ] ; then > + GCC=xgcc > + ARG=-B$BINDIR > +else > + GCC=gcc No, it's not "gcc" in a cross toolchain or likely in GNU/Linux distribution toolchains. It's gcc as modified by $(program_transform_name). And if someone happens to have "xgcc" in their installation directory that should not affect how the program behaves; at most, "xgcc" should be a fallback if the expected name is not found, but actually I don't think working in a GCC build directory is important here (we should move towards staged installation to let parts of GCC find each other before the final install). $ gcc -v Using built-in specs. Target: i686-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.4.4-14ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.4 --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu Thread model: posix gcc version 4.4.5 (Ubuntu/Linaro 4.4.4-14ubuntu5) That's system GCC on Ubuntu Maverick, note the --program-suffix to support simultaneous installation of multiple versions. All the previous comments that you should be using C wrappers still apply.
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` "$@"