[pisa-src] ongoing build system changes

  • From: Diego Biurrun <diego@xxxxxxxxxx>
  • To: pisa-src@xxxxxxxxxxxxx
  • Date: Tue, 13 Oct 2009 16:39:43 +0200

As you may have noticed, I'm working on refactoring and improving the
PISA build system.  Currently we have a mess of partly duplicated and
partly unnecessary code.

One of the main goals is to get rid of recursive make, i.e. make
invocations that start new make instances for subdirectories.  Recursive
make is as wrong as it is - unfortunately - widespread.  The pitfalls of
recursive make have best been summed up in Peter Miller's famous paper
"Recursive Make Considered Harmful":

http://miller.emu.id.au/pmiller/books/rmch/

The most important points are that it is

- incorrect
  Make works by constructing a directed graph of targets and their
  dependencies.  Recursive make effectively cuts this graph apart at
  subdirectory level.  This removes any inter-directory dependencies
  from the graph.  The result is make rebuilding parts it need not
  rebuild as well - worse - not rebuilding parts that need to be
  rebuilt.

- bad for performance
  The recursive calls incur an unnecessary overhead.  Moreover, make is
  excellent at parallelizing the build process.  Recursive make hampers
  that parallelization by unnecessarily linearizing the build process
  at the subdirectory level.  With today's multiprocessor and multicore
  systems, this slows down the build process quite a bit.

- inducive to code duplication
  Invariably, Makefiles in subdirectories are copied and pasted around
  (including bugs of course) more or less mindlessly.  Opportunities
  for refactoring Makefile code are lost and bugs are multiplied.
  Usually recursive make systems end up with at least twice the line
  count of proper nonrecursive make systems.

Claims that recursive make leads to individual makefiles that are easier
to understand are greatly exaggerated.  Most Makefiles mostly consist of
lists containing targets for building and the respecive sources.  Long
lists are not really more complicated than short lists.


So, what does this mean for the PISA project?  Watch out for Makefile.am
files in subdirectories going away and being merged into the top-level
Makefile.am.  If you need to add some new binary or object file in a
subdirectory that is no longer built recursively, find the appropriate
place in the top-level Makefile.am to hook it up.  It should only be a
one or two line change as opposed to adding a 20 line Makefile.am.

If there are any questions, shoot...

Diego

Other related posts:

  • » [pisa-src] ongoing build system changes - Diego Biurrun