Skip to content

Instantly share code, notes, and snippets.

@gregnwosu
Forked from bgamari/build-ghc-arm.sh
Last active August 29, 2015 14:03
Show Gist options
  • Save gregnwosu/2faf401d8794f039af4f to your computer and use it in GitHub Desktop.
Save gregnwosu/2faf401d8794f039af4f to your computer and use it in GitHub Desktop.
#!/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
Author

fixed here-document errors, mainly trailing spaces, now works with bash

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