I'm connected to my university's small Linux cluster via PuTTY and WinSCP, transferring files using the latter and compiling and running them with the former. My work so far has been performed in the university's labs, but today I have been doing some work at home that generated an interesting warning.
I uploaded an entire folder of stuff and, upon running the make
command, I get this as the last line of output:
make: warning: Clock skew detected. Your build may be incomplete.
The resulting binary works correctly, and there doesn't seem to be any other unexpected errors in the build process.
I seem to be able to trigger the error by building after uploading some new / replacement files (I edit everything locally then upload the new version), so I'm wondering if it's something just as simple as mismatched file modification times? Or something more concerning?
So, should I be worried? How do I fix/prevent this?
This is usually simply due to mismatching times between your host and client machines. You can try to synchronize the times on your machines using ntp.
Make checks if the result of the compilation, e.g. somefile.o, is older than the source, e.g. somefile.c. The warning above means that something about the timestaps of the files is strange. Probably the system clocks of the University server differs from your clock and you e.g. push at 1 pm a file with modification date 2 pm. You can see the time at the console by typing date.
That message is usually an indication that some of your files have modification times later than the current system time. Since
make
decides which files to compile when performing an incremental build by checking if a source files has been modified more recently than its object file, this situation can cause unnecessary files to be built, or worse, necessary files to not be built.However, if you are building from scratch (not doing an incremental build) you can likely ignore this warning without consequence.
This happened to me. It's because I ran
make -j 4
and some jobs finished out of order. This warning should be expected when using the-j
option.The other answers here do a good job of explaining the issue, so I won't repeat that here. But there is one solution that can resolve it that isn't listed yet: simply run
make clean
, then rerunmake
.Having make remove any already compiled files will prevent make from having any files to compare the timestamps of, resolving the warning.
Install the Network Time Protocol
This also happened to me when running
make
on a Samba SMB CIFS share on a server. A durable solution consists in installing thentp
daemon on both the server and the client. (Please, note that this problem is not solved by runningntpdate
. This would resolve the time difference only temporarily, but not in the future.)For Ubuntu and Debian-derived systems, simply type the following line at the command line:
Moreover, one will still need to issue the command
touch *
once (and only once) in the affected directory to correct the file modification times once and for all.For more information about the differences between
ntp
andntpdate
, please refer to: