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

 
 

bug #55533: .SECONDARY with % pattern

Submitter:  None
Submitted:  Mon 21 Jan 2019 01:38:58 AM UTC
Votes: 30
 
Severity:  3 - Normal Priority:  5 - 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
* Mandatory Fields

Post a Comment

Add a New Comment Rich Markup
   

Discussion

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

 

Attached Files

This item currently has no attached files.

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

Attach Files:
   
   
Comment:
   

 

Dependencies

This item does not depend on any other items.

No items depend on this one.

 

Mail Notification Carbon-Copy List

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

    Votes

    There are 30 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    History

    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.16-8b18.
    Corresponding source code