My preference is to always do rebuilds from a single make in the outer
directory. My makefile uses gcc to build dependency files for the C
files, then some sed magic to make even the dependency files have the
correct dependencies, so that they don't need rebuilt unnecessarily either.
Having to manually re-build in different directories in different orders
is a pain and a source of error.
>
>>> The biggest improvement that I have ever gotten on building is moving to
>>> a SSD drive. I now have a Intel 480 GB SSD. Fastest thing that I have
>>> ever seen. Jeff Atwood says that the new PCI Express SSD drives are
>>> even much faster than SATA SSD drives.
>>>
http://blog.codinghorror.com/building-a-pc-part-viii-iterating/
>>
>> It's a pity you are stuck on Windows for MSVC - if you were using Linux,
>> the disk speed would mean almost nothing at all (at least with a little
>> care in setup). Windows is poor at cache management, and will keep
>> re-reading files from disk instead of keeping them in memory
> ...
>
> That matches my experience from a decade ago; are you saying it hasn't
> improved?
I gather it has improved, but in my experience (which does not include
Win10), Windows is a long way behind Linux in this area.
>
>> The biggest improvement I made on compile speed was moving from Windows
>> to Linux.
>
> But I think on your average project, the best improvement you can get
> is from getting the build system into shape. Where I've worked, the
> main reason for long compilation times has been that things get
> rebuilt unnecessarily. And bad build systems seem to be the norm ...
>
Agreed.
For example, Eclipse has automatic dependency building in its project
management - when you press "build", it will check through all the
files, see which include files are used by each C file, see which are
changed, and then re-compile only those C files that depend on header
files that have changed, or where the C file itself has changed. That
makes it quick and reliable, without having to handle dependencies
manually or run update passes.
However, it is much faster if you track those dependencies, and only
re-check the C and header files when actually required. So a more
intelligent Makefile can speed up this dependency checking
significantly, and for large projects with regular rebuilds, it is the
dependency calculations that take time.