Question

How robust is the make utility?

For example, while "making" something, if the computer loses power, and make is resumed after the next computer start, is the output guaranteed to be correct (even if the file system is not robust)? Are there any other situation in which make may fail?

Was it helpful?

Solution

Make is writing to the file system while it's running. Therefore if it is interrupted (for instance if the computer loses power or the user kills the process) in the middle of doing that, incomplete files might be written to the file system, unless the file system has some kind of mechanism preventing this (ZFS for instance).

GNU Make itself does not detect whether or not a file is incomplete or broken. As long as it is present in the file system with a timestamp Make considers it being complete.

OTHER TIPS

Essentially, no.

Make tries to determine whether a target is "up to date" by a mechanism which can be fooled in some circumstances if the destination file had been partially written. Partial writes are possible if the power fails, and the OS may have updated the timestamp, so "make" can get it wrong.

It would be technically feasible for a tool used by make (e.g. a compiler, linker) to be safe by using atomic operations and syncing everything to disc. However, every tool would have to be safe for "make" to be safe.

Also syncing everything would slow compilation down a lot, probably.

GNU Make is as robust as the tools underneath it. If a target has a current date/time then Make will consider it complete even if it only contains partial output.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top