[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Build not parallel make safe

From: Joseph S. Myers
Subject: Build not parallel make safe
Date: Fri, 23 Jun 2006 10:59:37 +0000 (UTC)

The following in ncurses/Makefile.in is not safe with parallel make.

names.c codes.c: $(tinfo)/MKnames.awk
        $(AWK) -f $(tinfo)/MKnames.awk $(srcdir)/../include/@TERMINFO_CAPS@
        cat namehdr boolnames boolfnames numnames numfnames strnames strfnames 
nameftr >names.c
        cat namehdr boolcodes numcodes strcodes codeftr >codes.c
        -rm -f namehdr nameftr codeftr boolnames boolfnames boolcodes numnames 
numfnames numcodes strnames strfnames strcodes

The failure mode I observed was that make_keys is built when names.c 
exists but is incomplete (while the cat is running).  This is possible 
because make may have decided to build codes.c, and be in the process of 
building it, when another parallel job needs names.c and observes it 
already exists.  (This rule is effectively two independent rules, one to 
create names.c which happens as a side-effect to create codes.c and one to 
create codes.c which happens as a side-effect to create names.c.)

I think a safe fix might be to change all dependencies on names.c and 
codes.c to depend on a stamp file instead and then have

names-codes-stamp: $(tinfo)/MKnames.awk
        echo timestamp > names-codes-stamp

The following complete Makefile illustrates the sort of parallel build 
problem present here.

all: u v

x y:
        echo > x
        sleep 10
        echo >> x
        echo > y

u : y
v : x
        echo building v

Joseph S. Myers

reply via email to

[Prev in Thread] Current Thread [Next in Thread]