RFC: support of PGO?

H.J. Lu hjl.tools@gmail.com
Wed Oct 21 13:52:48 GMT 2020


On Tue, Oct 20, 2020 at 2:20 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Tue, Oct 20, 2020 at 2:08 AM Martin Liška <mliska@suse.cz> wrote:
> >
> > On 10/19/20 1:50 PM, Nick Clifton wrote:
> > > Hi Martin,
> > >
> > >> May I please ping this?
> > >
> > > Sorry for not responding earleir.
> > >
> > >>> Right now I make the PGO with:
> > >>>
> > >>> export C{,XX}FLAGS "-fprofile-generate=/tmp/binutils -O2 -flto"
> > > [...]
> > >
> > >>> Questions I have:
> > >>> - Would it be possible to integrate PGO into the root Makefile?
> > >
> > > Possible yes.  But you would need approval from the GDB and GCC
> > > communities, since we all use the same top level Makefile.
> > >
> > > Probably the easiest way to approach this is to create a patch that
> > > adds a new set of targets to the makefile.  Eg "pgo-all" or "pgo-gas".
> > > Then submit this patch for review.
> > >
> > > Maybe there is a way to toggle using pgo (an environment variable
> > > maybe ?), so that the new targets are not needed.  I am not enough
> > > of a Makefile expert to know if this idea is feasible however.
> >
> > Hello.
> >
> > I see quite obstacles to make it happen:
> > - one needs to run ./configure twice (-fprofile-generate/-fprofile-use) and it seems
> > that re-configuration is not much supported by binutils
> > - it's not trivial to fix the failing tests, simply accepting LDFLAGS fixes something,
> >    but breaks other tests
> > - that means some tools like ld will be actually trained with a failing inputes
> > - it would make sense to bootstrap bintuils (using gas, ld and other tools) during
> >    build of binutils. Apparently it's only somehow supported as part of GCC's build:
> >
> > ../configure --disable-nls --disable-gdb --disable-gdbserver --enable-bootstrap
> > configure: error: cannot bootstrap without a compiler
> >
> > >
> > >
> > >>> - Or do you prefer the way I made the PGO?
> > >
> > > Your method is definitely the simplest - no changes needed to any
> > > files.  It might be helpful - if the Makefile patching idea is shot
> > > down - to document this process in eg binutils/README so that other
> > > contributors can benefit.
> > >
> > > Please excuse my ignorance on PGO - but does it work well when changes
> > > are made to the code base ?  For example if I patch gas in some (major) way,
> > > is it necessary to run the multiple configure-and-build steps that you
> > > outlined in order to gain the benefits of PGO, or will a simple rebuild,
> > > using the old profile information, still work ?
> >
> > It does not work in that case. However, PGO is supposed to be used by package
> > builds (typically in spec file), where a speed benefit is desired.
> >
> > Anyway, I'm leaving the attempt for now.
>
> I am using:
>
>         rm -rf /tmp/binutils
>         $(MAKE) tools PGO-CFLAGS="-fprofile-generate=/tmp/binutils" && \
>           $(MAKE) $(PARALLELMFLAGS) -C $(BUILD-DIR)/gas check && \
>           $(MAKE) $(PARALLELMFLAGS) -C $(BUILD-DIR)/binutils check && \
>           $(MAKE) install && \
>           PATH=$(RELEASE-DIR)/usr/local/bin:$(PATH) \
>             $(MAKE) tools PGO-CFLAGS="-fno-profile-use" && \
>           find $(BUILD-DIR) -name *.o | xargs rm -f && \
>           find $(BUILD-DIR) -name *.lo | xargs rm -f && \
>           find $(BUILD-DIR) -name Makefile | \
>             xargs sed -i -e
> "s,-fno-profile-use,-fprofile-use=/tmp/binutils,g" && \
>           $(MAKE) all && \
>           find $(BUILD-DIR) -name Makefile | \
>             xargs sed -i -e "s,-fprofile-use=/tmp/binutils,,g" && \
>           $(MAKE) all && \
>           $(MAKE) $(PARALLELMFLAGS) check
>
>

I opened:

https://sourceware.org/bugzilla/show_bug.cgi?id=26766

-- 
H.J.


More information about the Binutils mailing list