I think our parallel make issue might be a Make bug, rather than a makefile bug. Here's a minimal test case inspired by this answer https://stackoverflow.com/a/47951465 :
all: e
.INTERMEDIATE: d
e: a b c
cat $^ > $@
a b c: d
d: i1 i2
cat i1 i2 > a
cat i1 i2 > b
cat i1 i2 > c
i1 i2:
touch $@
In a single threaded make this does the right thing. it creates i1 and i2, then cats them to make a b and c, then cats a b c to make e.
/tmp: make
touch i1
touch i2
cat i1 i2 > a
cat i1 i2 > b
cat i1 i2 > c
cat a b c > e
If e doesn't exist, it is recreated correctly in a parallel make:
/tmp: rm i1 i2 e a b c
/tmp: make -j4
touch i1
touch i2
cat i1 i2 > a
cat i1 i2 > b
cat i1 i2 > c
cat a b c > e
But if e already exists, make will regenerate a, b, and c, but not update e on the first run. It does recreate e on a second run:
/tmp: rm i1 i2
/tmp: make -j4
touch i1
touch i2
cat i1 i2 > a
cat i1 i2 > b
cat i1 i2 > c
/tmp: make -j4
cat a b c > e
I think our parallel make issue might be a Make bug, rather than a
makefilebug. Here's a minimal test case inspired by this answer https://stackoverflow.com/a/47951465 :In a single threaded make this does the right thing. it creates i1 and i2, then cats them to make a b and c, then cats a b c to make e.
If
edoesn't exist, it is recreated correctly in a parallel make:But if
ealready exists, make will regeneratea,b, andc, but not updateeon the first run. It does recreateeon a second run: