用于strace
此目的:
strace -e trace=stat make --touch
第一次运行的输出(完整构建):
...
stat("a.o", 0x7fff70c35f00) = -1 ENOENT (No such file or directory)
stat("h1.h", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
stat("h2.h", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
touch a.o
stat("b.o", 0x7fff70c35f00) = -1 ENOENT (No such file or directory)
touch b.o
第二次运行(增量构建):
...
stat("a.o", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
stat("h1.h", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
stat("h2.h", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
stat("b.o", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
make: Nothing to be done for `all'.
如您所见,GNU Make 缓存时间戳以避免不必要stat
的系统调用。但是,我想,在使用递归 make 的情况下,事情就不那么好了。