2013/5/19 David Coppa <[email protected]>

> On Sun, May 19, 2013 at 4:33 PM, Vadim Zhukov <[email protected]> wrote:
> > Hello all.
> >
> > This patch allows to run parallel builds for CMake-based ports.
> > Yes, it works. At least, for me. :) Tested on a few KDE4 ports.
>
> So cool!
>
> But what is the rationale behind this?
>

It's all about handling recursive make calls. Any parallel-ready make(1)
implementation knows that recursive calls should not be parallelized, at
least simply. But they use different mechanisms to avoid this problem.

GNU Make have separate mechanism to talk with sub-makes. It's complicated
but works for most time. Thus there was not needed anything to add in
Makefile.

​Our make(1) just looks at the commands being run, and if they look like
recursive call, it treats this target as ​"expensive". No other targets,
even "cheap" ones, are started until "expensive" target is ended.

​CMake generates Makefiles with recursive calls even for really simple
tasks. If you say "make foo.o" for CMake-generated Makefile, it will really
run some internal target. So our make treats all targets in CMake-generated
Makefiles as "expensive", and do not run them in parallel.

What this patch does: it adds explicit marks "this target is cheap" or
"this target is expensive" to all targets. This is done through
non-standard ".CHEAP" and ".EXPENSIVE" targets. make(1) implementations
that does not know about them will simply ignore this, so this patch has
only one negative effect - larger generated Makefiles.

--
  WBR,
  Vadim Zhukov

Reply via email to