Permalink
Browse files

Update build scripts

- Support GHC 8
- Drop platform-ghc
  • Loading branch information...
izgzhen committed Dec 31, 2016
1 parent d10d5ac commit a70e417ca9df421a3f2589821567fc42015761d1
Showing with 67 additions and 189 deletions.
  1. +26 −157 Makefile
  2. +2 −15 autoconf.mk.in
  3. +21 −9 configure.ac
  4. +14 −8 src/misc/build.mk.in
  5. +4 −0 src/scripts/ldkernel.in
View
183 Makefile
@@ -23,134 +23,6 @@ mrproper:: clean
.PHONY: install
install::
-###############################################################################
-# File Downloading
-###############################################################################
-
-$(GHC_FILE):
- $(CURL) -LO $(GHC_LINK)
-
-$(CABAL_FILE):
- $(CURL) -LO $(CABAL_LINK)
-
-mrproper::
- $(RM) -f $(GHC_FILE)
- $(RM) -f $(CABAL_FILE)
-
-###############################################################################
-# Platform GHC Preparation
-###############################################################################
-
-# We ship cabal, alex, happy, haddock, hscolour with the HaLVM environment,
-# since they depend on 'unix' and other libraries halvm-ghc can't build.
-# (User might not have a preexisting Haskell ecosystem installed).
-# A cabal sandbox is used to minimise the effect on the user's machine.
-BUILDDIR := $(TOPDIR)/build
-BUILDBOX := $(BUILDDIR)/sandbox
-BUILDENV := PATH=$(TOPDIR)/platform_ghc/bin:$(BUILDBOX)/bin:$(PATH)
-
-$(BUILDDIR):
- mkdir -p $@
-
-clean::
- $(RM) -rf $(BUILDDIR)
- $(RM) -rf $(TOPDIR)/platform_ghc
-
-mrproper::
- $(RM) -rf $(BUILDDIR)
-
-# Prepare an ordinary version of GHC.
-# We don't ship this - we just need it to build halvm-ghc etc.
-PLATGHC := $(TOPDIR)/platform_ghc/bin/ghc
-
-$(PLATGHC): $(GHC_FILE) | $(BUILDDIR)
- $(TAR) jxf $(GHC_FILE) -C $(BUILDDIR)
- (cd $(BUILDDIR)/ghc* && ./configure --prefix=$(TOPDIR)/platform_ghc)
- $(MAKE) -C $(BUILDDIR)/ghc*/ install
-
-mrproper::
- $(RM) -rf $(TOPDIR)/platform_ghc
- $(RM) $(HOME)/.ghc/$(ARCH)-linux-7.8.4
-
-PLATCABAL := $(TOPDIR)/platform_ghc${halvmlibdir}/bin/cabal
-$(PLATCABAL): $(CABAL_FILE) $(PLATGHC) | $(BUILDDIR)
- $(TAR) zxf $(CABAL_FILE) -C $(BUILDDIR)
- # XXX Why is this necessary?
- $(RM) -rf ${HOME}/.ghc/${ARCH}-linux-7.8.4
- $(BUILDENV) && cd $(BUILDDIR)/cabal-install-$(CABAL_VERSION) && \
- PREFIX=${halvmlibdir} \
- ./bootstrap.sh --no-doc --sandbox $(BUILDBOX)
- $(INSTALL) -D $(BUILDBOX)/bin/cabal $(PLATCABAL)
-
-mrproper::
- $(RM) -rf $(TOPDIR)/platform_ghc
-
-# `cabal update` stores package lists in ~/.cabal by default, even with sandbox.
-# We override this with a config file to prevent unwanted build effects.
-$(BUILDDIR)/cabal.config: $(PLATCABAL)
- echo "require-sandbox: True" >> $@
- echo "remote-repo: hackage.haskell.org:http://hackage.haskell.org/packages/archive" >> $@
- echo "remote-repo-cache: $(BUILDBOX)/packages" >> $@
- $(BUILDENV) && cd $(BUILDBOX) && \
- $(PLATCABAL) --config-file=$@ sandbox init --sandbox=$(BUILDBOX) && \
- $(PLATCABAL) --config-file=$@ update
-
-# Force Cabal to use our config file
-CABAL := $(PLATCABAL) --config-file="$(BUILDDIR)/cabal.config"
-
-# Fetch sources for alex, happy, hscolour, haddock from Hackage.
-# This produces targets $(ALEX_SRC) $(HAPPY_SRC) etc
-define hackage-fetch
-$2_SRC := $$(BUILDDIR)/$1-$3
-$$($2_SRC): $$(PLATCABAL) | $$(BUILDDIR)
- $$(BUILDENV) && cd $$(BUILDDIR) && \
- $$(CABAL) fetch $1-$3 && \
- $$(CABAL) unpack $1-$3
-endef
-$(eval $(call hackage-fetch,alex,ALEX,$(ALEX_VERSION)))
-$(eval $(call hackage-fetch,happy,HAPPY,$(HAPPY_VERSION)))
-$(eval $(call hackage-fetch,haddock,HADDOCK,$(HADDOCK_VERSION)))
-$(eval $(call hackage-fetch,hscolour,HSCOLOUR,$(HSCOLOUR_VERSION)))
-
-# Build regular versions of alex and happy in our sandbox, for building GHC.
-# We pass $(BUILDBOX)/bin via $(BUILDENV) while building GHC and libraries.
-define hackage-sandbox-build
-$1_BIN := $$(BUILDBOX)/bin/$2
-$$($1_BIN): $$(PLATCABAL) | $$($1_SRC)
- $$(BUILDENV) && cd $$($1_SRC) && \
- $$(CABAL) sandbox init --sandbox $$(BUILDBOX) && \
- $$(CABAL) install --only-dep && \
- $$(CABAL) configure && \
- $$(CABAL) build && \
- $$(CABAL) copy
-endef
-$(eval $(call hackage-sandbox-build,ALEX,alex))
-$(eval $(call hackage-sandbox-build,HAPPY,happy))
-$(eval $(call hackage-sandbox-build,HSCOLOUR,HsColour))
-$(eval $(call hackage-sandbox-build,HADDOCK,haddock))
-
-# For each of the tools we distribute with the HaLVM, build static versions
-# with the correct prefix burned in. This is only necessary because of
-# cabal #462 https://github.com/haskell/cabal/issues/462.
-# Without this, the built tools will only work on the builder's machine.
-# Targets $(PLATALEX) $(PLATHSCOLOUR) etc will be created.
-define hackage-static-build
-PLAT$1 = $$(TOPDIR)/platform_ghc$${halvmlibdir}/bin/$2
-$$(PLAT$1): $$(PLATCABAL) $$(BUILDDIR)/cabal.config $$($1_BIN)
- $$(BUILDENV) && cd $$($1_SRC) && \
- $$(CABAL) configure --prefix=$$(halvmlibdir) \
- --disable-shared --disable-executable-dynamic && \
- $$(CABAL) build && \
- $$(CABAL) copy --destdir=$$(TOPDIR)/platform_ghc
-endef
-$(eval $(call hackage-static-build,ALEX,alex))
-$(eval $(call hackage-static-build,HAPPY,happy))
-$(eval $(call hackage-static-build,HADDOCK,haddock))
-$(eval $(call hackage-static-build,HSCOLOUR,HsColour))
-
-# Require static and ordinary builds for each tool.
-all:: $(PLATHAPPY) $(PLATHADDOCK) $(PLATHSCOLOUR) $(PLATALEX)
-
###############################################################################
# Prepping / supporting the GHC build
################################################################################
@@ -160,16 +32,7 @@ $(TOPDIR)/halvm-ghc/libraries/array/array.cabal:
(cd halvm-ghc && ./sync-all --no-dph -r http://darcs.haskell.org get)
(cd halvm-ghc && ./sync-all checkout -t origin/ghc-7.8)
-# Replace GHC's base with halvm-base.
-# When NoIO.hs exists, we know this step has succeeded
-$(TOPDIR)/halvm-ghc/libraries/base/GHC/Event/NoIO.hs: \
- $(TOPDIR)/halvm-ghc/libraries/array/array.cabal
- $(RM) -rf $(TOPDIR)/halvm-ghc/libraries/base
- $(GIT) clone $(GIT_LIB_URL)/halvm-base.git -b halvm halvm-ghc/libraries/base
-
-$(TOPDIR)/halvm-ghc/libraries/base/ghc.mk: \
- $(TOPDIR)/halvm-ghc/libraries/base/GHC/Event/NoIO.hs \
- $(TOPDIR)/halvm-ghc/mk/build.mk
+$(TOPDIR)/halvm-ghc/libraries/base/ghc.mk: $(TOPDIR)/halvm-ghc/mk/build.mk
(cd halvm-ghc && ./boot)
# Link Xen headers into the HaLVM runtime include dir
@@ -197,14 +60,12 @@ $(TOPDIR)/halvm-ghc/libraries/XenDevice: \
fi
# Replace libc headers with minlibc
-$(TOPDIR)/halvm-ghc/libraries/base/libc-include: \
- $(TOPDIR)/halvm-ghc/libraries/base/GHC/Event/NoIO.hs
+$(TOPDIR)/halvm-ghc/libraries/base/libc-include:
if [ ! -h $@ ]; then \
$(LN) -sf $(TOPDIR)/halvm-ghc/rts/minlibc/include $@ ; \
fi
-GHC_PREPPED = $(TOPDIR)/halvm-ghc/libraries/base/GHC/Event/NoIO.hs \
- $(TOPDIR)/halvm-ghc/rts/xen/include/xen \
+GHC_PREPPED = $(TOPDIR)/halvm-ghc/rts/xen/include/xen \
$(TOPDIR)/halvm-ghc/libraries/base/ghc.mk \
$(TOPDIR)/halvm-ghc/libraries/base/libc-include \
$(TOPDIR)/halvm-ghc/mk/build.mk \
@@ -365,13 +226,12 @@ HALVM_GHC_CONFIGURE_FLAGS += --with-nm=$(NM)
HALVM_GHC_CONFIGURE_FLAGS += --with-ar=$(AR)
HALVM_GHC_CONFIGURE_FLAGS += --with-objdump=$(OBJDUMP)
HALVM_GHC_CONFIGURE_FLAGS += --with-ranlib=$(RANLIB)
-HALVM_GHC_CONFIGURE_FLAGS += --with-ghc=$(PLATGHC)
+HALVM_GHC_CONFIGURE_FLAGS += --with-ghc=$(GHC)
HALVM_GHC_CONFIGURE_FLAGS += --prefix=$(prefix)
+HALVM_GHC_CONFIGURE_FLAGS += --disable-large-address-space
-$(TOPDIR)/halvm-ghc/mk/config.mk: $(GHC_PREPPED) $(PLATGHC) $(PLATALEX) \
- $(PLATHAPPY) $(PLATHADDOCK) $(PLATHAPPY)
- (cd halvm-ghc && \
- $(BUILDENV) && ./configure $(HALVM_GHC_CONFIGURE_FLAGS))
+$(TOPDIR)/halvm-ghc/mk/config.mk: $(GHC_PREPPED)
+ (cd halvm-ghc && ./configure $(HALVM_GHC_CONFIGURE_FLAGS))
# The GHC build system picks up everything linked into halvm-ghc/libraries
$(TOPDIR)/halvm-ghc/inplace/bin/ghc-stage1: $(TOPDIR)/halvm-ghc/mk/config.mk
@@ -419,12 +279,13 @@ $(TOPDIR)/src/misc/ghci_runtime.o: $(TOPDIR)/src/misc/ghci_runtime.c
$(TOPDIR)/halvm-ghc/libminlibc.a: \
$(TOPDIR)/halvm-ghc/rts/dist/build/libHSrts.a \
- $(TOPDIR)/src/misc/ghci_runtime.o
+ $(TOPDIR)/src/misc/ghci_runtime.o \
+ $(GHCI_OBJS)
$(AR) cr $@ $(GHCI_OBJS)
all:: $(TOPDIR)/halvm-ghc/libminlibc.a
-install::
+install:: $(TOPDIR)/halvm-ghc/libminlibc.a
$(INSTALL) -D $(TOPDIR)/halvm-ghc/libminlibc.a \
$(DESTDIR)$(halvmlibdir)/base-$(BASE_VERSION)/libminlibc.a
@@ -446,22 +307,30 @@ install:: $(TOPDIR)/src/scripts/ldkernel
install:: $(TOPDIR)/src/misc/kernel-$(ARCH).lds
$(INSTALL) -D $(TOPDIR)/src/misc/kernel-$(ARCH).lds $(DESTDIR)$(halvmlibdir)/kernel.lds
-install:: ${PLATGHC}
- $(INSTALL) -D $(shell $(PLATGHC) --print-libdir)/bin/hsc2hs $(DESTDIR)${halvmlibdir}/bin/hsc2hs.bin
+install::
+ $(INSTALL) -D $(shell $(GHC) --print-libdir)/bin/hsc2hs $(DESTDIR)${halvmlibdir}/bin/hsc2hs.bin
# Need to be sure we grab datadirs for alex and happy, /usr/share w.r.t. their prefix
-install:: $(PLATALEX) $(PLATCABAL) $(PLATHAPPY) $(PLATHADDOCK) $(PLATHSCOLOUR)
+install::
mkdir -p $(DESTDIR)${halvmlibdir}
- cp -rf $(TOPDIR)/platform_ghc/${prefix}/* $(DESTDIR)${prefix}/
+ cp ${ALEX} $(DESTDIR)${halvmlibdir}/bin/alex
+ cp ${HSCOLOUR} $(DESTDIR)${halvmlibdir}/bin/HsColour
+ cp ${HADDOCK} $(DESTDIR)${halvmlibdir}/bin/haddock
+ cp ${CABAL} $(DESTDIR)${halvmlibdir}/bin/cabal
+ cp ${HAPPY} $(DESTDIR)${halvmlibdir}/bin/happy
+ cp ${HSC2HS} $(DESTDIR)${halvmlibdir}/bin/hsc2hs
+ cp -rf ${platformdir}/share $(DESTDIR)${halvmlibdir}
+ cp -rf ${platformdir}/lib $(DESTDIR)${halvmlibdir}
# hsc2hs requires a bunch of libraries to be installed. This is a hack (FIXME)
# to copy over the platform_ghc ones to our destination directory and hope
# nothing gets broken. Long term, finding some way to build a statically-linked
# hsc2hs would be better.
-install::
- $(FIND) $(TOPDIR)/platform_ghc -name "*so" -name '*-ghc*' \
- -exec cp '{}' $(DESTDIR)$(halvmlibdir)/lib/ \;
- $(INSTALL) -D $(TOPDIR)/src/scripts/hsc2hs $(DESTDIR)${halvmlibdir}/bin/hsc2hs
+# NOTE (izgzhen): Currently I don't know if it is necessary in GHC 8.0.1, needs testing
+# install::
+# $(FIND) $(TOPDIR)/platform_ghc -name "*so" -name '*-ghc*' \
+# -exec cp '{}' $(DESTDIR)$(halvmlibdir)/lib/ \;
+# $(INSTALL) -D $(TOPDIR)/src/scripts/hsc1hs $(DESTDIR)${halvmlibdir}/bin/hsc2hs
###############################################################################
# Packaging!
View
@@ -11,7 +11,6 @@ GIT_LIB_URL := git://github.com/GaloisInc
INTEGER_LIBRARY := @INTEGER_LIBRARY@
BUILD_DOCS := @ENABLE_DOCS@
ABI := @ABI@
-
# Top of the build system, set by auto[re]conf. This allows any other makefile
# to include common.mk and get a consistent variable environment.
TOPDIR := @abs_top_builddir@
@@ -22,6 +21,7 @@ bindir := @bindir@
libdir := @libdir@
incdir := @includedir@
halvmlibdir := $(libdir)/HaLVM-$(HaLVM_VERSION)
+platformdir := @PLATFORMDIR@
#
# External programs of interest
@@ -57,6 +57,7 @@ RM := @RM@
SED := @SED@
TAR := @TAR@
TOUCH := @TOUCH@
+HSC2HS := @HSC2HS@
#
# Interesting flags from configure
@@ -104,17 +105,3 @@ LDFLAGS := -L$(XEN_LIBRARY_DIR)
GHCFLAGS := -O2 -H32m
GHCFLAGS += $(ARCH_GHC_FLAGS)
-GHC_VERSION := 7.8.4
-GHC_FILE := ghc-${GHC_VERSION}-@ARCHITECTURE@-unknown-linux-@PLATFORM@.tar.bz2
-GHC_LINK := http://www.haskell.org/ghc/dist/${GHC_VERSION}/$(GHC_FILE)
-
-HACKAGE := http://hackage.haskell.org/package
-
-CABAL_VERSION := 1.22.3.0
-CABAL_FILE := cabal-install-${CABAL_VERSION}.tar.gz
-CABAL_LINK := ${HACKAGE}/cabal-install-${CABAL_VERSION}/${CABAL_FILE}
-
-ALEX_VERSION := 3.1.4
-HAPPY_VERSION := 1.19.5
-HADDOCK_VERSION := 2.15.0.2
-HSCOLOUR_VERSION := 1.22
View
@@ -6,7 +6,7 @@ dnl - terms and conditions.
dnl Author: Adam Wick <awick@galois.com>
dnl BANNEREND
AC_PREREQ(2.60)
-AC_INIT(HALVM,2.2.1,awick@galois.com,halvm)
+AC_INIT(HALVM,2.3.0,awick@galois.com,halvm)
dnl -------------------------------------------------------------------------
dnl
@@ -129,15 +129,27 @@ AC_FORCE_EXIST(SED,sed)
AC_FORCE_EXIST(TAR,tar)
AC_FORCE_EXIST(TOUCH,touch)
-AC_CHECK_PROG_VER(ALEX, alex, --version, [version \([0-9.]*\)],
- [3.[1-9]*], AC_SUBST(ALEX, "no") NEED_CURL=yes)
-AC_CHECK_PROG_VER(HAPPY, happy, --version, [Version \([0-9.]*\)], [1.19.*],
- AC_SUBST(HAPPY,"no") NEED_CURL=yes)
+AC_CHECK_PROG_VER(ALEX, alex, --version, [Alex version \([0-9.]*\)],
+ [3.*], LOG_FAILURE("Couldn't find required version of Alex"))
AC_CHECK_PROG_VER(CABAL, cabal, --version, [cabal-install version \([0-9.]*\)],
- [1.[23456789][0123456789].*],
- AC_SUBST(CABAL,"no") NEED_CURL=yes)
-AC_CHECK_PROG_VER(GHC, ghc, --version, [version \([0-9.]*\)], [7.8.*],
- AC_SUBST(GHC,no) NEED_CURL=yes)
+ [1.2[456789].*],
+ LOG_FAILURE("Couldn't find required version of Cabal"))
+AC_CHECK_PROG_VER(GHC, ghc, --version, [version \([0-9.]*\)],
+ [8.0.*], LOG_FAILURE("Couldn't find required version of GHC"))
+AC_CHECK_PROG_VER(HADDOCK, haddock, --version, [Haddock version \([0-9.]*\)],
+ [2.17.*],
+ LOG_FAILURE("Couldn't find required version of Haddock"))
+AC_CHECK_PROG_VER(HAPPY, happy, --version, [Happy Version \([0-9.]*\)],
+ [1.19.*],
+ LOG_FAILURE("Couldn't find required version of Happy"))
+AC_CHECK_PROG_VER(HSCOLOUR, HsColour, --version, [HsColour \([0-9.]*\)],
+ [1.24*],
+ LOG_FAILURE("Couldn't find required version of HsColour"))
+AC_CHECK_PROG_VER(HSC2HS, hsc2hs, --version, [hsc2hs version \([0-9.]*\)],
+ [0.68*],
+ LOG_FAILURE("Couldn't find required version of hsc2hs"))
+
+AC_SUBST(PLATFORMDIR, `dirname $(dirname ${ALEX})`)
AC_CHECK_HEADER(ncurses.h, HAVE_NCURSES=y,
[AC_CHECK_HEADER(curses.h, HAVE_NCURSES=y,
View
@@ -1,22 +1,26 @@
Stage1Only := YES
INTEGER_LIBRARY := @INTEGER_LIBRARY@
+DYNAMIC_BY_DEFAULT := NO
DYNAMIC_GHC_PROGRAMS := NO
GhcLibWays = v p
GhcRTSWays = thr v p debug thr_debug
-# These are copied from the "perf" option
-SRC_HC_OPTS = -O -H64m
+SRC_HC_OPTS = -O0 -H64m
GhcStage1HcOpts = -O -fasm
-GhcStage2HcOpts = -O2 -fasm
+GhcStage2HcOpts = -O0 -fasm
GhcHcOpts = -Rghc-timing
-GhcLibHcOpts = -O2
+GhcLibHcOpts = -O
+
+BUILD_PROF_LIBS = NO
+SplitObjs = NO
+# NOTE (izgzhen): It is faster to not split object files, and it
+# looks like CrossCompiling GHC-8 with this on can cause some problems
-SplitObjs = YES
HADDOCK_DOCS = NO
-BUILD_DOCBOOK_HTML = NO
-BUILD_DOCBOOK_PS = NO
-BUILD_DOCBOOK_PDF = NO
+BUILD_SPHINX_HTML = NO
+BUILD_SPHINX_PDF = NO
+BUILD_MAN = NO
SRC_CC_OPTS += @NO_UNIT_AT_A_TIME_OPT@
SRC_CC_OPTS += @NO_STACK_PROT_OPT@
@@ -30,3 +34,5 @@ SRC_CC_OPTS += @ARCH_OPTION@
NoFibWays =
STRIP_CMD = :
+HaveLibDL = NO
+
View
@@ -31,6 +31,9 @@ exec_prefix="@exec_prefix@"
libdir="@libdir@"
halvm_dir="@libdir@/HaLVM-@PACKAGE_VERSION@"
+# reset the arguments as the file content of the path provided in the original argument
+set -- $(cat $(echo $@ | sed 's/^@//') | tr '\n' ' ' | sed 's/\"//g')
+
ARGS=""
LIBS=""
LIBDIR=`echo $0 | sed 's/[^/]*$//g'`
@@ -53,6 +56,7 @@ while [ $# != 0 ] ; do
-Wl,--hash-size*) BIT=`echo "$1"|cut -c 17-`;ARGS="$ARGS -u ${BIT}";shift;;
-Wl,--version) ARGS="$ARGS --version"; shift;;
-Wl,--build-id=none) TY=$(echo "$1" | cut -c 16-); ARGS="$ARGS --build-id=${TY}"; shift;;
+ -Wl,--gc-sections) shift;; # HACK (izgzhen): don't know a better way to handle this
*) ARGS="$ARGS $1"; shift;;
esac
done

0 comments on commit a70e417

Please sign in to comment.