[klibc] Parallel build of dash still fails

Dave Dodge dododge at dododge.net
Fri Dec 16 02:06:49 PST 2005


On Tue, Dec 13, 2005 at 09:29:02AM -0800, H. Peter Anvin wrote:
[...]
> $(obj)/nodes.c $(obj)/nodes.h: $(obj)/mknodes $(src)/nodetypes \
>                                $(src)/nodes.c.pat
>         $(call cmd,mknodes)
> 
> ... which DO NOT do what one logically think they do.  If executed in 
> parallel that rule will be executed not once but *twice*, one for 
> nodes.c and one for nodes.h, and they will of course step on each other. 
>  One way to deal with that is to have a dummy rule from nodes.c to 
> nodes.h, and another way is to have the program only output one file and 
> not the other.

Another option is to use a pattern rule for the targets.  If a pattern
rule contains multiple targets, GNU make marks all of the targets as
updated after running the commands only once (see the "Pattern Intro"
node in the GNU make manual).

> This particular misfeature is my #1 gripe with make, and has been. 
> Unfortunately, the GNU make people don't seem willing to come up with a 
> proper fix.

The pattern rule technique is obscure and might be hard to apply in a
readable manner.  I only know about it because I had to solve a
similar problem in another project last week.  For the above case:

  $(obj)/nodes.%: ...

might not solve it, if make thinks that the pattern also matches
nodes.o (the order of the rules in the Makefile may be important).
Something really ugly like this might work:

  $(obj)/%odes.h $(obj)/%odes.c: ...

                                                  -Dave Dodge



More information about the klibc mailing list