Mail archive
alpine-aports

[alpine-aports] [PATCH 2/3] testing/ghc-bootstrap new aport

From: Mitch Tishmack <mitch.tishmack_at_gmail.com>
Date: Tue, 1 Mar 2016 19:28:55 -0600

From: Mitch Tishmack <mitch.tishmack_at_gmail.com>

---
 testing/ghc-bootstrap/APKBUILD                     |  38 ++
 testing/ghc-bootstrap/Makefile                     |  50 +++
 testing/ghc-bootstrap/bootstrap/gmpurl.patch       |  22 ++
 testing/ghc-bootstrap/bootstrap/llvm-3.5.2.sh      | 122 +++++++
 testing/ghc-bootstrap/bootstrap/x86_64/Dockerfile  |  96 +++++
 .../ghc-bootstrap/bootstrap/x86_64/bootstrap.patch | 397 +++++++++++++++++++++
 testing/ghc-bootstrap/bootstrap/x86_64/settings    |  32 ++
 7 files changed, 757 insertions(+)
 create mode 100755 testing/ghc-bootstrap/APKBUILD
 create mode 100644 testing/ghc-bootstrap/Makefile
 create mode 100644 testing/ghc-bootstrap/bootstrap/gmpurl.patch
 create mode 100755 testing/ghc-bootstrap/bootstrap/llvm-3.5.2.sh
 create mode 100644 testing/ghc-bootstrap/bootstrap/x86_64/Dockerfile
 create mode 100644 testing/ghc-bootstrap/bootstrap/x86_64/bootstrap.patch
 create mode 100644 testing/ghc-bootstrap/bootstrap/x86_64/settings
diff --git a/testing/ghc-bootstrap/APKBUILD b/testing/ghc-bootstrap/APKBUILD
new file mode 100755
index 0000000..d396589
--- /dev/null
+++ b/testing/ghc-bootstrap/APKBUILD
_at_@ -0,0 +1,38 @@
+#-*-mode: Shell-script; coding: utf-8;-*-
+# Contributor: Mitch Tishmack <mitch.tishmack_at_gmail.com>
+# Maintainer: Mitch Tishmack <mitch.tishmack_at_gmail.com>
+#
+# Mostly here for porting, beyond that the native ghc
+# should be preferred. Cross compiling insn't a commonly
+# tested piece of ghc.
+pkgname=ghc-bootstrap
+pkgdesc="The Glasgow haskell compiler (bootstrapped)"
+apkgver=7.10.3b
+pkgrel=0
+pkgver=$(echo ${apkgver} | tr -d '[a-z]')
+url="http://haskell.org"
+subpackages=""
+arch="x86_64"
+source="https://dev.alpinelinux.org/archive/ghc-bootstrap/ghc-$apkgver-x86_64-unknown-linux-musl.tar.xz"
+license="custom:bsd3"
+depends="bash libffi musl zlib gcc binutils-gold ghc-llvm-3.5"
+install=""
+subpackages=""
+makedepends="perl"
+
+package() {
+	cd "$srcdir"
+	install -d "$pkgdir" || return 1
+	mv usr "$pkgdir" || return 1
+	settings=$(find "$pkgdir" -name settings -type f)
+	perl -pi -e 's/.*C compiler link flags.*/ \(\"C compiler link flags\"\, \"-nopie\"\)\,/' "$settings" || return 1
+}
+
+# The bootstrap process uses docker to build ghc from a debian glibc host
+# then upload the bootstrap compiler to where that source url is.
+#
+# Ensure that docker is running prior to calling this.
+snapshot () {
+	make x86_64
+	scp "ghc-$pkgver-$bs_arch-unknown-linux-musl.tar.xz" dev.alpinelinux.org:/archive/ghc-bootstrap/ || return 1
+}
diff --git a/testing/ghc-bootstrap/Makefile b/testing/ghc-bootstrap/Makefile
new file mode 100644
index 0000000..94214b3
--- /dev/null
+++ b/testing/ghc-bootstrap/Makefile
_at_@ -0,0 +1,50 @@
+CABAL_VERSION:=1.22.7.0
+GHC_VERSION:=7.10.3
+LLVM_VERSION:=3.5.2
+ARCH:=x86_64
+GHC_BS:=ghc-$(GHC_VERSION)-$(ARCH)-deb8-linux.tar.xz
+GHC_SRC:=ghc-$(GHC_VERSION)-src.tar.xz
+CABAL_BS:=cabal-install-$(CABAL_VERSION).tar.gz
+LLVM_BS:=llvm-$(LLVM_VERSION).src.tar.xz
+POLLY_BS:=polly-$(LLVM_VERSION).src.tar.xz
+SRCS:= $(GHC_BS) $(GHC_SRC) $(CABAL_BS) $(LLVM_BS) $(POLLY_BS)
+
+DOCKER_NAME:=alpine-ghc-bootstrap
+TARGET:=ghc-$(GHC_VERSION)-$(ARCH)-unknown-linux-musl.tar.xz
+
+.PHONY: clean distclean cleandocker x86_64
+
+all: x86_64
+
+dl: $(SRCS)
+
+x86_64:
+	TARGET=ghc-$(GHC_VERSION)-$_at_-unknown-linux-musl.tar.xz
+	docker build -t $(DOCKER_NAME):$_at_ -f bootstrap/$@/Dockerfile . | tee make-$_at_-$(shell date +%s).log
+	docker run -a stdout "$(DOCKER_NAME):$_at_" /bin/cat "/tmp/ghc-$(GHC_VERSION)-$(ARCH)-pc-linux-musl.tar.xz" > $(TARGET)
+
+$(GHC_BS):
+	curl -LO https://downloads.haskell.org/~ghc/$(GHC_VERSION)/$_at_
+
+$(GHC_SRC):
+	curl -LO https://www.haskell.org/ghc/dist/$(GHC_VERSION)/$_at_
+
+$(CABAL_BS):
+	curl -LO https://www.haskell.org/cabal/release/cabal-install-$(CABAL_VERSION)/$_at_
+
+$(LLVM_BS):
+	curl -LO http://llvm.org/releases/$(LLVM_VERSION)/$_at_
+
+$(POLLY_BS):
+	curl -LO http://llvm.org/releases/$(LLVM_VERSION)/$_at_
+
+clean:
+	-rm $(SRCS) $(TARGET)
+
+cleanlogs:
+	-rm make-*.log
+
+cleandocker:
+	docker rmi $(DOCKER_NAME)
+
+distclean: clean cleanlogs
diff --git a/testing/ghc-bootstrap/bootstrap/gmpurl.patch b/testing/ghc-bootstrap/bootstrap/gmpurl.patch
new file mode 100644
index 0000000..c919fa3
--- /dev/null
+++ b/testing/ghc-bootstrap/bootstrap/gmpurl.patch
_at_@ -0,0 +1,22 @@
+diff -r d72695b410e3 defs.sh
+--- a/defs.sh   Sun Jul 26 15:38:58 2015 -0400
++++ b/defs.sh   Sun Jan 31 23:18:18 2016 +0000
+_at_@ -221,7 +221,7 @@
+ gccprereqs() {
+     if [ ! -e gcc-$GCC_VERSION/gmp ]
+     then
+-        fetchextract http://gmplib.org/download/gmp/ gmp-$GMP_VERSION .tar.bz2
++        fetchextract http://gmplib.org/download/gmp/archive/ gmp-$GMP_VERSION .tar.bz2
+         mv gmp-$GMP_VERSION gcc-$GCC_VERSION/gmp
+     fi
+
+--- a/extra/build-gcc-deps.sh   Sun Jul 26 15:38:58 2015 -0400
++++ b/extra/build-gcc-deps.sh   Sun Jan 31 23:18:18 2016 +0000
+_at_@ -28,7 +28,7 @@
+ PREFIX="$CC_PREFIX/$TRIPLE"
+
+ # GMP
+-fetchextract ftp://ftp.gmplib.org/pub/gmp-$GMP_VERSION/ gmp-$GMP_VERSION .tar.bz2
++fetchextract ftp://ftp.gmplib.org/pub/archive/gmp-$GMP_VERSION/ gmp-$GMP_VERSION .tar.bz2
+ cp -f "$MUSL_CC_BASE/extra/config.sub" gmp-$GMP_VERSION/configfsf.sub
+ buildinstall '' gmp-$GMP_VERSION --host="$TRIPLE" --enable-static --disable-shared
diff --git a/testing/ghc-bootstrap/bootstrap/llvm-3.5.2.sh b/testing/ghc-bootstrap/bootstrap/llvm-3.5.2.sh
new file mode 100755
index 0000000..f130872
--- /dev/null
+++ b/testing/ghc-bootstrap/bootstrap/llvm-3.5.2.sh
_at_@ -0,0 +1,122 @@
+#!/usr/bin/env sh
+#-*-mode: Shell-script; coding: utf-8;-*-
+# File: llvm.sh
+# Copyright: 2016 Mitchell Tishmack
+# Description: bootstrap llvm for ghc bootstrapping
+# largely a copypasta of what is in APKBUILD
+export script=$(basename "$0")
+export dir=$(cd "$(dirname "$0")"; pwd)
+export iam=${dir}/${script}
+llvm_major=3.5
+llvm_version=${llvm_major}.2
+llvm_srcdir="/tmp/llvm-${llvm_version}.src"
+#mdir="/tmp/llvm-mirror-llvm-7892e56"
+#if [ -e ${mdir} ]; then
+#  mv ${mdir} ${llvm_srcdir}
+#fi
+suffix="-${llvm_major}"
+llvm_builddir=/tmp/build
+polly_orig_srcdir="/tmp/polly-$llvm_version.src"
+
+cd "$llvm_srcdir"
+# for i in /tmp/llvm*.patch; do
+# 	patch -s -p1 -N -i $i || return 1
+# done
+
+_cmake_flags="\
+	-DCMAKE_BUILD_TYPE=Release \
+	-DCMAKE_VERBOSE_MAKEFILE=NO \
+	-DLLVM_DEFAULT_TARGET_TRIPLE=$CBUILD \
+	-DLLVM_HOST_TRIPLE=$CHOST \
+	-DLLVM_BINUTILS_INCDIR=/usr/include \
+	-DLLVM_ENABLE_ASSERTIONS=NO \
+	-DLLVM_ENABLE_LIBCXX=NO \
+	-DLLVM_ENABLE_PIC=YES \
+	-DLLVM_ENABLE_ZLIB=YES \
+	-DLLVM_ENABLE_RTTI=YES \
+	-DLLVM_BUILD_EXAMPLES=NO \
+	-DLLVM_INCLUDE_EXAMPLES=NO \
+	-DLIBXML2_INCLUDE_DIR=/usr/include/libxml2 \
+	-DCMAKE_INSTALL_PREFIX=/usr \
+	-DLLVM_TARGETS_TO_BUILD='all' \
+	-DLLVM_BUILD_EXTERNAL_COMPILER_RT=NO \
+	-DBUILD_SHARED_LIBS=NO \
+	-DLLVM_EXTERNAL_POLLY_BUILD=NO \
+	-DLINK_POLLY_INTO_TOOLS=NO \
+	-DLLVM_BUILD_DOCS=NO \
+	-DLLVM_BUILD_TESTS=NO \
+	-DLLVM_ENABLE_CXX1Y=NO \
+	-DLLVM_ENABLE_FFI=YES \
+	-DLLVM_ENABLE_SPHINX=NO \
+	-DLLVM_ENABLE_TERMINFO=YES \
+	-DWITH_POLLY=YES \
+	-DLLVM_INCLUDE_EXAMPLES=NO \
+	-DLLVM_INCLUDE_TESTS=NO \
+	-DPOLLY_ENABLE_GPGPU_CODEGEN=NO \
+	"
+srcdir_polly="$llvm_srcdir"/tools/polly
+mv /tmp/polly-$llvm_version.src "$srcdir_polly" || return 1
+
+build_isl() {
+	srcdir=/tmp
+	tmp="$srcdir/tmp"
+	install -d ${tmp} || return 1
+	isl_srcdir="$tmp/isl"
+	cloog_srcdir="$tmp/cloog"
+	cd "$srcdir_polly/utils"
+	./checkout_cloog.sh ${tmp} || return 1
+#	./checkout_isl.sh ${isl_srcdir} || return 1
+	cd "$isl_srcdir"
+	./configure --build=$CBUILD \
+		--host=$CHOST \
+		--prefix=$tmp || return 1
+	make -j$(grep -c processor /proc/cpuinfo)|| return 1
+	make -j1 INSTALL="install -D"	 install || return 1
+}
+
+build_isl "$srcdir_polly" || return 1
+(
+	OCFLAGS="${CFLAGS}"
+	OCXXFLAGS="${CXXFLAGS}"
+	unset CFLAGS
+	unset CXXFLAGS
+
+	test -z "${OCFLAGS}" && OCFLAGS="-O3"
+	test -z "${OCXXFLAGS}" && OCXXFLAGS="-O3"
+
+	cflags="${OCFLAGS} -DNDEBUG -I$srcdir/tmp/include"
+	cxxflags="${OCXXFLAGS} -DNDEBUG -fno-devirtualize"
+
+	export CBUILD
+	export CC=gcc
+	export CXX=g++
+
+	ffi_include_dir="$(pkg-config --cflags-only-I libffi | sed 's|^-I||g')"
+
+	cflags="${OCFLAGS} -DNDEBUG"
+	cxxflags="${OCXXFLAGS} -DNDEBUG"
+
+	mkdir -p "${llvm_builddir}"
+	cd "${llvm_builddir}"
+	cmake -G "Unix Makefiles" -Wno-dev ${_cmake_final_flags} \
+			  -DCMAKE_C_COMPILER="${CC}" \
+			  -DCMAKE_CXX_COMPILER="${CXX}" \
+			  -DCMAKE_C_FLAGS_RELEASE="${cflags}" \
+			  -DCMAKE_CXX_FLAGS_RELEASE="${cxxflags}" \
+			  -DCMAKE_EXE_LINKER_FLAGS="${LDFLAGS} -L$srcdir/tmp/lib" \
+			  -DCMAKE_SHARED_LINKER_FLAGS="${LDFLAGS}" \
+			  -DFFI_INCLUDE_DIR="$ffi_include_dir" \
+			  -DCMAKE_PREFIX_PATH="$srcdir/tmp" \
+			  "${llvm_srcdir}" || return 1
+
+	(
+		export LD_LIBRARY_PATH="$srcdir/tmp/lib:$LD_LIBRARY_PATH"
+		make -j$(grep -c processor /proc/cpuinfo) llvm-tblgen || return 1
+		make -j$(grep -c processor /proc/cpuinfo) || return 1
+	) || return 1
+	export CFLAGS="${OCFLAGS}"
+	export CXXFLAGS="${OCXXFLAGS}"
+
+	# install portion
+	make -j1 install || return 1
+) || return 1
diff --git a/testing/ghc-bootstrap/bootstrap/x86_64/Dockerfile b/testing/ghc-bootstrap/bootstrap/x86_64/Dockerfile
new file mode 100644
index 0000000..00b1bfc
--- /dev/null
+++ b/testing/ghc-bootstrap/bootstrap/x86_64/Dockerfile
_at_@ -0,0 +1,96 @@
+from debian:8.0
+
+# all needed packages for compiling
+run apt-get update && \
+    apt-get install -y \
+      binutils-gold \
+      musl-tools \
+      build-essential \
+      wget \
+      curl \
+      libncurses-dev \
+      autoconf \
+      elfutils \
+      libgmp-dev \
+      zlib1g-dev \
+      git \
+      libtool \
+      pkg-config \
+      libffi-dev \
+      cmake \
+      g++ \
+      python \
+      pixz
+
+# Install stock bindist for cross compile
+env ghc 7.10.3
+env arch x86_64
+copy ghc-$ghc-$arch-deb8-linux.tar.xz /tmp/ghc.txz
+workdir /tmp
+run tar xJpf /tmp/ghc.txz
+workdir /tmp/ghc-$ghc
+run ./configure --prefix=/usr && \
+make -j1 install && \
+rm -fr /tmp/ghc-$ghc
+
+env llvm 3.5.2
+workdir /tmp
+copy llvm-$llvm.src.tar.xz /tmp/llvm.txz
+copy polly-$llvm.src.tar.xz /tmp/polly.txz
+copy bootstrap/llvm-3.5.2.sh /tmp/llvm.sh
+run tar xJpf /tmp/llvm.txz && \
+    tar xJpf /tmp/polly.txz && \
+    /tmp/llvm.sh && \
+    rm -fr /tmp/llvm-$llvm.src
+
+env tardir /tmp/root
+env crosscc musl-gcc
+
+workdir /tmp
+copy ghc-$ghc-src.tar.xz /tmp/ghc-src.txz
+run tar xJpf /tmp/ghc-src.txz
+workdir /tmp/ghc-$ghc
+copy bootstrap/$arch/bootstrap.patch bootstrap.patch
+run patch -p1 < bootstrap.patch
+run cp mk/build.mk.sample mk/build.mk
+run echo "BuildFlavour         = quick-llvm" >> mk/build.mk && \
+    echo "INTEGER_LIBRARY      = integer-simple" >> mk/build.mk && \
+    echo "HADDOCK_DOCS         = NO" >> mk/build.mk && \
+    echo "BUILD_DOCBOOK_HTML   = NO" >> mk/build.mk && \
+    echo "BUILD_DOCBOOK_PS     = NO" >> mk/build.mk && \
+    echo "BUILD_DOCBOOK_PDF    = NO" >> mk/build.mk
+run ./configure \
+  --target=$arch-pc-linux-musl \
+  --with-gcc=$crosscc \
+  --with-ld=ld.gold \
+  --with-nm=nm \
+  --with-ar=ar \
+  --with-ranlib=ranlib \
+  --with-readelf=eu-readelf \
+  --prefix=/usr
+run make -j$(grep -c processor /proc/cpuinfo) || make -j1
+run make -j1 install DESTDIR=$tardir
+
+env triple pc-linux-musl
+# unlit and hp2ps both build using the stage0, not having luck
+# getting the build patched right so for now lets just
+# remove and rebuild these c helper programs
+run rm $tardir/usr/bin/$arch-$triple-hp2ps $tardir/usr/lib/$arch-$triple-ghc-$ghc/unlit
+
+# remove target prefix from stage2 binaries
+# HACK, just build unlit with the cross compiler and move it to /usr/bin in the install dir
+workdir /tmp/ghc-$ghc/utils/unlit
+run $crosscc unlit.c -o $tardir/usr/lib/$arch-$triple-ghc-$ghc/unlit
+run $crosscc unlit.c -o $tardir/usr/bin/unlit
+
+# remove target prefix from stage2 binaries
+workdir $tardir/usr/bin
+run (for i in $arch-$triple-* ; do ln -s $i ${i#$arch-$triple-} ; done )
+copy bootstrap/$arch/settings /tmp/settings
+run mv /tmp/settings $(find $tardir -name settings -type f)
+run rm -fr $tardir/usr/share/doc
+
+workdir $tardir
+# Compress to xz via pixz because xz is normally too
+# old for -TN multithreads
+run tar -I'pixz -9' -cf /tmp/ghc-$ghc-$arch-$triple.tar.xz .
diff --git a/testing/ghc-bootstrap/bootstrap/x86_64/bootstrap.patch b/testing/ghc-bootstrap/bootstrap/x86_64/bootstrap.patch
new file mode 100644
index 0000000..b2ef497
--- /dev/null
+++ b/testing/ghc-bootstrap/bootstrap/x86_64/bootstrap.patch
_at_@ -0,0 +1,397 @@
+diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
+index 42ac14e..75a7471 100644
+--- a/compiler/main/DynFlags.hs
++++ b/compiler/main/DynFlags.hs
+_at_@ -2353,8 +2353,7 @@ dynamic_flags = [
+   , defGhcFlag "dynload"            (hasArg parseDynLibLoaderMode)
+   , defGhcFlag "dylib-install-name" (hasArg setDylibInstallName)
+     -- -dll-split is an internal flag, used only during the GHC build
+-  , defHiddenFlag "dll-split"
+-      (hasArg (\f d -> d{ dllSplitFile = Just f, dllSplit = Nothing }))
++  , defHiddenFlag "dll-split"       (NoArg (addWarn "ignoring -dll-split"))
+ 
+         ------- Libraries ---------------------------------------------------
+   , defFlag "L"   (Prefix addLibraryPath)
+diff --git a/ghc.mk b/ghc.mk
+index 9aa0dc3..97464b8 100644
+--- a/ghc.mk
++++ b/ghc.mk
+_at_@ -386,7 +386,7 @@ else
+ PACKAGES_STAGE0 = binary Cabal/Cabal hpc bin-package-db hoopl transformers
+ ifeq "$(Windows_Host)" "NO"
+ ifneq "$(HostOS_CPP)" "ios"
+-PACKAGES_STAGE0 += terminfo
++PACKAGES_STAGE0 +=
+ endif
+ endif
+ 
+_at_@ -424,7 +424,7 @@ endif
+ 
+ ifeq "$(Windows_Target)" "NO"
+ ifneq "$(TargetOS_CPP)" "ios"
+-PACKAGES_STAGE1 += terminfo
++PACKAGES_STAGE1 +=
+ endif
+ endif
+ PACKAGES_STAGE1 += haskeline
+_at_@ -444,7 +444,9 @@ REGULAR_INSTALL_DYNLIBS += $(addprefix libraries/,$(PACKAGES_STAGE2))
+ REGULAR_INSTALL_DYNLIBS := $(filter-out $(REGULAR_INSTALL_PACKAGES),\
+                                         $(REGULAR_INSTALL_DYNLIBS))
+ 
+-ifneq "$(CrossCompiling)" "YES"
++# See Note [No stage2 packages when CrossCompiling or Stage1Only].
++# See Note [Stage1Only vs stage=1] in mk/config.mk.in.
++ifeq "$(CrossCompiling) $(Stage1Only)" "NO NO"
+ define addExtraPackage
+ ifeq "$2" "-"
+ # Do nothing; this package is already handled above
+_at_@ -486,7 +488,7 @@ endif
+ endif
+ 
+ # -------------------------------------------
+-# Dependencies between package-data.mk files
++# Note [Dependencies between package-data.mk files].
+ 
+ # We cannot run ghc-cabal to configure a package until we have
+ # configured and registered all of its dependencies.  So the following
+_at_@ -506,29 +508,34 @@ ifneq "$(BINDIST)" "YES"
+ fixed_pkg_prev=
+ $(foreach pkg,$(PACKAGES_STAGE1),$(eval $(call fixed_pkg_dep,$(pkg),dist-install)))
+ 
++# Intermezzo: utils that we build with the stage1 compiler. They depend on
++# the stage1 packages, so we have to make sure those packages get configured
++# and registered before we can start with these. Note that they don't depend on
++# eachother, so we can configure them in parallel.
++utils/ghc-pwd/dist-install/package-data.mk: $(fixed_pkg_prev)
++utils/ghc-cabal/dist-install/package-data.mk: $(fixed_pkg_prev)
++utils/hpc/dist-install/package-data.mk: $(fixed_pkg_prev)
++utils/ghc-pkg/dist-install/package-data.mk: $(fixed_pkg_prev)
++utils/hsc2hs/dist-install/package-data.mk: $(fixed_pkg_prev)
++utils/compare_sizes/dist-install/package-data.mk: $(fixed_pkg_prev)
++utils/runghc/dist-install/package-data.mk: $(fixed_pkg_prev)
++
+ # the GHC package doesn't live in libraries/, so we add its dependency manually:
+ compiler/stage2/package-data.mk: $(fixed_pkg_prev)
+-fixed_pkg_prev:=compiler/stage2/package-data.mk
+ 
+ # and continue with PACKAGES_STAGE2, which depend on GHC:
++fixed_pkg_prev:=compiler/stage2/package-data.mk
+ $(foreach pkg,$(PACKAGES_STAGE2),$(eval $(call fixed_pkg_dep,$(pkg),dist-install)))
+ 
+ ghc/stage1/package-data.mk: compiler/stage1/package-data.mk
+ ghc/stage2/package-data.mk: compiler/stage2/package-data.mk
+-# haddock depends on ghc and some libraries, but depending on GHC's
+-# package-data.mk is sufficient, as that in turn depends on all the
+-# libraries
+-utils/haddock/dist/package-data.mk: compiler/stage2/package-data.mk
+-utils/ghc-pwd/dist-install/package-data.mk: compiler/stage2/package-data.mk
+-utils/ghc-cabal/dist-install/package-data.mk: compiler/stage2/package-data.mk
+ 
++# Utils that we build with the stage2 compiler.
++# They depend on the ghc library and some other libraries, but depending on
++# the ghc library's package-data.mk is sufficient, as that in turn depends on
++# all the other libraries' package-data.mk files.
++utils/haddock/dist/package-data.mk: compiler/stage2/package-data.mk
+ utils/ghctags/dist-install/package-data.mk: compiler/stage2/package-data.mk
+-utils/dll-split/dist-install/package-data.mk: compiler/stage2/package-data.mk
+-utils/hpc/dist-install/package-data.mk: compiler/stage2/package-data.mk
+-utils/ghc-pkg/dist-install/package-data.mk: compiler/stage2/package-data.mk
+-utils/hsc2hs/dist-install/package-data.mk: compiler/stage2/package-data.mk
+-utils/compare_sizes/dist-install/package-data.mk: compiler/stage2/package-data.mk
+-utils/runghc/dist-install/package-data.mk: compiler/stage2/package-data.mk
+ utils/mkUserGuidePart/dist/package-data.mk: compiler/stage2/package-data.mk
+ 
+ # add the final package.conf dependency: ghc-prim depends on RTS
+_at_@ -598,26 +605,12 @@ endif
+ 
+ # -----------------------------------------------------------------------------
+ # Include build instructions from all subdirs
+-
+-ifneq "$(BINDIST)" "YES"
+ BUILD_DIRS += utils/mkdirhier
+-endif
+-
+-ifeq "$(Windows_Host)" "YES"
+ BUILD_DIRS += utils/touchy
+-endif
+-
+ BUILD_DIRS += utils/unlit
+ BUILD_DIRS += utils/hp2ps
+-
+-ifneq "$(GhcUnregisterised)" "YES"
+ BUILD_DIRS += driver/split
+-endif
+-
+-ifneq "$(BINDIST)" "YES"
+ BUILD_DIRS += utils/genprimopcode
+-endif
+-
+ BUILD_DIRS += driver
+ BUILD_DIRS += driver/ghci
+ BUILD_DIRS += driver/ghc
+_at_@ -626,11 +619,8 @@ BUILD_DIRS += libffi
+ BUILD_DIRS += utils/deriveConstants
+ BUILD_DIRS += includes
+ BUILD_DIRS += rts
+-
+-ifneq "$(BINDIST)" "YES"
+ BUILD_DIRS += bindisttest
+ BUILD_DIRS += utils/genapply
+-endif
+ 
+ ifneq "$(CLEANING)" "YES"
+ # These are deliberately in reverse order, so as to ensure that
+_at_@ -647,52 +637,76 @@ endif
+ endif
+ 
+ 
+-ifeq "$(INTEGER_LIBRARY)" "integer-gmp"
+ BUILD_DIRS += libraries/integer-gmp/gmp
+ BUILD_DIRS += libraries/integer-gmp/mkGmpDerivedConstants
+-else ifneq "$(findstring clean,$(MAKECMDGOALS))" ""
+-BUILD_DIRS += libraries/integer-gmp/gmp
+-BUILD_DIRS += libraries/integer-gmp/mkGmpDerivedConstants
+-endif
+-
+-ifeq "$(INTEGER_LIBRARY)" "integer-gmp2"
+-BUILD_DIRS += libraries/integer-gmp2/gmp
+-else ifneq "$(findstring clean,$(MAKECMDGOALS))" ""
+ BUILD_DIRS += libraries/integer-gmp2/gmp
+-endif
+-
+-ifeq "$(HADDOCK_DOCS)" "YES"
+ BUILD_DIRS += utils/haddock
+ BUILD_DIRS += utils/haddock/doc
+-endif
+-
+ BUILD_DIRS += compiler
+ BUILD_DIRS += utils/hsc2hs
+ BUILD_DIRS += utils/ghc-pkg
+ BUILD_DIRS += utils/testremove
+-ifneq "$(Stage1Only)" "YES"
+ BUILD_DIRS += utils/ghctags
+-endif
+-BUILD_DIRS += utils/dll-split
+ BUILD_DIRS += utils/ghc-pwd
+ BUILD_DIRS += utils/ghc-cabal
+ BUILD_DIRS += utils/hpc
+ BUILD_DIRS += utils/runghc
+ BUILD_DIRS += ghc
+-
+-ifneq "$(BINDIST)" "YES"
+-ifneq "$(CrossCompiling)-$(phase)" "YES-final"
+ BUILD_DIRS += utils/mkUserGuidePart
+-endif
+-endif
+-
+ BUILD_DIRS += docs/users_guide
+ BUILD_DIRS += docs/man
+ BUILD_DIRS += utils/count_lines
+ BUILD_DIRS += utils/compare_sizes
+ 
+ # ----------------------------------------------
+-# Actually include all the sub-ghc.mk's
++# Actually include the sub-ghc.mk's
++
++ifeq "$(CLEANING)" "YES"
++# Don't exclude any BUILD_DIRS when cleaning. When you for example build
++# haddock once, but later set HADDOCK_DOCS back to NO, then 'make clean'
++# should still clean the haddock directory.
++else # CLEANING
++ifeq "$(BINDIST)" "YES"
++BUILD_DIRS := $(filter-out utils/mkdirhier,$(BUILD_DIRS))
++BUILD_DIRS := $(filter-out utils/genprimopcode,$(BUILD_DIRS))
++BUILD_DIRS := $(filter-out bindisttest,$(BUILD_DIRS))
++BUILD_DIRS := $(filter-out utils/genapply,$(BUILD_DIRS))
++BUILD_DIRS := $(filter-out utils/mkUserGuidePart,$(BUILD_DIRS))
++endif
++ifeq "$(HADDOCK_DOCS)" "NO"
++BUILD_DIRS := $(filter-out utils/haddock,$(BUILD_DIRS))
++BUILD_DIRS := $(filter-out utils/haddock/doc,$(BUILD_DIRS))
++endif
++ifeq "$(BUILD_DOCBOOK_HTML) $(BUILD_DOCBOOK_PS) $(BUILD_DOCBOOK_PDF)" "NO NO NO"
++# Don't to build this little utility if we're not building the User's Guide.
++BUILD_DIRS := $(filter-out utils/mkUserGuidePart,$(BUILD_DIRS))
++endif
++ifeq "$(Windows_Host)" "NO"
++BUILD_DIRS := $(filter-out utils/touchy,$(BUILD_DIRS))
++endif
++ifeq "$(GhcUnregisterised)" "YES"
++BUILD_DIRS := $(filter-out driver/split,$(BUILD_DIRS))
++endif
++ifeq "$(GhcWithInterpreter)" "NO"
++# runghc is just GHCi in disguise
++BUILD_DIRS := $(filter-out utils/runghc,$(BUILD_DIRS))
++endif
++ifneq "$(INTEGER_LIBRARY)" "integer-gmp"
++BUILD_DIRS := $(filter-out libraries/integer-gmp/gmp,$(BUILD_DIRS))
++BUILD_DIRS := $(filter-out libraries/integer-gmp/mkGmpDerivedConstants,$(BUILD_DIRS))
++endif
++ifneq "$(INTEGER_LIBRARY)" "integer-gmp2"
++BUILD_DIRS := $(filter-out libraries/integer-gmp2/gmp,$(BUILD_DIRS))
++endif
++ifneq "$(CrossCompiling) $(Stage1Only)" "NO NO"
++# See Note [No stage2 packages when CrossCompiling or Stage1Only].
++# See Note [Stage1Only vs stage=1] in mk/config.mk.in.
++BUILD_DIRS := $(filter-out utils/haddock,$(BUILD_DIRS))
++BUILD_DIRS := $(filter-out utils/haddock/doc,$(BUILD_DIRS))
++BUILD_DIRS := $(filter-out utils/ghctags,$(BUILD_DIRS))
++BUILD_DIRS := $(filter-out utils/mkUserGuidePart,$(BUILD_DIRS))
++endif
++endif # CLEANING
+ 
+ include $(patsubst %, %/ghc.mk, $(BUILD_DIRS))
+ 
+_at_@ -737,6 +751,11 @@ $(eval $(call clean-target,root,bootstrapping_conf,$(BOOTSTRAPPING_CONF)))
+ # lost).
+ fixed_pkg_prev=
+ $(foreach pkg,$(PACKAGES_STAGE0),$(eval $(call fixed_pkg_dep,$(pkg),dist-boot)))
++# ghc-pkg, unlike other utils that we build with the stage0 compiler (TODO: is
++# this really true?), depends on several boot packages (e.g. Cabal and
++# bin-package-db). They need to be configured before ghc-pkg, so we add a
++# dependency between their package-data.mk files. See also Note
++# [Dependencies between package-data.mk files].
+ utils/ghc-pkg/dist/package-data.mk: $(fixed_pkg_prev)
+ compiler/stage1/package-data.mk:    $(fixed_pkg_prev)
+ endif
+_at_@ -900,8 +919,8 @@ INSTALLED_PACKAGE_CONF=$(DESTDIR)$(topdir)/package.conf.d
+ # Install packages in the right order, so that ghc-pkg doesn't complain.
+ # Also, install ghc-pkg first.
+ ifeq "$(Windows_Host)" "NO"
+-INSTALLED_GHC_REAL=$(DESTDIR)$(ghclibexecdir)/bin/ghc
+-INSTALLED_GHC_PKG_REAL=$(DESTDIR)$(ghclibexecdir)/bin/ghc-pkg
++INSTALLED_GHC_REAL=$(CURDIR)/inplace/bin/ghc-stage1
++INSTALLED_GHC_PKG_REAL=$(CURDIR)/utils/ghc-pkg/dist/build/tmp/ghc-pkg
+ else
+ INSTALLED_GHC_REAL=$(DESTDIR)$(bindir)/ghc.exe
+ INSTALLED_GHC_PKG_REAL=$(DESTDIR)$(bindir)/ghc-pkg.exe
+_at_@ -1398,6 +1417,50 @@ endif
+ 	cd libraries/xhtml && ./Setup clean   --builddir=dist-bindist
+ 	cd libraries/xhtml && rm -f Setup Setup.exe Setup.hi Setup.o
+ 
++# Note [No stage2 packages when CrossCompiling or Stage1Only]
++#
++# (first read Note [CrossCompiling vs Stage1Only] and
++#  Note [Stage1Only vs stage=1] in mk/config.mk.in)
++#
++# When either CrossCompiling=YES or Stage1Only=YES, we have to exclude the
++# following packages from the build:
++#   * packages that we build with ghc-stage2 [1]
++#   * packages that depend on the ghc library [2]
++#
++# Here's why:
++#  - first of all, ghc-stage1 can't use stage0's ghc library (it's too old)
++#  - neither do we register the ghc library (compiler/stage1) that we build
++#    with stage0. TODO Why not? We do build it...
++#  - as a result, we need to a) use ghc-stage2 to build packages that depend on
++#    the ghc library (e.g. ghctags [4] and mkUserGuidePart) and b) exclude
++#    those packages when ghc-stage2 is not available.
++#  - when Stage1Only=YES, it's clear that ghc-stage2 is not available (we just
++#    said we didn't want it), so we have to exclude the stage2 packages from
++#    the build. This includes the case where Stage1Only=YES is combined with
++#    CrossCompiling=YES (Building GHC as a cross-compiler [3]).
++#  - when CrossCompiling=YES, but Stage1Only=NO (Cross-compiling GHC itself
++#    [3]), we can not use ghc-stage2 either. The reason is that stage2 doesn't
++#    run on the host platform at all; it is built to run on $(TARGETPLATFORM)"
++#    [5]. Therefore in this case we also have to exclude the stage2 packages
++#    from the build.
++#
++#  [1] find utils -name ghc.mk | xargs grep -l 'build-prog.*,2'
++#
++#  [2]
++#  find utils -name package-data.mk | xargs grep -l 'DEP_NAMES =.* ghc\($\| \)'
++#
++#  [3] https://ghc.haskell.org/trac/ghc/wiki/Building/CrossCompiling
++#
++#  [4] 5fb72555f7b7ab67a33583f33ad9160761ca434f
++#      "ghctags needs the stage2 compiler, since it uses the GHC API."
++#
++#  [5] * bc31dbe8ee22819054df60f5ef219fed393a1c54
++#      "Disable any packages built with stage 2 when cross-compiling
++#       Since we can't run stage 2 on the host."
++#
++#      * 72995160b0b190577b5c0cb8d7bd0426cc455b05
++#      "We cannot use the stage 2 compiler, it runs on $(TARGETPLATFORM)"
++
+ # -----------------------------------------------------------------------------
+ # Numbered phase targets
+ 
+diff --git a/libffi/ghc.mk b/libffi/ghc.mk
+index 59e089d..7e743f6 100644
+--- a/libffi/ghc.mk
++++ b/libffi/ghc.mk
+_at_@ -65,6 +65,7 @@ $(libffi_STAMP_CONFIGURE): $(TOUCH_DEP)
+ # We have to fake a non-working ln for configure, so that the fallback
+ # option (cp -p) gets used instead.  Otherwise the libffi build system
+ # will use cygwin symbolic links which cannot be read by mingw gcc.
++	cp /usr/share/misc/config.sub libffi/build/config.sub
+ 	chmod +x libffi/ln
+ 
+ 	# don't report nonselinux systems as selinux
+diff --git a/rules/build-package-way.mk b/rules/build-package-way.mk
+index 27da099..10d8863 100644
+--- a/rules/build-package-way.mk
++++ b/rules/build-package-way.mk
+_at_@ -58,17 +58,6 @@ $1_$2_$3_ALL_OBJS = $$($1_$2_$3_HS_OBJS) $$($1_$2_$3_NON_HS_OBJS)
+ 
+ ifeq "$3" "dyn"
+ 
+-ifneq "$$($1_$2_dll0_MODULES)" ""
+-$$($1_$2_$3_LIB)  : $1/$2/dll-split.stamp
+-ifneq "$$($1_$2_$3_LIB0)" ""
+-$$($1_$2_$3_LIB0) : $1/$2/dll-split.stamp
+-endif
+-endif
+-
+-$1/$2/dll-split.stamp: $$($1_$2_depfile_haskell) $$$$(dll-split_INPLACE)
+-	$$(dll-split_INPLACE) $$< "$$($1_$2_dll0_START_MODULE)" "$$($1_$2_dll0_MODULES)"
+-	touch $$_at_
+-
+ # Link a dynamic library
+ # On windows we have to supply the extra libs this one links to when building it.
+ ifeq "$$(HostOS_CPP)" "mingw32"
+diff --git a/rules/distdir-way-opts.mk b/rules/distdir-way-opts.mk
+index 99f7ce9..cb4709b 100644
+--- a/rules/distdir-way-opts.mk
++++ b/rules/distdir-way-opts.mk
+_at_@ -139,14 +139,6 @@ $1_$2_$3_ALL_HC_OPTS = \
+  $$(if $$(findstring YES,$$($1_$2_SplitObjs)),$$(if $$(findstring dyn,$3),,-split-objs),) \
+  $$(if $$(findstring YES,$$($1_$2_DYNAMIC_TOO)),$$(if $$(findstring v,$3),-dynamic-too))
+ 
+-ifeq "$3" "dyn"
+-ifeq "$$(HostOS_CPP)" "mingw32"
+-ifneq "$$($1_$2_dll0_MODULES)" ""
+-$1_$2_$3_ALL_HC_OPTS += -dll-split $1/$2/dll-split
+-endif
+-endif
+-endif
+-
+ $1_$2_$3_ALL_CC_OPTS = \
+  $$(WAY_$3_CC_OPTS) \
+  $$($1_$2_DIST_GCC_CC_OPTS) \
+diff --git a/utils/ghc-pkg/Main.hs b/utils/ghc-pkg/Main.hs
+index decdb38..f852114 100644
+--- a/utils/ghc-pkg/Main.hs
++++ b/utils/ghc-pkg/Main.hs
+_at_@ -1,6 +1,7 @@
+ {-# LANGUAGE CPP, TypeSynonymInstances, FlexibleInstances, RecordWildCards,
+              GeneralizedNewtypeDeriving, StandaloneDeriving #-}
+ {-# OPTIONS_GHC -fno-warn-orphans #-}
++#define BOOTSTRAPPING
+ -----------------------------------------------------------------------------
+ --
+ -- (c) The University of Glasgow 2004-2009.
+diff --git a/utils/ghc-pkg/ghc-pkg.cabal b/utils/ghc-pkg/ghc-pkg.cabal
+index 317aab7..72b244a 100644
+--- a/utils/ghc-pkg/ghc-pkg.cabal
++++ b/utils/ghc-pkg/ghc-pkg.cabal
+_at_@ -28,7 +28,7 @@ Executable ghc-pkg
+                    bin-package-db,
+                    bytestring
+     if !os(windows)
+-        Build-Depends: unix,
+-                       terminfo
++        Build-Depends: unix
++
+     if os(windows)
+         c-sources: CRT_noglob.c
diff --git a/testing/ghc-bootstrap/bootstrap/x86_64/settings b/testing/ghc-bootstrap/bootstrap/x86_64/settings
new file mode 100644
index 0000000..59e12d7
--- /dev/null
+++ b/testing/ghc-bootstrap/bootstrap/x86_64/settings
_at_@ -0,0 +1,32 @@
+[("GCC extra via C opts", " -fwrapv"),
+ ("C compiler command", "gcc"),
+ ("C compiler flags", " -fno-stack-protector"),
+ ("C compiler link flags", "--no-pie"),
+ ("Haskell CPP command","gcc"),
+ ("Haskell CPP flags","-E -undef -traditional "),
+ ("ld command", "ld.gold"),
+ ("ld flags", ""),
+ ("ld supports compact unwind", "YES"),
+ ("ld supports build-id", "YES"),
+ ("ld supports filelist", "NO"),
+ ("ld is GNU ld", "YES"),
+ ("ar command", "ar"),
+ ("ar flags", "q"),
+ ("ar supports at file", "YES"),
+ ("touch command", "touch"),
+ ("dllwrap command", "/bin/false"),
+ ("windres command", "/bin/false"),
+ ("libtool command", "libtool"),
+ ("readelf command", "readelf"),
+ ("perl command", "perl"),
+ ("cross compiling", "YES"),
+ ("target os", "OSLinux"),
+ ("target arch", "ArchX86_64"),
+ ("target word size", "8"),
+ ("target has GNU nonexec stack", "True"),
+ ("target has .ident directive", "True"),
+ ("target has subsections via symbols", "False"),
+ ("Unregisterised", "NO"),
+ ("LLVM llc command", "/usr/lib/ghc/llc-3.5"),
+ ("LLVM opt command", "/usr/lib/ghc/opt-3.5")
+ ]
-- 
2.7.0
---
Unsubscribe:  alpine-aports+unsubscribe_at_lists.alpinelinux.org
Help:         alpine-aports+help_at_lists.alpinelinux.org
---
Received on Tue Mar 01 2016 - 19:28:55 GMT