Mohammad Rahimi
Mohammad Rahimi

Reputation: 1113

Do I need to do `make clean` if i press Ctrl + C

I'm compiling a very large code base. If I press Ctrl+C in the middle of make process, do I need to run make clean before continuing the make process. What if the host computer runs out of memory and I had to do hard shut down? I have searched a lot but there are very few suggestions on when someone should do make clean and they are all kinda unclear.

Upvotes: 1

Views: 616

Answers (1)

John Bollinger
John Bollinger

Reputation: 181149

I have searched a lot but there are very few suggestions on when someone should do make clean and they are all kinda unclear.

There cannot be any universal guidance because the effect of make clean depends on the makefile involved. Even the existence of a 'clean' target is merely a convention.

Generally speaking, however, make clean conventionally serves two main purposes:

  1. Getting rid of built files to free space.
  2. Getting rid of built files to overcome makefile shortcomings that prevent make from recognizing when some targets need to be rebuilt.

If your makefile accurately and completely represents all your project's build dependencies then the latter is not relevant, but the larger your project is, the harder it is to be confident about the completeness of your build rules.

If I press Ctrl+C in the middle of make process, do I need to run make clean before continuing the make process. What if the host computer runs out of memory and I had to do hard shut down?

Probably not. The risk is that the build is interrupted in a way that leaves a partially-written or otherwise corrupt new target in place. This is unlikely, and the risk does not scale with the size of the project. But if you need to be absolutely sure of a good build then the safest thing is to clean first and accept the build only if it goes all the way to completion.

Upvotes: 3

Related Questions