Make seems to compare a file modification time with some sort of internal cache of modification times. Does anyone know where is this cache located or how to access it?
The data in a cache is generally stored in fast access hardware such as RAM (Random-access memory) and may also be used in correlation with a software component. A cache's primary purpose is to increase data retrieval performance by reducing the need to access the underlying slower storage layer.
There is no cache.
In modern computers, the cache memory is stored between the processor and DRAM; this is called Level 2 cache. On the other hand, Level 1 cache is internal memory caches which are stored directly on the processor.
It depends on the OS. I believe it is in ~\AppData\Local\pip\cache on Windows. A cache is not always human-readable, as in this case.
Use a utility such as strace
to see what it's doing. Here we can follow all file actions (-e trace=file
) that the make program performs.
Let's say that we have foo.c
and a foo
which is built from it using a simple Makefile that looks like:
$ cat Makefile
foo: foo.c
Let's run make
:
$ strace -e trace=file make
execve("/usr/bin/make", ["make"], [/* 20 vars */]) = 0
...
open("Makefile", O_RDONLY) = 3
stat("Makefile", {st_mode=S_IFREG|0644, st_size=11, ...}) = 0
...
stat("foo", 0x7ffd4373c8c0) = -1 ENOENT (No such file or directory)
stat("foo.c", {st_mode=S_IFREG|0644, st_size=36, ...}) = 0
cc foo.c -o foo
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=27717, si_status=0, si_utime=0, si_stime=0} ---
stat("foo", {st_mode=S_IFREG|0755, st_size=8549, ...}) = 0
+++ exited with 0 +++
Here you see that it checks for the existence of foo
and fails to find it, it checks for the existence of foo.c
, and it then calls the rule to compile it.
Now you can call make again, and you get slightly different results:
$ strace -e trace=file make
...
stat("foo", {st_mode=S_IFREG|0755, st_size=8549, ...}) = 0
stat("foo.c", {st_mode=S_IFREG|0644, st_size=36, ...}) = 0
make: `foo' is up to date.
+++ exited with 0 +++
If there was some kind of a cache file being used, we'd expect to see an open()
and a read()
against it. If this cache was being used between runs, then we'd expect to see a write()
to it as well.
The cache as such is your file system:
make
program reads the makefile,As it performs rules, the target it builds is expected to be updated (newer), but it moves on to the next out-of-date target from its initial inspection of the filesystem even if the target is not actually updated.
Re-executing make
forces it to start over with the analysis, using the current state of your file system.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With