How robust is make?

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?

Answers


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.


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.


Need Your Help

How to distribute updates to users of pre-installed paid Android App?

android google-play

I wrote a small Android app. It is published on Google Play as two distinct versions

Porting OpenGL project from Visual Studio to Xcode

visual-studio xcode opengl opengl-es

I'm in the process of converting/migrating a Visual Studio OpenGL project to an Xcode (iPhone) OpenGL project.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.