[CMake] Obtaining improved GNU make performance on Makefiles generated by cmake
Bill Hoffman
bill.hoffman at kitware.com
Mon Mar 17 21:22:21 EDT 2008
Alan W. Irwin wrote:
> The GNU make documentation states the following:
>
> Since it knows that phony targets do not name actual files that
> could be remade from other files, make skips the implicit rule search
> for phony targets.... This is why declaring a
> target phony is good for [make] performance....
>
> Also,
>
> Using .PHONY' is more explicit and more efficient. However, other
> versions of make' do not support .PHONY'; thus FORCE (an arbitrarily
> named rule with no prerequisites or rules) appears in
> many makefiles.
>
> As part of another investigation I searched a Linux build tree created by
> cmake (2.4.8) and was surprised to find no reference to .PHONY. Instead,
> the makefile generator on Linux is using the same method as FORCE idea
> above, i.e., a rule called cmake_force with no prerequisites or commands to
> serve as a prerequisite to rules that must be run every time.
>
> CMake is missing a bet on Linux systems to reduce Makefile overhead
> since it
> is using this cmake_force approach rather than the preferred more
> efficient.PHONY approach for rules that must be run every time. Since the
> Makefiles generated by cmake have an extremely large number of such rules,
> Makefile latency may be significantly reduced by this method on Linux (GNU
> make) systems.
>
> If the cmake developers here like this idea (or at least don't strongly
> dislike it), I will go ahead and make a feature request so it doesn't get
> lost.
>
CMake is written to generic make, and I don't think we would want to add
something that only worked with gmake. The trouble is the make you are
using can change after CMake is run, so we can not even test for the
version of make being used. I guess if it was a big enough performance
gain, we could add some sort of option to allow for this. However, I
would want to make sure that there would be a good payback. So far the
cmake makefiles outperform the autotools ones quite well, and
performance has not been an issue. Do you think you are having a
performance problem?
-Bill
More information about the CMake
mailing list