[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Fri, 6 Feb 2004 11:09:36 -0600
I think I found a flaw in a so-called "advanced auto-dependencies"
generation technique. To start, consider this small excerpt from the
"Since we know some prerequisite of the target changed, we don't really
need the updated prerequisite list in this build. We already know that
we're going to rebuild the target, and having a more up-to-date list
won't affect that decision. What we really need is to ensure that the
prerequisite list is up-to-date for the next invocation of make, when
we need to decide whether to update it again."
This reasoning ignores the case when some of the prerequisites may not
exist and should in turn be built. In this case we do need up-to-date
dependency list in this build.
The following example illustrates this situation. Suppose we have
'hello.idl' which can be compiled to 'hello_stub.hpp' and 'hello_stub.cpp'.
Plus we have 'client.cpp' which includes 'hello_stub.hpp' and gets compiled
into client.o. Finally, 'client.o' and 'hello_stub.o' are used to produce
client : client.o hello_stub.o
g++ -o $@ $^
-include client.o.d # dependencies for client.o
-include hello_stub.o.d # dependencies for hello_stub.o
hello_stub.hpp hello_stub.cpp : hello.idl
In the makefile fragment above I assume that there is an implicit rule
to compile .cpp to .o and generate dependencies at the same time.
Now let's see what happens when we try to build this project for the
first time. Make will ignore cleint.o.d and hello_stub.o.d since they
don't exist and there is no rule to build them. Then make proceeds to
build 'client' which depends on 'client.o' and 'hello_stub.o'. Since
there is an implicit rule to build .o from .cpp make readily executes
the command to compile 'client.cpp'. Do you see the problem?
'hello_stub.hpp' does not exist and it is included by 'client.cpp'.
But make has no idea about this dependency (since we decided it doesn't
need to know ;-).
Also note that this problem arise not only in the first build. Every time
you add a dependency (for example include a header) that does not merely
exist but should be built you will face this problem.
Description: Digital signature
- advanced auto-dependencies,
Boris Kolpackov <=