bugmake - Bugs: bug #46596, Timestamp check behaviour...

 
 

bug #46596: Timestamp check behaviour difference in clean build and rebuild on rules without recipes

Submitter:  Stefan Becker <stefanb>
Submitted:  Thu 03 Dec 2015 07:58:39 AM UTC
   
 
Severity:  3 - Normal Item Group:  Bug
Status:  Duplicate Privacy:  Public
Assigned to:  None Open/Closed:  Closed
Component Version:  4.1 Operating System:  None
Fixed Release:  None Triage Status:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 11 Apr 2016 02:36:27 PM UTC, comment #4: 

You can simplify your example down to this:


all: a

a: b ; cp $< $@

b: c

c: ; touch b


In this makefile you're lying to make by telling it that running the final recipe will create a target "c", but in reality it doesn't do that; it creates a target "b".

Make knows of no way to create target "b" itself (because the rule for "b" has no recipe).

I think this may be an example of bug #41273; when the "b" file already exists on disk then the last modified time will be cached internally to make.  Because there is no recipe to update the "b" target, make will never invalidate the cached modified time for "b".  So, if the timestamp of "b" when make starts up is older than "a", then "a" will not be rebuilt.  If the timestamp of "b" when make starts up is newer than "a", then "a" will be rebuilt.

Paul D. Smith <psmith>
Group administrator
Fri 04 Dec 2015 07:19:42 AM UTC, comment #3: 

Thanks

The admin may delete my posts, if he wishes to.

Anonymous
Fri 04 Dec 2015 07:14:35 AM UTC, comment #2: 

Sorry, no hidden magic, just reading 3 times through the whole text before hitting submit.

As for the markup: when you enter a new bug there shows up a "related recipe" on the left hand side. Strangely enough it does not appear when you add a comment.

Hope this helps.

Stefan Becker <stefanb>
Fri 04 Dec 2015 04:07:49 AM UTC, comment #1: 

Just curious.
How did you manage to set up this nice post and its mark-up...

given that there is no preview, or no re-edit after posting.

Is there a feature that i'm missing?

Is there a "sandbox" where I can "test" my post and preview the resulting post, after its mark-up processing.

Can I re-edit?

Or any other trick?

Are there any special privileges for admins/advanced users, to "fix" and edit existing posts?

Thanks in advance...

Note to the admin: Feel free to delete this message in a few days time... or a day or two after someone will hopefully supply a satisfactory answer.

Thanks in advance

Anonymous
Thu 03 Dec 2015 07:58:39 AM UTC, original submission:  

We encountered a difference how timestamps are handled between clean builds and rebuild depending if a rule has a recipe or not. If a rule doesn't have a recipe GNU make doesn't check the timestamp of the dependency correctly and therefore fails to trigger recipes from dependent rules.

I have checked GNU make 3.81, 4.0 and 4.1: they are all affected by this issue.

I've attached 3 makefiles that highlight the problem. We have

  • file "a" that depends on file "b"
  • file "b" is one of the files generated when file "d" is updated
  • the target for dependency "d" is file/.PHONY target "c"
  • the empty rule "b: c" makes sure that the dependencies are correct, i.e. when we ask for "a" the rule for "c" is triggered


Without recipe attached to rule "b: c" the file "a" is not updated on first rebuild, only on the second one.

Example 1 uses a .PHONY target for "c", example 2 does not. The example output is generated with make 4.1 to have the "--trace" option available.


Example 1: wrong execution on rebuild:


$ make --version
GNU Make 4.1
Built for x86_64-unknown-linux-gnu
...

# clean build
$ make clean
rm -f a b c d e
$ make --no-print-directory --trace
Makefile:21: target 'c' does not exist
make -f Makefile2
Makefile2:8: target 'd' does not exist
touch d
Makefile2:5: update target 'b' due to: d
cp d b
Makefile:7: update target 'a' due to: b
cp b a

# rebuild without source change
$ make --no-print-directory --trace
Makefile:21: target 'c' does not exist
make -f Makefile2
make[1]: Nothing to be done for 'all'.

# 1st rebuild after source change
$ touch d
$ make --no-print-directory --trace
Makefile:21: target 'c' does not exist
make -f Makefile2
Makefile2:5: update target 'b' due to: d
cp d b

# 2nd rebuild after source change
$ make --no-print-directory --trace
Makefile:21: target 'c' does not exist
make -f Makefile2
make[1]: Nothing to be done for 'all'.
Makefile:7: update target 'a' due to: b
cp b a

# 3rd rebuild after source change
$ make --no-print-directory --trace
Makefile:21: target 'c' does not exist
make -f Makefile2
make[1]: Nothing to be done for 'all'.

# check that other target doesn't trigger phony target
$ make --no-print-directory --trace all2
Makefile:24: target 'e' does not exist
touch e


Example 1: correct execution on rebuild by adding a no-op ":" recipe


# clean build
$ make clean
rm -f a b c d e
$ make --no-print-directory --trace _workaround1:=1
Makefile:21: target 'c' does not exist
make -f Makefile2
Makefile2:8: target 'd' does not exist
touch d
Makefile2:5: update target 'b' due to: d
cp d b
Makefile:14: update target 'b' due to: c
:
Makefile:7: update target 'a' due to: b
cp b a

# rebuild without source change
$ make --no-print-directory --trace _workaround1:=1
Makefile:21: target 'c' does not exist
make -f Makefile2
make[1]: Nothing to be done for 'all'.
Makefile:14: update target 'b' due to: c
:

# 1st rebuild after source change
$ touch d
$ make --no-print-directory --trace _workaround1:=1
Makefile:21: target 'c' does not exist
make -f Makefile2
Makefile2:5: update target 'b' due to: d
cp d b
Makefile:14: update target 'b' due to: c
:
Makefile:7: update target 'a' due to: b
cp b a

# 2nd rebuild after source change
$ make --no-print-directory --trace _workaround1:=1
Makefile:21: target 'c' does not exist
make -f Makefile2
make[1]: Nothing to be done for 'all'.
Makefile:14: update target 'b' due to: c
:


Example 1: correct execution on rebuild by adding an empty recipe


# clean build
$ make clean
rm -f a b c d e
$ make --no-print-directory --trace _workaround2:=1
Makefile:21: target 'c' does not exist
make -f Makefile2
Makefile2:8: target 'd' does not exist
touch d
Makefile2:5: update target 'b' due to: d
cp d b
Makefile:7: update target 'a' due to: b
cp b a

# rebuild without source change
$ make --no-print-directory --trace _workaround2:=1
Makefile:21: target 'c' does not exist
make -f Makefile2
make[1]: Nothing to be done for 'all'.

# 1st rebuild after source change
$ touch d
$ make --no-print-directory --trace _workaround2:=1
Makefile:21: target 'c' does not exist
make -f Makefile2
Makefile2:5: update target 'b' due to: d
cp d b
Makefile:7: update target 'a' due to: b
cp b a

# 2nd rebuild after source change
$ make --no-print-directory --trace _workaround2:=1
Makefile:21: target 'c' does not exist
make -f Makefile2
make[1]: Nothing to be done for 'all'.



Example 2: wrong execution on rebuild:


# clean build
$ make -f Makefile.no-phony clean
rm -f a b c d e

# rebuild without source change
$ make -f Makefile.no-phony --trace
Makefile.no-phony:23: target 'd' does not exist
touch d
Makefile.no-phony:19: update target 'c' due to: d
touch c
touch b
Makefile.no-phony:7: update target 'a' due to: b
cp b a

# 1st rebuild after source change
$ touch d
$ make -f Makefile.no-phony --trace
Makefile.no-phony:19: update target 'c' due to: d
touch c
touch b

# 2nd rebuild after source change
$ make -f Makefile.no-phony --trace
Makefile.no-phony:7: update target 'a' due to: b
cp b a

# 3rd rebuild after source change
$ make -f Makefile.no-phony --trace
make: Nothing to be done for 'all'.


Example 2: correct execution on rebuild by adding a no-op ":" recipe


# clean build
$ make -f Makefile.no-phony clean
rm -f a b c d e
$ make -f Makefile.no-phony --trace _workaround1:=1
Makefile.no-phony:23: target 'd' does not exist
touch d
Makefile.no-phony:19: update target 'c' due to: d
touch c
touch b
Makefile.no-phony:14: update target 'b' due to: c
:
Makefile.no-phony:7: update target 'a' due to: b
cp b a

# rebuild without source change
$ make -f Makefile.no-phony --trace _workaround1:=1
make: Nothing to be done for 'all'.

# 1st rebuild after source change
$ touch d
$ make -f Makefile.no-phony --trace _workaround1:=1
Makefile.no-phony:19: update target 'c' due to: d
touch c
touch b
Makefile.no-phony:14: update target 'b' due to: c
:
Makefile.no-phony:7: update target 'a' due to: b
cp b a

# 2nd rebuild after source change
$ make -f Makefile.no-phony --trace _workaround1:=1
make: Nothing to be done for 'all'.


Example 2: correct execution on rebuild by adding an empty recipe


# clean build
$ make -f Makefile.no-phony clean
rm -f a b c d e
$ make -f Makefile.no-phony --trace _workaround2:=1
Makefile.no-phony:23: target 'd' does not exist
touch d
Makefile.no-phony:19: update target 'c' due to: d
touch c
touch b
Makefile.no-phony:7: update target 'a' due to: b
cp b a

# rebuild without source change
$ make -f Makefile.no-phony --trace _workaround2:=1
make: Nothing to be done for 'all'.

# 1st rebuild after source change
$ touch d
$ make -f Makefile.no-phony --trace _workaround2:=1
Makefile.no-phony:19: update target 'c' due to: d
touch c
touch b
Makefile.no-phony:7: update target 'a' due to: b
cp b a

# 2nd rebuild after source change
$ make -f Makefile.no-phony --trace _workaround2:=1
make: Nothing to be done for 'all'.


Stefan Becker <stefanb>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #35624:  Makefile added by stefanb (233B - application/octet-stream - Example makefiles)
file #35625:  Makefile2 added by stefanb (48B - application/octet-stream - Example makefiles)
file #35626:  Makefile.no-phony added by stefanb (185B - application/octet-stream - Example makefiles)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by psmith (Posted a comment)
  • -email is unavailable- added by stefanb (Submitted the item)
  •  

    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 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-04-11 psmith StatusNone Duplicate
        Open/ClosedOpen Closed
    2015-12-03 stefanb Attached File- Added Makefile, #35624
        Attached File- Added Makefile2, #35625
        Attached File- Added Makefile.no-phony, #35626

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code