Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A small helper script for building GHC 7.8 on ARM
#!/bin/bash -e
bindir=`pwd`/bin-tmp
mkdir -p $bindir
export PATH=$bindir:$PATH
function use_ld() {
rm -f $bindir/ld
ln -s $1 $bindir/ld
echo "Using $1 for ld"
}
# Wrapper to strip out BFD ld options which ghc 7.6 will attempt to pass to gold
cat >$bindir/ld.gold-fixed <<EOF
#!/usr/bin/env python
# From http://stackoverflow.com/questions/6952396
import sys
import os
import subprocess
tofilter = [
"--hash-size",
"--reduce-memory-overheads",
]
filtered = [ a for a in sys.argv if not any(a.startswith(p) for p in tofilter) ]
filtered[0] = "/usr/bin/ld.gold"
subprocess.check_call(filtered)
EOF
chmod ugo+rx $bindir/ld.gold-fixed
# Build utilities using BFD ld
use_ld /usr/bin/ld.bfd
make $@ -r -f ghc.mk phase=0 phase_0_builds
make $@ -r -f ghc.mk phase=1 utils/hsc2hs/dist/build/tmp/hsc2hs
make $@ -r -f ghc.mk phase=1 utils/ghc-pkg/dist/build/tmp/ghc-pkg
make $@ -r -f ghc.mk phase=1 utils/genapply/dist/build/tmp/genapply
make $@ -r -f ghc.mk phase=1 inplace/lib/bin/ghc-stage1
# Build phase 1 using gold
use_ld $bindir/ld.gold-fixed
make $@
make -C ghc $@ 1
@gregnwosu
Copy link

gregnwosu commented Jul 10, 2014

cant pulll request but you may want to pull from my gist , there are some issues with the here document format , i think its mainly due to trailing spaces

https://gist.github.com/gregnwosu/2faf401d8794f039af4f

Loading

@bgamari
Copy link
Author

bgamari commented Nov 22, 2014

@gregnwosu, could you describe more precisely the behavior you were seeing? I've had no trouble using this script with bash 4.3.30.

Loading

@bgamari
Copy link
Author

bgamari commented Aug 5, 2015

@gregnwosu, indeed you were right; there was trailing whitespace in this gist (likely from copying the code from a terminal emulator). I've removed it. Thanks for pointing this out and sorry it took me so long to realize it!

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment