Building on machines with less than 1Gb of RAM

Instructions for building from source on machines with less than vast amounts of RAM

(Note: this is no longer relevant since Gtk2Hs 0.9.8 uses much less RAM)

The easiest option is not to build from source at all but to use a pre-built package for your platfrom. If one is not avaliable for your platform read on…

Building from source requires a large amount of memory. There are two options for building on weaker machines. The choice depends on how much memory your system has:

  1. 400Mb or more:

    A realistic minimum for an ordinary build is 400Mb on Unix machines and 700Mb on Windows machines. (It is somewhat of a mystery why it takes so much more on Windows.) By default the build may try to use more than 400Mb. To restrict the amount of memory the build uses to the minimum necessary, pass these extra parameters to make:

    $ make HSTOOLFLAGS="-H380m -M380m"

  2. less than 400Mb:

    In this case an ordinary build will not work however we do have a fix. The basic idea is that we generate some of the build files on one machine (the ones that take so much memory to generate) and then you can use them on other machines. These files do depend on the platform and version of Gtk+ being used so there are a few versions avaliable and you need to pick the one appropriate for your platform:

    1. x86 Linux with Gtk+ 2.2.x
    2. x86 Linux with Gtk+ 2.4.x
    3. x86 Linux with Gtk+ 2.6.x

    If there is no package matching your platform please ask on the mailing list. If necessary we could probably generate versions for Windows, Sparc Linux, Sparc Solaris, and possibly MacOS X, PPC Linux and FreeBSD

    The instructions are as follows:

    1. download gtk2hs-0.9.7.tar.gz as normal
    2. download one of the low mem overlay tarballs above (corresponding to your platform and Gtk+ version)
    3. $ tar -xzf gtk2hs-0.9.7.tar.gz
      $ tar -xzf gtk2hs-0.9.7-lowmem-overlay-gtk-2.2.tar.gz
      $ cd gtk2hs-0.9.7
      $ ./configure --disable-gnome --disable-mozilla
      $ make HSTOOLFLAGS="-H50m -M100m"
      $ make install

    The main point here is that the overlay tarball unpacks files into the same directory as the main tarball unpacked into.

    The --disable-gnome --disable-mozilla is important since the 2.2 overlay tarball does not include .precomp files for the gnome or mozilla modules. (The 2.4 and 2.6 tarballs do include them for gnome but not mozilla so for the gtk 2.4/2.6 overlays you must still use --disable-mozilla.)

    For Mozilla support, in addition to the Gtk+ overlay you should unpack the mozembed overlay. In this case you obviously should not specify --disable-mozilla to ./configure. At the moment we have this available for just:

    1. x86 Linux with Mozilla 1.7.x:

You may well ask why the build takes so much memory in the first place. The explanation is that we use a FFI tool called c2hs which scans C header files to gather information used to generate the appropriate Haskell modules. The problem is that c2hs keeps the whole of the header files and all the symbol maps it accumulates in memory at once and the header files for Gtk+ are rather large so it ends up taking rather a lot of RAM. We are aware that this is a fustrating problem for people with older machines and are looking into the issue to see if there is a practical solution.

One Response to “Building on machines with less than 1Gb of RAM”

  1. Gtk2Hs » Blog Archive » Building from source no longer needs vast amounts of RAM Says:

    While there was a workaround for machines with less than 512Mb RAM it was not easy to use and was hard for distributors to automate.