[PATCH] Fix build: don't recompile all C++ every time

Linus Torvalds torvalds at linux-foundation.org
Sat Oct 5 11:18:11 UTC 2013


On Sat, Oct 5, 2013 at 11:09 AM, Linus Torvalds
<torvalds at linux-foundation.org> wrote:
>
> To recap: in a pattern, the "dependencies" aren't dependencies at all.
> They are pattern matches, and while there are similarities, they are
> not the same thing. DO NOT DO IT.

To perhaps clarify things: there are cases where you really do want to
use those pattern matching things. There's two really valid cases:

 - the traditional 'yacc' pattern:

      %.tab.c %.tab.h: %.y

   here the important part to notice is that you have two output files
with a name pattern. Sometimes you have similar issues on the _input_
pattern,. so you might have something like

      %.table: %.input %.rules

   and the point is that the pattern doesn't just match any *.rules
things, the '%' parts all have to be equal.

 - the "this pattern triggers if this other thing is true" case

   For example, let's say that you want to have *different* patterns
for OS X than for Windows or for Linux. Then you can do

     %.o: %.cpp osx-build
          .. OS X-only command goes here ..

   and then you have a magic configuration thing that creates the
"osx-build" file only under OS X. Now that pattern only triggers on OS
X, and you can have *another* pattern to generate *.o files on Linux
or Windows.

Note in particular in that latter example how "osx-build" is _not_ a
dependency that gets built. It's a flag. If that flag doesn't exist,
and make doesn't see a way to build it, make will just ignore the
rule. That's very different from having a

   file.o: file.cpp osx-build

pattern that uses osx-build as a *dependency*, and make will complain
about "No rule to make target `osx-build'" if it cannot find it.

See the difference? It's subtle, but it's a *HUGE* difference.

               Linus


More information about the subsurface mailing list