Darcs, FreeBSD and AMD64. Happy Together.
Edit: This approach seemed tenable, but the resulting executable failed in some circumstances. We suggest you use the method in this article instead.
We recently moved to the AMD64 platform on FreeBSD, and for the most part it has been fantastic. The machines are screaming fast, and almost every piece of software we use has been supported.
Everything except darcs and ghc, which are i386 only on the FreeBSD platform.
We didn’t want to run a standard (dynamic) 32-bit binary, because then we would end up having to manage 32-bit version of the curl, readline and gmp libraries, in parallel with their 64-bit brothers. It seemed like a disaster waiting to happen at upgrade time.
After some experimentation, it became clear that the least bad solution would be to create a statically linked 32-bit binary, that could be run an i386 compatible kernel.
As such, first we built a new amd64 kernel with the following added to the kernel configuration:
options COMPAT_IA32
Then on an FreeBSD/i386 machine, we went about building a binary package with a statically linked binary, by making a few edits to the darcs ports Makefile. Here is the diff:
--- Makefile.orig Sat Feb 10 14:02:34 2007
+++ Makefile Sat Feb 10 14:18:44 2007
@@ -14,10 +14,10 @@
MAINTAINER= haskell@FreeBSD.org
COMMENT= Yet another replacement for CVS, written in Haskell
-BUILD_DEPENDS= ghc:${PORTSDIR}/lang/ghc
-LIB_DEPENDS= curl:${PORTSDIR}/ftp/curl \
- gmp.7:${PORTSDIR}/math/libgmp4 \
- readline.5:${PORTSDIR}/devel/readline
+BUILD_DEPENDS= ghc:${PORTSDIR}/lang/ghc \
+ curl:${PORTSDIR}/ftp/curl \
+ /usr/local/lib/libgmp.so.7:${PORTSDIR}/math/libgmp4 \
+ /usr/local/lib/libreadline.so.5:${PORTSDIR}/devel/readline
OPTIONS= SERVER "install server" off
USE_AUTOTOOLS= autoconf:259
@@ -25,6 +25,7 @@
CONFIGURE_ENV= CPPFLAGS="-I${LOCALBASE}/include ${PTHREAD_CFLAGS}" \
LDFLAGS="-L${LOCALBASE}/lib -L${PREFIX}/lib/ ${PTHREAD_LIBS}" \
CFLAGS=""
+CONFIGURE_ARGS= --with-static-libs
USE_GMAKE= yes
MAKEFILE= GNUmakefile
ALL_TARGET= darcs darcs.1
And then, still on the i386, in ports/devel/darcs, I ran make package to create a new darcs binary package, containing the statically linked binary.
This package was then able to be copied over to the amd64 machines, and installed via pkg_add, without issue.
Edit: This binary then worked fine on a test repository, but it dumped core on a large, production repository. As such we switched to a different tactic. Read about it in Part 2.