URL: <http://savannah.gnu.org/bugs/?30505>
Summary: Make doesn't update the entire dependency chain? Project: make Submitted by: glywood Submitted on: Wed 21 Jul 2010 07:43:12 AM GMT Severity: 3 - Normal Item Group: Bug Status: None Privacy: Public Assigned to: None Open/Closed: Open Discussion Lock: Any Component Version: 3.81 Operating System: POSIX-Based Fixed Release: None Triage Status: None _______________________________________________________ Details: I have found a case where 'make' will update a target, and then fail to update things that depend on that target. Consider the following Makefile (also attached in case the indentation gets messed up): all: test PREVIOUS_VAR := $(shell cat previous_var) ifneq ($(PREVIOUS_VAR),$(VAR)) previous_var: echo $(VAR) > previous_var .PHONY: previous_var endif test: test.o $(LD) -o test test.o test.o: test.c previous_var $(CC) -o test.o test.c As you can see, the Makefile attempts to remember the value of VAR= that was passed in on the command line, and rebuild the 'test' program whenever the value changes. Now, lets try it out: /source/test $ make VAR=abc cat: previous_var: No such file or directory echo abc > previous_var cc -o test.o test.c ld -o test test.o /source/test $ make VAR=abc make: Nothing to be done for `all'. /source/test $ make VAR=def echo def > previous_var cc -o test.o test.c ld -o test test.o All is looking good so far. However: /source/test $ while true ; do make VAR=abc ; make VAR=def ; done echo abc > previous_var cc -o test.o test.c ld -o test test.o echo def > previous_var cc -o test.o test.c echo abc > previous_var cc -o test.o test.c echo def > previous_var cc -o test.o test.c echo abc > previous_var cc -o test.o test.c ^C What happened to the link step? Why isn't it being executed anymore? Lets look at the debug output: Must remake target `test.o'. cc -o test.o test.c Putting child 0x018f3120 (test.o) PID 3074 on the chain. Live child 0x018f3120 (test.o) PID 3074 Reaping winning child 0x018f3120 PID 3074 Removing child 0x018f3120 PID 3074 from chain. Successfully remade target file `test.o'. Finished prerequisites of target file `test'. Prerequisite `test.o' is older than target `test'. No need to remake target `test'. How can 'test.o' possibly be older than 'test'? 'test.o' just got rebuilt! It's the newest thing on the entire system. _______________________________________________________ File Attachments: ------------------------------------------------------- Date: Wed 21 Jul 2010 07:43:12 AM GMT Name: Makefile Size: 243B By: glywood <http://savannah.gnu.org/bugs/download.php?file_id=21019> _______________________________________________________ Reply to this item at: <http://savannah.gnu.org/bugs/?30505> _______________________________________________ Message sent via/by Savannah http://savannah.gnu.org/ _______________________________________________ Bug-make mailing list Bug-make@gnu.org http://lists.gnu.org/mailman/listinfo/bug-make