[SV 54233] Preserve higher command_state values on also_make targets.

If multiple pattern rules have the same pattern as also-make targets
and we attempt to run them at the same time, we might downgrade the
command state from 'running' to 'deps_running'; this will prevent
that also_make from being considered complete causing make to wait
forever for it to finish.

Ensure that set_command_state never downgrades the state of a target.

* src/file.c (set_command_state): Don't downgrade command_state.
* src/filedef.h (struct file): Document the order prerequisite.
* test/scripts/features/patternrules: Test the behavior.
This commit is contained in:
Paul Smith
2018-08-04 19:07:59 -04:00
parent e2234bc1ab
commit 05769ca009
3 changed files with 22 additions and 3 deletions

View File

@@ -220,6 +220,22 @@ all: foo.x foo-mt.x
1;
# Test pattern rules building the same targets
# See SV 54233. Rely on our standard test timeout to break the loop
touch('a.c');
run_make_test(q!
all: a.elf a.dbg
%.elf %.lnk: %.c ; : $*.elf $*.lnk
%.elf %.dbg: %.lnk ; : $*.elf $*.dbg
!,
'-j2', ": a.elf a.lnk\n: a.elf a.dbg\n");
unlink('a.c');
# This tells the test driver that the perl test script executed properly.
1;