bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Non existing target not marked as new


From: Raz Manor
Subject: RE: Non existing target not marked as new
Date: Thu, 9 Feb 2017 08:16:23 +0000

Hi,
Unfortunately I can't send you my makefile as it gives up company IP.
Also my makefile is not a direct copy-past, but an implementation of the method 
described in the article.
However I can assure you I checked that the -include directive uses the correct 
%.d files.

What I can tell you is this:
1. I have a rule to make .o files:
build/common/%.o: ../common/%.cpp build/common/%.d

2. I also have a rule to make executables:
build/%: build/%.o

3. I have file named ../common/tests/timer_test.cpp which is used to build 
build/common/tets/timer_test using the above rules

4. I build the project, creating build/common/tests/timer_test.o, 
build/common/tests/timer_test.d and build/common/tests/timer_test

5. I deleted build/common/tests/timer_test.d

6. I run make build/common/tests/timer_test -d --dry-run --no-builtin-rules

7. I get the output:
GNU Make 4.1
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Reading makefiles...
.....
Reading makefile 'build/common/tests/timer_test.d' (search path) (don't care) 
(no ~ expansion)...
.....
Updating makefiles....
Considering target file 'build/common/tests/timer_test.d'.
  File 'build/common/tests/timer_test.d' does not exist.
  Looking for an implicit rule for 'build/common/tests/timer_test.d'.
  Trying pattern rule with stem 'common/tests/timer_test.d'.
  Trying implicit prerequisite 'build/common/tests/timer_test.d.o'.
  Trying pattern rule with stem 'timer_test'.
  Found an implicit rule for 'build/common/tests/timer_test.d'.
  Finished prerequisites of target file 'build/common/tests/timer_test.d'.
 Must remake target 'build/common/tests/timer_test.d'.
 Successfully remade target file 'build/common/tests/timer_test.d'.
Considering target file 'Makefile'.
  Looking for an implicit rule for 'Makefile'.
  No implicit rule found for 'Makefile'.
  Finished prerequisites of target file 'Makefile'.
 No need to remake target 'Makefile'.
Updating goal targets....
Considering target file 'build/common/tests/timer_test'.
 Looking for an implicit rule for 'build/common/tests/timer_test'.
 Trying pattern rule with stem 'common/tests/timer_test'.
 Trying implicit prerequisite 'build/common/tests/timer_test.o'.
 Found an implicit rule for 'build/common/tests/timer_test'.
  Considering target file 'build/common/tests/timer_test.o'.
   Looking for an implicit rule for 'build/common/tests/timer_test.o'.
   Trying pattern rule with stem 'tests/timer_test'.
   Trying implicit prerequisite '../common/tests/timer_test.cpp'.
   Trying implicit prerequisite 'build/common/tests/timer_test.d'.
   Found an implicit rule for 'build/common/tests/timer_test.o'.
    Considering target file '../common/tests/timer_test.cpp'.
     Looking for an implicit rule for '../common/tests/timer_test.cpp'.
     No implicit rule found for '../common/tests/timer_test.cpp'.
     Finished prerequisites of target file '../common/tests/timer_test.cpp'.
    No need to remake target '../common/tests/timer_test.cpp'.
   Finished prerequisites of target file 'build/common/tests/timer_test.o'.
   Prerequisite '../common/tests/timer_test.cpp' is older than target 
'build/common/tests/timer_test.o'.
   Prerequisite 'build/common/tests/timer_test.d' of target 
'build/common/tests/timer_test.o' does not exist.
  No need to remake target 'build/common/tests/timer_test.o'.
  Pruning file 'build/common/tests/timer_test.o'.
 Finished prerequisites of target file 'build/common/tests/timer_test'.
 Prerequisite 'build/common/tests/timer_test.o' is older than target 
'build/common/tests/timer_test'.
 Prerequisite 'build/common/tests/timer_test.o' is older than target 
'build/common/tests/timer_test'.
 Prerequisite 'build/common/linux/timer.o' is older than target 
'build/common/tests/timer_test'.
No need to remake target 'build/common/tests/timer_test'.
make: 'build/common/tests/timer_test' is up to date.

I removed the other .d files includes but that’s the idea.
Note the line Prerequisite 'build/common/tests/timer_test.d' of target 
'build/common/tests/timer_test.o' does not exist.
And the one right after it  No need to remake target 
'build/common/tests/timer_test.o'

I hope this gives you enough information.

Thanks,
Raz

-----Original Message-----
From: Paul Smith [mailto:address@hidden 
Sent: Thursday, February 9, 2017 7:52 AM
To: Raz Manor <address@hidden>; address@hidden
Subject: Re: Non existing target not marked as new

On Wed, 2017-02-08 at 13:48 +0000, Raz Manor wrote:
> I created a makefile using instructions for this post: http://make.mad 
> -scientist.net/papers/advanced-auto-dependency-generation/
> To test it, I make all my files, then deleted one .d file and touched 
> one of the header files present in that .d file.
> The target, however, was not rebuilt.
>  
> Running with -d, I found that the empty rule to make %.d files, ran 
> the first time the %.d file was needed, in the -include directive.
> Than the target was marked as built by make, so the second time it was 
> needed, when building the .o file, the empty recipe was not re-run.
> However, since the .d file still didn’t exist, the .o file was not 
> rebuilt.

I'm not able to understand from this description what exactly you are seeing.  
Maybe you can provide a small reproducible example.

When I tried a simple example and deleted any .d file, without even touching 
any header file, the object file is rebuilt (which also rebuilds the .d file as 
a side-effect).  This is the intended behavior:
since the .d file is missing we can't know what the dependencies are and we 
have to assume the object file must be rebuilt.

One thing that maybe should be made more clear and obvious in that page is the 
need to set the SRCS variable.  At the very end of the sample makefile you'll 
see the line:

  -include $(patsubst %,$(DEPDIR)/%.d,$(basename $(SRCS)))

This line requires that the make variable SRCS be set to the list of source 
files, otherwise nothing will work.  Since that's down at the end of the 
makefile if you don't read carefully the rest of that section:

> Also, this assumes the SRCS variable contains all the source files 
> (not header files) you want to track dependencies for.

then you might miss it.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]