bugmake - Bugs: bug #12331, .SECONDARY affects behavior of a...

 
 

bug #12331: .SECONDARY affects behavior of a .PHONY target

Submitter:  None
Submitted:  Tue 15 Mar 2005 05:13:28 PM UTC
   
 
Severity:  3 - Normal Item Group:  Bug
Status:  Fixed Privacy:  Public
Assigned to:  psmith Open/Closed:  Closed
Component Version:  4.0 Operating System:  POSIX-Based
Fixed Release:  3.81 Triage Status:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Mon 22 Jan 2007 07:23:49 PM UTC, comment #8: 

Hi!

I would like to know if this bug was really solved and how can I test its solution.

Currently I have a makefile generator that used to generate makefiles that works fine with make 3.80 but I am having problems with FORCE targets in make 3.81.

As the makefile generator always generates a .SECONDARY target that is usually empty, I've change the generation rule to populate .SECONDARY with some dependencies and after that the FORCE targets return to be executed correctly, just as it is written in this bug report.

Any help in this subject should be appreciated!

Best regards,

Leonardo Garcia

Leonardo Garcia <laggarcia>
Sat 28 May 2005 08:04:57 AM UTC, comment #7: 

I've run into what appears to be this problem with 3.81beta2.  I've just built from CVS and it seems to be fixed there.  make --version reports 3.81beta3.

(Just noting this for the benefit of anyone else who tries 3.81beta2 and, like me, panics thinking that 3.81 might change the behavior in this area over 3.80.)

-email is unavailable-

Anonymous
Thu 07 Apr 2005 08:24:01 PM UTC, comment #6: 

OK, I applied the fix to allow .PHONY to take precedence over intermediate.

The rest of the items will need to wait until the next version of GNU make to consider.  Probably we should open a new enhancement request about this, referencing this bug#.

Paul D. Smith <psmith>
Group administrator
Wed 16 Mar 2005 08:25:21 AM UTC, comment #5: 

I did some more investigation on this. It appears that historically, make treated the .SECONDARY as Bill Curry stated in the bug #2515. Th
is behavior changed between 3.79 and 3.79.1. However, this new behavior has also had a significant lifespan (almost 5 years since the 3.79.1 was released). Therefore, I would suggest that both these behaviors need to be accomodated.

I agree that the behavior of the .SECONDARY target needs to be restored to historical: it used to work this way. The behavior the .SECONDA
RY target had in 3.79.1 and 3.80 could be preserved in the following ways:

1. Give .PHONY a precedence over .SECONDARY. This will cause make's behavior to differ in new-style (.PHONY) and old-style (FORCE:) declar
ations of phony targets. This will also be consistent with current make.info: .PHONY will actually make its prerequisites updated uncondit
ionally (as it is stated in .PHONY description), and .SECONDARY will apply 'intermediate file' semantics to all targets (including FORCE:)
. The only thing to update is the `Rules without Commands or Prerequisites' chapter: it will need to say that the behavior will differ in
the presence of .SECONDARY target.

2. This behavior could be transferred to a, say, .PRECIOUS target without prerequisites. Currently, .PRECIOUS without prerequisites is a n
o-op. This will give it the sense that "all files are precious".

3. A new target could be created, e.g. .PRECIOUS_ALL. Its mere appearance in a makefile will prevent make from deleting any intermediate f
ile.

4. Introduce a set of orthogonal targets. E.g. .KEEP_INTERMEDIATE; allow .INTERMEDIATE without prerequisites (marking all targets are intermediate), describe .SECONDARY as an alias to .INTERMEDIATE+.KEEP_INTERMEDIATE.

I would prefer either (1) as being the least intrusive or (4) as being the most correct in the sense of orthogonality.

Once the path is chosen, I will provide a patch.

Alexey Neyman <stilor>
Wed 16 Mar 2005 07:32:55 AM UTC, comment #4: 

Comments by Paul D.Smith in an email:

Hm.  This solves the problem for .PHONY files, but what if you use the old-style FORCE target method to force rebuilds:

    FORCE: ;
    version.c: FORCE

This doesn't work with .SECONDARY set globally: it thinks FORCE doesn't need to be remade (even though it doesn't exist), so version.c doesn't need to be remade, etc.

Unfortunately it's not exactly clear from the documentation (which is all I have to go on) what it means to set .SECONDARY globally.  If you take the documentation at face value, the current (3.81) behavior is correct and the bug you're reporting is actually an enhancement request, that marking a target as .PHONY take precedence over .SECONDARY and .INTERMEDIATE, whereas right now it's the other way around.  Which is fine with me as a change, BTW.


However, I'm not sure that's really what the original intent of the global .SECONDARY target was... or else I'm not sure all the ramifications were completely thought out.  Note you cannot define a global .INTERMEDIATE target!  Why, then, can you define .SECONDARY globally, that imputes all the behavior of .INTERMEDIATE to all targets in the system--except for automatic deletion?  It seems strange and unusual to me.

I have to wonder if the original point of the global .SECONDARY was really just to turn off all automatic deletions of any intermediate files, without really forcing every target to be considered intermediate. To me that would make more sense.


On the other hand, if you read the information provided with bug # 2515, which originally fostered this change, Bill Curry (the author of the bug) clearly feels that the former ("face value" reading) of the docs is correct and is what RMS intended when he introduced the feature, apparently at the request of the project that Bill is working on.  So, I guess maybe that is correct.  I personally would probably have implemented this differently, because it seems that we have a matrix of two different capabilities (delete/don't delete intermediates, and build/don't build non-existent files) and the current set of targets to set the capabilities doesn't cover the entire matrix: there are some things you can't do.  I would have preferred to define the targets in a more orthogonal manner to cover the entire matrix.  Then you could have used them in combination to get the behavior you wanted more precisely.

Alexey Neyman <stilor>
Tue 15 Mar 2005 05:32:16 PM UTC, comment #3: 

Sorry, the previous comment should have said 'version target needs to be rebuilt unconditionally'.

Alexey Neyman <stilor>
Tue 15 Mar 2005 05:30:38 PM UTC, comment #2: 

Attached suggested patch (with a testcase)

This behavior was introduced by the revision 1.69 of the 'file.c' file. This revision made .SECONDARY target not only set the 'all_secondary' variable to 1, but also sets ->intermediate flag on all files. Therefore, the check_dep() function in remake.c doesn't notice that
version.c needs to be rebuilt unconditionally (mtime == NONEXISTENT_MTIME).

Alexey Neyman <stilor>
Tue 15 Mar 2005 05:20:29 PM UTC, comment #1: 

Attached a testcase.

$ make all
GOOD
$ touch version2
$ make all
make: Nothing to be done for `all'.

(as version2 depends on a phony target, it should be remade even if it exists)

Alexey Neyman <stilor>
Tue 15 Mar 2005 05:13:28 PM UTC, original submission:  

A .PHONY target is not rebuilt if there is .SECONDARY target without prerequisites in the Makefile.

Anonymous

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #2734:  patch added by stilor (1KiB - text/x-diff - Suggested patch.)
file #2733:  Makefile added by stilor (74B - text/x-makefile - test case)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by laggarcia (Posted a comment)
  •  

    There are 0 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.

     

    Follow 9 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2007-01-22 laggarcia Carbon-Copy- Added -email is unavailable-
    2006-04-01 psmith Fixed Release4.0 3.81
    2005-04-07 psmith StatusNone Fixed
        Assigned toNone psmith
        Open/ClosedOpen Closed
        Fixed ReleaseNone 4.0
    2005-03-15 stilor Attached File- Added patch, #2312
        Carbon-Copy- Added -email is unavailable-
    2005-03-15 stilor Attached File- Added Makefile, #2311

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code