Re: [PATCH 2/2] libstdc++: build the source directories in parallel
Jonathan Wakely <[email protected]>
| Newsgroups | gmane.comp.gcc.patches,gmane.comp.gcc.libstdc++.devel |
|---|---|
| Message-ID | <CACb0b4mtwWK6aixoOuU9OBcOsOOVuenvPg-d5_5Ho6+JscxYpw@mail.gmail.com> |
On Tue, 11 Aug 2026 at 10:58, <[email protected]> wrote: > > From: Kyrylo Tkachov <[email protected]> > > libstdc++-v3/src is built by walking SUBDIRS, and automake implements that > walk as a shell loop. The per-standard directories are therefore built one > after another no matter how large -j is, and most of them hold only a handful > of files. Sampling the compiler processes during a bootstrap shows a mean of > between 2 and 4 concurrent compiles against -j64, with exactly one source > directory active at any moment, and long stretches at a concurrency of two. > > libstdc++ is the last thing to finish in every stage, so for most of that time > nothing else in the build is running and the machine is idle. > > The directories are independent of each other, apart from src/experimental, > which links the convenience archives of c++23, c++26, filesystem and > libbacktrace. Give make an explicit target per directory, with that one > dependency written down, and let it overlap them. automake's own loop still > runs afterwards, finds everything built and costs nothing, so the recursion > for install, clean and the other targets is untouched. > > On aarch64 a clean rebuild of libstdc++-v3/src with the final stage compiler > falls by 62%, and a release checking bootstrap by 12.8%. Splendid! > > > Bootstrapped on aarch64-none-linux-gnu. Ok for trunk? Could you please add a comment to src/experimental/Makefile.am that says to keep the list of convenience libs in sync with the prerequisites of all-in-experimental in src/Makefile.am, something similar to the existing "Keep this list sync'd" comment on line 45 of src/Makefile.am That will ensure that when we add libc++29convenience.la and link that into libstdc++exp.a, we don't forget to update the prereqs of all-in-experimental. OK with that change, thanks. > > libstdc++-v3/ChangeLog: > > * src/Makefile.am (all-recursive): Depend on all-parallel-subdirs. > (all-parallel-subdirs, all-in-%): New targets. > (all-in-experimental): Depend on the directories whose convenience > archives it links. > * src/Makefile.in: Regenerate. > > Signed-off-by: Kyrylo Tkachov <[email protected]> > --- > libstdc++-v3/src/Makefile.am | 20 ++++++++++++++++++++ > libstdc++-v3/src/Makefile.in | 20 ++++++++++++++++++++ > 2 files changed, 40 insertions(+) > > diff --git a/libstdc++-v3/src/Makefile.am b/libstdc++-v3/src/Makefile.am > index 35a497a1588..17fd6ed6064 100644 > --- a/libstdc++-v3/src/Makefile.am > +++ b/libstdc++-v3/src/Makefile.am > @@ -46,6 +46,26 @@ endif > SUBDIRS = c++98 c++11 c++17 c++20 c++23 c++26 \ > $(filesystem_dir) $(backtrace_dir) $(experimental_dir) > > +# automake walks SUBDIRS with a shell loop, so the source directories are > +# built strictly one after another however large -j is. They are independent > +# of each other apart from the convenience archives that src/experimental > +# links, so build them from make instead and let it overlap them. automake's > +# own loop still runs afterwards, where it finds everything already built and > +# costs nothing, and the recursion for install, clean and the rest is > +# untouched. > +all-recursive: all-parallel-subdirs > + > +all-parallel-subdirs: $(SUBDIRS:%=all-in-%) > + > +all-in-%: > + $(MAKE) $(AM_MAKEFLAGS) -C $* all > + > +# src/experimental links the convenience archives of these directories. > +all-in-experimental: all-in-c++23 all-in-c++26 \ > + $(filesystem_dir:%=all-in-%) $(backtrace_dir:%=all-in-%) > + > +.PHONY: all-parallel-subdirs > + > # Cross compiler support. > if VTV_CYGMIN > toolexeclib_LTLIBRARIES = libvtv.la libstdc++.la > diff --git a/libstdc++-v3/src/Makefile.in b/libstdc++-v3/src/Makefile.in > index 811d0a5ce4a..104033fd679 100644 > --- a/libstdc++-v3/src/Makefile.in > +++ b/libstdc++-v3/src/Makefile.in > @@ -1020,6 +1020,26 @@ uninstall-am: uninstall-toolexeclibLTLIBRARIES > .PRECIOUS: Makefile > > > +# automake walks SUBDIRS with a shell loop, so the source directories are > +# built strictly one after another however large -j is. They are independent > +# of each other apart from the convenience archives that src/experimental > +# links, so build them from make instead and let it overlap them. automake's > +# own loop still runs afterwards, where it finds everything already built and > +# costs nothing, and the recursion for install, clean and the rest is > +# untouched. > +all-recursive: all-parallel-subdirs > + > +all-parallel-subdirs: $(SUBDIRS:%=all-in-%) > + > +all-in-%: > + $(MAKE) $(AM_MAKEFLAGS) -C $* all > + > +# src/experimental links the convenience archives of these directories. > +all-in-experimental: all-in-c++23 all-in-c++26 \ > + $(filesystem_dir:%=all-in-%) $(backtrace_dir:%=all-in-%) > + > +.PHONY: all-parallel-subdirs > + > @VTV_CYGMIN_TRUE@vtv_stubs.cc: > @VTV_CYGMIN_TRUE@ rm -f $@ > @VTV_CYGMIN_TRUE@ $(LN_S) $(toplevel_srcdir)/libstdc++-v3/libsupc++/vtv_stubs.cc $@ > -- > 2.50.1 (Apple Git-155) >