bugmake - Bugs: bug #55533, .SECONDARY with % pattern

 
 

bug #55533: .SECONDARY with % pattern

Submitted by:  None
Submitted on:  Mon 21 Jan 2019 01:38:58 AM UTC  
Votes:  30  
 
Severity:  3 - Normal Item Group:  Enhancement
Status:  None Privacy:  Public
Assigned to:  None Open/Closed:  Open
Component Version:  None Operating System:  Any
Fixed Release:  None Triage Status:  None

Add a New Comment (Rich Markup)
   

You are not logged in

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

 

Mon 21 Jan 2019 01:51:09 AM UTC, comment #1: 

The correct command of 'Result 2' is as follows:

Result 2
--------
$ rm -f a.*
$ touch a.zzz
$ make a.xxx
cp a.zzz a.yyy
cp a.yyy a.xxx
rm a.yyy

Anonymous
Mon 21 Jan 2019 01:38:58 AM UTC, original submission:  

GNU Make automatically deletes intermediate files that are updated in a chain of pattern rules.

People tend to abuse .PRECIOUS to suppress the deletion of
the intermediate patterns.

In the following test code, %.yyy is an intermediate pattern.

Test code 1
-----------

%.xxx: %.yyy
[ TAB ] cp $< $@

%.yyy: %.zzz
[ TAB ] cp $< $@

.PRECIOUS: %.yyy

Result 1
--------

$ touch a.zzz
$ make a.xxx
cp a.zzz a.yyy
cp a.yyy a.xxx

It is true that it can suppress the automatic deletion of %.yyy,
but it is not the correct usage of .PRECIOUS.

The use of .PRECIOUS is quite rare because it may leave partially constructed (i.e. corrupted but its timestamp says
it is up-to-date) files when GNU Make is interrupted.

I know why people tend to abuse .PRECIOUS;
it is because .SECONDARY does not work against % pattern.

Test code 2
-----------

%.xxx: %.yyy
[ TAB ] cp $< $@

%.yyy: %.zzz
[ TAB ] cp $< $@

.SECONDARY: %.yyy

Result 2
--------

$ rm -f a.*
$ touch a.zzz
cp a.zzz a.yyy
cp a.yyy a.xxx
rm a.yyy

The prerequisites of the .SECONDARY target must be explicit
file paths or nothing.

(.SECONDARY with no prerequisites causes all targets to be treated as secondary.)

But, considering the motivation of .SECONDARY, I believe it would be a good improvement to make .SECONDARY work with % pattern.

Anonymous

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by alexeicolin
  •  

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

    Only logged-in users can vote.

     

     

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-03-18 alexeicolin Carbon-Copy- => Added alexeicolin

    Back to the top


    Powered by Savane 3.5