From 80727d709c3a14c5f7b4ab14d7c59b8709dc133e Mon Sep 17 00:00:00 2001 From: Dmitry Goncharov Date: Sun, 2 Apr 2023 11:04:26 -0400 Subject: [SV 63856] Fix pruning of double-colon rules Given this setup: $ cat Makefile A::; @echo A-1 && sleep 1 && echo A-1 done A::; @echo A-2 && sleep 1 && echo A-2 done A::; @echo A-3 && sleep 1 && echo A-3 done B::; @echo B-1 && sleep 1 && echo B-1 done B::; @echo B-2 && sleep 1 && echo B-2 done B::; @echo B-3 && sleep 1 && echo B-3 done $ make -j8 A .WAIT B All recipes for A should be started sequentially and complete before any recipe for B is started, then all recipes for B should be started sequentially. This wasn't happening because the double-colon target was getting pruned too early. * src/remake.c (update_file): Don't prune a target if it's a double colon rule which is complete, but there are other recipes to run for this target: we want those other recipes to be run first. * tests/scripts/targets/WAIT: Test .WAIT with double colon rules. --- src/remake.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/remake.c b/src/remake.c index dec4667c..bdf78b3e 100644 --- a/src/remake.c +++ b/src/remake.c @@ -373,9 +373,15 @@ update_file (struct file *file, unsigned int depth) { /* Check for the case where a target has been tried and failed but the diagnostics haven't been issued. If we need the diagnostics - then we will have to continue. */ + then we will have to continue. + In the case of double colon rules, this file cannot be pruned if + this recipe finished (file->command_state == cs_finished) and there + are more double colon rules for this file. Instead the recipe of the + next double colon rule of this file should be run. */ if (!(f->updated && f->update_status > us_none - && !f->dontcare && f->no_diag)) + && !f->dontcare && f->no_diag) + && !(file->double_colon && file->command_state == cs_finished && + f->prev)) { DBF (DB_VERBOSE, _("Pruning file '%s'.\n")); return f->command_state == cs_finished ? f->update_status : us_success; -- cgit v1.2.1