bugmake - Bugs: bug #42215, secondexpansion interference

 
 

bug #42215: secondexpansion interference

Submitted by:  Patatti <patatti>
Submitted on:  Sun 27 Apr 2014 08:48:58 PM UTC  
 
Severity: 3 - NormalItem Group: Bug
Status: NonePrivacy: Public
Assigned to: NoneOpen/Closed: Open
Component Version: 4.0Operating System: Any
Fixed Release: NoneTriage Status: None

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Sun 27 Apr 2014 08:48:58 PM UTC, original submission:

On Fri, 2014-04-25 at 16:08 -0400, Martin d'Anjou wrote:

> .SECONDEXPANSION:
> file_x := f.q
> build_x := touch
>
> %.tcl: $(interference) $$(file_$$*)
> $(build_$*) \
> $@
>
> %.q: %.tcl
> touch $@
>
> To run, first touch a few files so they exist:
> $ touch f.q file.txt
>
> Next, run make (this works):
> $ make x.tcl
> touch \
> x.tcl
>
> Ok, clean up:
> $ rm x.tcl
>
> Now interfere with the process:
> $ make x.tcl interference=file.txt
> make x.tcl
> \
> f.tcl
> make: f.tcl: Command not found
> make: *** [f.tcl] Error 127


I think there is a bug here but it's somewhat subtle, and not related to memory issues at all. I'm not sure why Philip is not seeing this behavior.

Here's what's happening:

In the "working" case, you ask for x.tcl to be built. Because of
$(file_x), there is a prerequisite of f.q for this file. f.q an be rebuilt from f.tcl, but we can't use the %.tcl rule to build f.tcl since that would be a pattern rule recursion (we're already using this pattern rule to build x.tcl) so it's not allowed and we have no rule to build f.tcl. Thus we have no rule to build f.q, but since f.q already exists it's OK, then we build x.tcl with $* set to "x" so $(build_$*) works as expected. Here's some debug output:

Considering target file 'x.tcl'.
File 'x.tcl' does not exist.
Looking for an implicit rule for 'x.tcl'.
Trying pattern rule with stem 'x'.
Trying implicit prerequisite 'f.q'.
Found an implicit rule for 'x.tcl'.
Considering target file 'f.q'.
Looking for an implicit rule for 'f.q'.
Trying pattern rule with stem 'f'.
Trying implicit prerequisite 'f.tcl'.
Looking for a rule with intermediate file 'f.tcl'.
Avoiding implicit rule recursion.
Trying pattern rule with stem 'f'.
Found an implicit rule for 'f.q'.
Finished prerequisites of target file 'f.q'.
Prerequisite 'f.tcl' of target 'f.q' does not exist.
No need to remake target 'f.q'.
Finished prerequisites of target file 'x.tcl'.
Must remake target 'x.tcl'.

In the "non-working" case, you again ask for x.tcl to be built. We depend on file.txt (due to $(intermediate)) and make doesn't have a rule to build it but it exists, so that's OK. Then we try to build f.q and see it can be rebuilt from f.tcl, as before.

Here's where the difference shows up. f.tcl depends now on "file.txt" and $(file_f) which is empty. Make sees that this is a pattern rule recursion as before, but for some reason the addition of the extra prerequisite "file.txt" causes make to not throw away that rule; it still decides to try to build f.tcl and because $(build_f) is not set, that fails. Here's some debug output:

Considering target file 'x.tcl'.
File 'x.tcl' does not exist.
Looking for an implicit rule for 'x.tcl'.
Trying pattern rule with stem 'x'.
Trying implicit prerequisite 'file.txt'.
Trying implicit prerequisite 'f.q'.
Found an implicit rule for 'x.tcl'.
Considering target file 'file.txt'.
Looking for an implicit rule for 'file.txt'.
No implicit rule found for 'file.txt'.
Finished prerequisites of target file 'file.txt'.
No need to remake target 'file.txt'.
Considering target file 'f.q'.
Looking for an implicit rule for 'f.q'.
Trying pattern rule with stem 'f'.
Trying implicit prerequisite 'f.tcl'.
Looking for a rule with intermediate file 'f.tcl'.
Avoiding implicit rule recursion.
Trying pattern rule with stem 'f'.
Trying implicit prerequisite 'file.txt'.
Found an implicit rule for 'f.q'.
Pruning file 'file.txt'.
Considering target file 'f.tcl'.
File 'f.tcl' does not exist.
Pruning file 'file.txt'.
Finished prerequisites of target file 'f.tcl'.
Must remake target 'f.tcl'.
<fails>

Note that even though we say "Avoiding implicit rule recursion" we still think we found a rule to build f.tcl.

I think there's something wonky about implicit rule recursion and
secondary expansion.

As a workaround, define an explicit rule for it;
add:

f.tcl: ;

and then it will work.

Patatti <patatti>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by patatti (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    No Changes Have Been Made to This Item

    Back to the top


    Powered by Savane 3.1-cleanup