I recently started playing around with a Linode instance. It's a really nice service and I wanted to kick the tires with couple of Haskell projects. The smallest Linode instance comes with 512MB of memory, and this should be reasonably enough for everybody. Except for
ld, it seems :)
I installed Yesod web framework from scratch using cabal
cabal install yesod
I quickly noticed that installing software with
cabalcaused a huge load spike to host. I whipped out my trusty htop and noticed that process
ld(the linker). was sucking up 500MB of memory and compilation was (understandably) stuck since the host was swapping all the time.
The relevant ticket for GHC contained some information. I also came across a brilliant posting outlining some optimizations for limited memory hosts.
I tested giving the options to ghc, but unfortunately some packages flag out refused to compile with those. At least for some packages the linker parameters given with
-optlwere passed to
gcc. After some twiddling I decided to give up.
Then I came across a Stack Overflow discussion about
goldlinker, which is experimental optimized linker. There's a Ubuntu package for that,
binutils-goldwhich conveniently replaces the system
ldwith the experimental optimized linker.
So, it just installed it with command
sudo apt-get install binutils-gold
and rerun the
cabal install yesod
The compilation seemed to go through smoothly, and
lddidn't cause any memory spikes. As such, using the
binutils-goldpackage seemed to solve this particular memory blues.
goldlinker is experimental software, and is known not to compile some software correctly (such kernel modules). As such, using it is a tradeoff. In my case the standard linker just didn't work. Fortunately, the experimental linker can be quite easily removed by uninstalling the
binutils-goldpackage - system will revert back to stock ld.
Anyway, if you happen to run into this particular problem, try the
binutils-gold. Rumour is that the optimized
ldmight even help with