<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>blog@insidesystems.net: Darcs, FreeBSD and AMD64.  Happy Together.</title>
    <link>http://blog.insidesystems.net/articles/2007/02/10/oh-my-darcs</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>Darcs, FreeBSD and AMD64.  Happy Together.</title>
      <description>&lt;blockquote&gt;Edit: This approach seemed tenable, but the resulting executable failed in some circumstances.  We suggest you use the method in &lt;a href="http://blog.insidesystems.net/articles/2007/02/12/darcs-freebsd-and-amd64-happier-together"&gt;this article&lt;/a&gt; instead.&lt;/blockquote&gt;

	&lt;p&gt;We recently moved to the &lt;span class="caps"&gt;AMD64&lt;/span&gt; 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.&lt;/p&gt;


	&lt;p&gt;Everything except darcs and ghc, which are i386 only on the FreeBSD platform.&lt;/p&gt;


	&lt;p&gt;We didn&amp;#8217;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.&lt;/p&gt;&lt;p&gt;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.&lt;/p&gt;


As such, first we built a new amd64 kernel with the following added to the kernel configuration:
&lt;pre&gt;
&lt;code&gt;
options       COMPAT_IA32
&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;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:&lt;/p&gt;


&lt;pre&gt;
&lt;code&gt;
--- 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
&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;And then, still on the i386, in ports/devel/darcs, I ran &lt;code&gt;make package&lt;/code&gt; to create a new darcs binary package, containing the statically linked binary.&lt;/p&gt;


	&lt;p&gt;This package was then able to be copied over to the amd64 machines, and installed via pkg_add, without issue.&lt;/p&gt;


&lt;blockquote&gt;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 &lt;a href="http://blog.insidesystems.net/articles/2007/02/12/darcs-freebsd-and-amd64-happier-together"&gt; Part 2&lt;/a&gt;.</description>
      <pubDate>Sat, 10 Feb 2007 14:12:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:7f8e04b5-a4f4-4221-9be8-4c8f22c9843e</guid>
      <author>Kevin Way</author>
      <link>http://blog.insidesystems.net/articles/2007/02/10/oh-my-darcs</link>
      <category>FreeBSD</category>
      <category>System Administration</category>
      <enclosure type="application/octet-stream" length="1266727" url="http://blog.insidesystems.net/files/darcs-1.0.8_1.tbz"/>
    </item>
  </channel>
</rss>
