[build2] LTO and parallelization with build2

Boris Kolpackov boris at codesynthesis.com
Fri Aug 7 14:28:36 UTC 2020


Matthew Krupcale <mkrupcale at matthewkrupcale.com> writes:

> For some reason when I was browsing the GitHub GCC sources, it led me
> to look at an older revision of gcc/params.def. lto-partitions default
> was bumped to 128[1] [...]

Ok, that's a much more reasonable default.


> In any case, I think that in addition to translating -flto=auto or
> -flto=n (with n>N) to -flto=N, where N is the number of available
> hardware threads, we may have to also set --param lto-partitions=m,
> where m>N. I'm not entirely sure what the right value for m is
> compared to the number of threads. m=N+1? m=2*N?

I am not sure we want to mess with lto-partitions, feels like it can
get GCC-version-dependent. Also, I would be weary of rewriting -flto=n;
we generally assume the user knows what they are doing (and if not,
they will appreciate an opportunity to learn ;-)).


> > What's left is to translate -flto=auto. Would you like to take
> > a stab at it? I could give you some pointers if you are interested.
> 
> Yeah, I might give it a try this weekend, and pointers are always
> appreciated.

The place to do this seems to be libbuild2/cc/link-rule.cxx:2993,
just before printing the command line (we generally want to allocate
extra threads as late as possible and release them as early as
possible, the latter would be after run_finish() on line 3164).

We will also only want to do this if:

1. It's not a static library.

2. It's GCC of sufficient version. (I wonder what's the story with
   Clang here?)

You can find plenty of such tests earlier in the function.

As for finding the option itself, we have the find_option_prefix()
utility function that does almost what we need (we need the
position, not the pointer to the option value). Maybe we can add
find_option_prefix_position() or some such?



More information about the users mailing list