tech-toolchain archive

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

Re: make: ignore stale .depend



On Thu, 25 Nov 2010 12:16:26 +1100, matthew green writes:
> ... is this going to help
>builds from always-building files when there are stale depends?  eg,

No, but automatically updating .depend when you do the build does:

$ make
$ make
$ cp _depend /c/sjg/work/bt/obj/freebsd7-i386/buildtools/tests/stale/.depend
$ make
make: ignoring stale .depend for 
/c/sjg/work/bt/src/buildtools/tests/stale0/foo.c
make: ignoring stale .depend for 
/c/sjg/work/bt/src/buildtools/tests/stale0/foo.h
make: ignoring stale .depend for 
/c/sjg/work/bt/src/buildtools/tests/stale0/goo.c
make: ignoring stale .depend for 
/c/sjg/work/bt/src/buildtools/tests/stale0/h/goo.h
make: ignoring stale .depend for goo.h
cc -O2 -I/c/sjg/work/bt/src/buildtools/tests/stale2/h    -MD -MF goo.d -MT 
goo.o   -c /c/sjg/work/bt/src/buildtools/tests/stale2/goo.c
cc   -o stale  -Wl,-rpath,/usr/lib:/usr/lib main.o foo.o goo.o 
$ make
$ make
$ cp _depend /c/sjg/work/bt/obj/freebsd7-i386/buildtools/tests/stale/.depend
$ make
make: ignoring stale .depend for 
/c/sjg/work/bt/src/buildtools/tests/stale0/foo.c
make: ignoring stale .depend for 
/c/sjg/work/bt/src/buildtools/tests/stale0/foo.h
make: ignoring stale .depend for 
/c/sjg/work/bt/src/buildtools/tests/stale0/goo.c
make: ignoring stale .depend for 
/c/sjg/work/bt/src/buildtools/tests/stale0/h/goo.h
make: ignoring stale .depend for goo.h
cc -O2 -I/c/sjg/work/bt/src/buildtools/tests/stale2/h    -MD -MF goo.d -MT 
goo.o   -c /c/sjg/work/bt/src/buildtools/tests/stale2/goo.c
cc   -o stale  -Wl,-rpath,/usr/lib:/usr/lib main.o foo.o goo.o 
$ make
$ make

>can it be as simple as saying if a depend file has stale depends, then
>that file is out of date and should be rebuilt?  that would at least
>make it fixed the _next_ time i built, i think.

Only if you update .depend as a consequence (as above).

With meta mode (now in NetBSD make), you get this automatically, the
.meta files largely replace .depend, and are updated as a consequence of
building.  Even better, since they capture any errors, you can have a
.ERROR target copy the relevant .meta file to an errors/ dir for easier
automated failure analysis.

I was looking at meta.c earlier, and noted that it should probably
consider a target oodate, if one of the referenced files is now missing.
Which is exactly what you mentioned above ;-)

BTW, without the change to targ.c, you get:

$ cp _depend /c/sjg/work/bt/obj/freebsd7-i386/buildtools/tests/stale/.depend
$ make
make: ignoring stale .depend for 
/c/sjg/work/bt/src/buildtools/tests/stale0/foo.c
make: ignoring stale .depend for 
/c/sjg/work/bt/src/buildtools/tests/stale0/foo.h
cc -O2 -I/c/sjg/work/bt/src/buildtools/tests/stale2/h    -MD -MF foo.d -MT 
foo.o   -c /c/sjg/work/bt/src/buildtools/tests/stale0/foo.c
cc: /c/sjg/work/bt/src/buildtools/tests/stale0/foo.c: No such file or directory
cc: No input files specified
*** Error code 1

and you cannot get past that until you remove the .depend file.

Again, this error probably only occurs if you use gcc -M to gather
dependencies automagically, in which case the path to the .c is recored,
but then if you don't do that, you have the problem you mentioned where
things re-build all the time because of stale .depend

Thanks
--sjg


Home | Main Index | Thread Index | Old Index