[PATCH] Add gcc-ar/nm/ranlib wrappers for slim LTO

Andi Kleen andi@firstfloor.org
Thu Oct 20 14:52:00 GMT 2011


On Thu, Oct 20, 2011 at 10:45:31AM +0200, Richard Guenther wrote:
> > My previous attempt at using shell scripts for this
> > http://gcc.gnu.org/ml/gcc-patches/2010-10/msg02471.html
> > was not approved. Here's another attempt using wrappers written
> > in C. It's only a single wrapper which just adds a --plugin
> > argument before calling the respective binutils utilities.
> 
> Thanks for doing this.  How do they end up being used?  I suppose
> Makefiles will need to call gcc-ar then instead of ar?  In which case
> I wonder if ...

Basically you use

make AR=gcc-ar RANLIB=gcc-ranlib NM=gcc-nm

For most makefiles just specifying ar is enough.

> 
> > The logic gcc.c uses to find the files is very complicated. I didn't
> > try to replicate it 100% and left out some magic. I would be interested
> > if this simple method works for everyone or if more code needs
> > to be added. This only needs to support LTO supporting hosts of course.
> 
> ;)
> 
> ... using something like gcc --ar would be more convenient (as you

That's essentially what the old proposal did (gcc -print-plugin-name) 
plus a wrapper. You can see the old discussion here
http://gcc.gnu.org/ml/gcc-patches/2010-10/msg02471.html


> can then trivially share the find-the-files logic)?  Did you consider
> factoring out the find-the-file logic to a shared file that you can re-use?

I did this first (with collect2), but it was quite messy. Still
have it as a branch. Then I settled on this simpler method which
works for me at least.

collect2 does not fully match what gcc.c does I think, so there's
already some divergence.

-Andi



More information about the Gcc-patches mailing list