> A further note: it's version 4.3 of make

Behavior seems the same to me from (at least) 3.81 to 4.3.91 (inclusive).  
Isn't this slightly simplified example sufficient to demonstrate the same 
behavior...

martind@sirius:~/tmp/Pomaznoy-2022-10-04$ cat Makefile
RECIPE = echo "Making $@ from $^" > $@
T.1 : A.4 A.4.ind; $(RECIPE)
A.4 :; $(RECIPE)
A.4.ind : A.4; $(RECIPE)
.SECONDARY: A.4
martind@sirius:~/tmp/Pomaznoy-2022-10-04$ rm -f T.1 A.2 A.3 A.3.ind A.4 
A.4.ind; touch A.4.ind; make
echo "Making A.4 from " > A.4
echo "Making T.1 from A.4 A.4.ind" > T.1
martind@sirius:~/tmp/Pomaznoy-2022-10-04$ make
echo "Making A.4.ind from A.4" > A.4.ind
echo "Making T.1 from A.4 A.4.ind" > T.1
martind@sirius:~/tmp/Pomaznoy-2022-10-04$

... whereby Make causes A.4.ind to become out of date by building non-existent 
A.4, yet doesn't seem to notice?  With --debug=all, it seems to decide that 
there's no reason to remake A.4.ind before it causes such a reason:

Considering target file 'T.1'.
 File 'T.1' does not exist.
  Considering target file 'A.4.ind'.
   Finished prerequisites of target file 'A.4.ind'.
   Prerequisite 'A.4' of target 'A.4.ind' does not exist.
  No need to remake target 'A.4.ind'.
 Considering target file 'A.4'.
  File 'A.4' does not exist.
  Finished prerequisites of target file 'A.4'.
 Must remake target 'A.4'.

The subsequent invocation of make causes it to realize that A.4.ind needs 
updating and hence T.1 does too.

I don't immediately see how this is documented by 
https://www.gnu.org/software/make/manual/html_node/Chained-Rules.html#Chained-Rules,
 though .SECONDARY is not something I'm familiar with.

________________________________
From: Bug-make <bug-make-bounces+martin.dorey=hds....@gnu.org> on behalf of 
Mikhail Pomaznoy <mik...@mikpom.ru>
Sent: Tuesday, October 4, 2022 17:16
To: bug-make@gnu.org <bug-make@gnu.org>
Subject: Re: .SECONDARY unexpectedly affects rule invocation

***** EXTERNAL EMAIL *****

A further note: it's version 4.3 of make

On 10/4/22 14:57, Mikhail Pomaznoy wrote:

Greetings,

I have encountered weird behavior in make and tried to isolate it.  The 
software was built from source.

I have the following Makefile:

RECIPE = echo "Making $@ from $^" > $@
T.1 : A.4 A.4.ind; $(RECIPE)
A.4 : A.3 A.3.ind
    $(RECIPE)
A.2 :
    $(RECIPE)
A.3 : A.2
    $(RECIPE)
A.3.ind A.4.ind : %.ind : %
    $(RECIPE)
.SECONDARY:

And the current directory contains A.3.ind and A.4.ind .

I want to make target T.1. If I run

make T.1

Then the following commands are executed:

echo "Making A.2 from " > A.2
echo "Making A.3 from A.2" > A.3
echo "Making A.4 from A.3 A.3.ind" > A.4
echo "Making T.1 from A.4 A.4.ind" > T.1

I.e. A.4.ind and A.3.ind are never updated, while A.4 was updated. It means the 
very last command will use invalid A.4.ind file. This is a bit unexpected to me 
already. Moreover, if I remove .SECONDARY, A.4.ind or A.3.ind ARE updated while 
preparing T.1.

Could you please clarify or investigate ?

-Mikhail

Reply via email to