>From 72bb1e8446a8043c0863778cba8c8a14ddcf9eca Mon Sep 17 00:00:00 2001 From: Jarmo Jaakkola Date: Thu, 16 Mar 2023 00:07:05 +0200 Subject: [PATCH] Fix also_make of non-prefix patterns In pattern rules with multiple targets where the pattern is *not* a prefix, i.e. "a% b%: c%; rule" vs. "%a %b: %c; rule" The stem was being expanded incorrectly when populating also_make. The pattern was replaced with the entire stem instead of prepending the directory part of the stem and replacing the pattern with only the file part of stem. E.g. given the rule above, for dir/atarget also_make would contain "bdir/target" instead of "dir/btarget" The incorrect names didn't match the intended targets and as a result the rule got executed for each target, instead of only once. In a parallel build they could even execute simultaneously. --- src/implicit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/implicit.c b/src/implicit.c index 5fa30944..b3884dfa 100644 --- a/src/implicit.c +++ b/src/implicit.c @@ -1110,9 +1110,10 @@ pattern_search (struct file *file, int archive, struct dep *new = alloc_dep (); /* GKM FIMXE: handle '|' here too */ + p = mempcpy (p, file->stem, pathlen); p = mempcpy (p, rule->targets[ri], rule->suffixes[ri] - rule->targets[ri] - 1); - p = mempcpy (p, file->stem, fullstemlen); + p = mempcpy (p, file->stem + pathlen, stemlen); memcpy (p, rule->suffixes[ri], rule->lens[ri] - (rule->suffixes[ri] - rule->targets[ri])+1); new->name = strcache_add (nm); -- 2.30.2