December 19, 2004

Making a copy of a complete build of GHC

This is probably my most useful post so far. It answers the question, "Okay, so I've built GHC. I want to make a copy of the build but I don't want to suffer another three plus hours of productivity destroying build watching."

Being a savvy reader, you're probably aware that the GHC build system has the annoying habit of hard coding many of the paths. This means that simply copying the build directory somewhere else won't work. Once you type make again you're in trouble - everything will have to be built again. Well fear not! I have a found a reasonable solution that involves using rsync, touch, and ranlib if you're building on Mac OS X.

First run rsync to copy the old build directory.

mkdir <new build dir>
cd <new build dir>
rsync -rl <old path> .

Now run configure

./configure <what ever options you want>

(Note: I actually have a custom configure script that is simply a wrapper around a call to configure with the many options I want. So I just type ./configure.custom)

Now touch all the old files.


for i in `find . -name '*.o'`; do touch $i ; done
for i in `find . -name '*.p_o'`; do touch $i ; done
for i in `find . -name '*.thr_o'`; do touch $i ; done
for i in `find . -name '*.thr_p_o'`; do touch $i ; done
for i in `find . -name '*.debug_o'`; do touch $i ; done
for i in `find . -name 'ghc*6.3'`; do touch $i; done
for i in `find . -name '*.a'`; do touch $i ; done

The paths in the various in-place scripts (e.g. ghc-inplace, ghc-pkg-inplace) are incorrect. Just delete them; they are inexpensive to generate again.

rm `find . -name '*-inplace'`

Finally, if you're on Mac OS X you must ranlib all the libraries

for i in `find . -name '*.a'`; do ranlib $i ; done

Now run make and you're done. It should take a lot less time. On my system it took about five minutes to rsync, three minutes to run configure and seven minutes to run make. This is entirely acceptable.