X-Original-To: alpine-aports@mail.alpinelinux.org Delivered-To: alpine-aports@mail.alpinelinux.org Received: from mail.alpinelinux.org (dallas-a1.alpinelinux.org [127.0.0.1]) by mail.alpinelinux.org (Postfix) with ESMTP id 05438DC00FE for ; Mon, 16 May 2016 03:30:36 +0000 (UTC) Received: from mail-ig0-f195.google.com (mail-ig0-f195.google.com [209.85.213.195]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mail.alpinelinux.org (Postfix) with ESMTPS id BD955DC06BA for ; Mon, 16 May 2016 03:30:35 +0000 (UTC) Received: by mail-ig0-f195.google.com with SMTP id jn6so5893928igb.2 for ; Sun, 15 May 2016 20:30:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=EUqOWBONskyxa6a5s7fG7KjUOTcd/aYwbU5NwDuBxHo=; b=K4rilBUf+X9yDBE0bBMKinxr79qajJJToAN/pjMe8RPgjFLCj85PBJgOHLYoSFncug j2EiVPVte5y2XU6irf2Qg3aqEJRp/LhEDcF/xoLv9qNeNo6NRlfZ7yAASDjTyw+NAqcL gVDdlJ2lw+Iwf+6z1O3bHCqJwr4WB5pLVSmos0Xp64qalrMC0+h7Y3NGX6YktbgX98b3 Bn5jHm9vNyce2l6Mexw3M2X8hhtOvIFT5Pnu4/P1yUpT72PttR/uVNB2/86Ra4pg4yu/ H/g63q/7Iy74b7NCQp12THODrlo4/ZUqxXVLacIeDkVxLpjUgC+s0zHtWzrXNqNe0YHC LfsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=EUqOWBONskyxa6a5s7fG7KjUOTcd/aYwbU5NwDuBxHo=; b=HjpWSzlk3kc/W1q9OG3PWWKqrnTgeIWG+INiqXjGZrl99NffbCncbACj44DyWwo1xm iuu6wmkJieYk+365+W57eN42WJnKNQSHJ1jvXgBxRGy7rfWTC83ioXm7tbSlYwM1BwdF +o7vSWKKsoFis/KiXxwKSgQdksJ9Qx/Trj3NM093GATv1wFt+9RrBMuFhLiW8/e/o4fX l9EDJX9JiTw+d+FIBwEzQtqD25HE7hYdardE2RR9Rbn00NKEMI/x8N7gcuXCyBhuuDVq T3Unv4uuqfOTHB5cleLWr/8+v3zz6JrUWBAG5xgBvKtZ9AS8JqGAyI3QwvAGXf+jhoPf 1KGw== X-Gm-Message-State: AOPr4FUjDJKGh2LRjNqcKifQGjwCE2ZXLxdM/VaKzVmY1Y//xm+E7m4bjLM06N7AhXjArg== X-Received: by 10.50.63.5 with SMTP id c5mr8627508igs.56.1463369435311; Sun, 15 May 2016 20:30:35 -0700 (PDT) Received: from mb.lan (c-73-24-18-171.hsd1.mn.comcast.net. [73.24.18.171]) by smtp.gmail.com with ESMTPSA id xp13sm4883406igc.19.2016.05.15.20.30.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 15 May 2016 20:30:34 -0700 (PDT) From: Mitch Tishmack To: alpine-aports@lists.alpinelinux.org Cc: Mitch Tishmack Subject: [alpine-aports] [PATCH 2/4] testing/ghc-bootstrap new aport Date: Sun, 15 May 2016 22:30:16 -0500 Message-Id: <1463369418-51523-3-git-send-email-mitch.tishmack@gmail.com> X-Mailer: git-send-email 2.8.0 In-Reply-To: <1463369418-51523-1-git-send-email-mitch.tishmack@gmail.com> References: <1463369418-51523-1-git-send-email-mitch.tishmack@gmail.com> X-Virus-Scanned: ClamAV using ClamSMTP X-Mailinglist: alpine-aports Precedence: list List-Id: Alpine Development List-Unsubscribe: List-Post: List-Help: List-Subscribe: --- testing/ghc-bootstrap/APKBUILD | 50 +++++++ testing/ghc-bootstrap/bootstrap/armhf/Dockerfile | 154 +++++++++++++++++++++ .../ghc-bootstrap/bootstrap/armhf/bootstrap.patch | 112 +++++++++++++++ testing/ghc-bootstrap/bootstrap/armhf/settings | 32 +++++ testing/ghc-bootstrap/bootstrap/gmpurl.patch | 22 +++ testing/ghc-bootstrap/bootstrap/llvm-3.7.1.sh | 88 ++++++++++++ testing/ghc-bootstrap/bootstrap/x86_64/Dockerfile | 143 +++++++++++++++++++ .../ghc-bootstrap/bootstrap/x86_64/bootstrap.patch | 112 +++++++++++++++ testing/ghc-bootstrap/bootstrap/x86_64/settings | 32 +++++ 9 files changed, 745 insertions(+) create mode 100755 testing/ghc-bootstrap/APKBUILD create mode 100644 testing/ghc-bootstrap/bootstrap/armhf/Dockerfile create mode 100644 testing/ghc-bootstrap/bootstrap/armhf/bootstrap.patch create mode 100644 testing/ghc-bootstrap/bootstrap/armhf/settings create mode 100644 testing/ghc-bootstrap/bootstrap/gmpurl.patch create mode 100755 testing/ghc-bootstrap/bootstrap/llvm-3.7.1.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..063a4dd --- /dev/null +++ b/testing/ghc-bootstrap/APKBUILD @@ -0,0 +1,50 @@ +#-*-mode: Shell-script; coding: utf-8;-*- +# Maintainer: Mitch Tishmack +# +# Build/bootstrap ghc similarly to the go package. +# Caveat: bootstrapping isn't a commonly tested piece of ghc. +pkgname=ghc-bootstrap +pkgdesc="The Glasgow haskell compiler (bootstrapped)" +apkgver=8.0.1 +pkgrel=0 +pkgver=$(echo ${apkgver} | tr -d '[a-z]') +url="http://haskell.org" +subpackages="" +arch="x86_64 armhf" +# These are the one's I've built, will need to be replaced by the correct url produced from package() +# and uploaded to alpine linux servers. +source=" + https://s3-us-west-2.amazonaws.com/alpine-ghc/next/ghc-8.0.1-x86_64-unknown-linux-musl.tar.xz + https://s3-us-west-2.amazonaws.com/alpine-ghc/next/ghc-8.0.1-arm-unknown-linux-musleabihf.tar.xz +" +license="custom:bsd3" +depends="bash libffi musl zlib gcc binutils-gold ghc-llvm" +install="" +subpackages="" +makedepends="perl" + +package() { + cd "$srcdir/$CARCH" + install -d "$pkgdir" || return 1 + mv usr "$pkgdir" || return 1 + settings=$(find "$pkgdir" -name settings -type f) +} + +# 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 to build bootstrapped +# ghc +snapshot () { + docker build -t ghc-bootstrap:x86_64 -f bootstrap/x86_64/Dockerfile . + docker run -a stdout "ghc-bootstrap:x86_64" /bin/cat "/tmp/ghc-${apkgver}-x86_64-pc-linux-musl.tar.xz" > ghc-${apkgver}-x86_64-unknown-linux-musl.tar.xz + docker build -t ghc-bootstrap:armhf -f bootstrap/armhf/Dockerfile . + docker run -a stdout "ghc-bootstrap:armhf" /bin/cat "/tmp/ghc-${apkgver}-arm-unknown-linux-musleabihf.tar.xz" > ghc-${apkgver}-arm-unknown-linux-musleabihf.tar.xz + scp "ghc-$pkgver-*-unknown-linux-musl*.tar.xz" dev.alpinelinux.org:/archive/ghc-bootstrap/ || return 1 +} +md5sums="af5244e96269555debc669518a723c82 ghc-8.0.1-x86_64-unknown-linux-musl.tar.xz +dd9f06d557d1c3d1ff1195fabdff4213 ghc-8.0.1-arm-unknown-linux-musleabihf.tar.xz" +sha256sums="ad4215344c5fcd5ff3126f7372b0bd838705603b0fc1b95ba14cc6d6e0e749bd ghc-8.0.1-x86_64-unknown-linux-musl.tar.xz +bb7e1523f05a7da0fc669ae24046171b6caaa61fe0634c52cb0caf9b43661245 ghc-8.0.1-arm-unknown-linux-musleabihf.tar.xz" +sha512sums="12d1d1e3cf89330db63e6b10bf63cea4db75da71a75ca69e4b4c31e5f90aa3f770f4bffab5f1cfbb2d859128618d42e2ecfed6baad7e905d3e1ba7611806ef89 ghc-8.0.1-x86_64-unknown-linux-musl.tar.xz +4beb817b5eed6267c610175c7ba0c95959eac3328ce3c5a08ef42150846ed19c9b714f767abe486cce744eb6c7738d847cea256ed1e278784c72d0afe0b4bbe1 ghc-8.0.1-arm-unknown-linux-musleabihf.tar.xz" diff --git a/testing/ghc-bootstrap/bootstrap/armhf/Dockerfile b/testing/ghc-bootstrap/bootstrap/armhf/Dockerfile new file mode 100644 index 0000000..5ca1eb2 --- /dev/null +++ b/testing/ghc-bootstrap/bootstrap/armhf/Dockerfile @@ -0,0 +1,154 @@ +# Mostly self contained setup to build a stage2 ghc for musl +from debian:8.0 + +# Install stock bindist for cross compile +env ghc 7.10.3 +env arch x86_64 +env llvm 3.7.1 +env cabal 1.22.9.0 + +# all needed packages for compiling +run apt-get clean && \ + 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 \ + openssl \ + bison \ + flex \ + git + +add http://llvm.org/releases/$llvm/llvm-$llvm.src.tar.xz /tmp/ +add http://llvm.org/releases/$llvm/polly-$llvm.src.tar.xz /tmp/ + +# Install a non ancient version of llvm on debian, I'm purposefully ignoring +# debian repos in favor of compiling to not have to deal with +# "what debian upstream has a current version of llvm" nonsense, takes more +# time to do that than just build the right llvm from source. +workdir /tmp +copy bootstrap/llvm-$llvm.sh /tmp/llvm.sh +run openssl sha1 llvm-$llvm.src.tar.xz | grep "SHA1(llvm-3.7.1.src.tar.xz)= 5dbdcafac105273dcbff94c68837a66c6dd78cef" && \ + openssl sha1 polly-$llvm.src.tar.xz | grep "SHA1(polly-3.7.1.src.tar.xz)= 0e3a461907cde7505fbdb44bf61ff318aa9254f7" && \ + tar xJpf /tmp/llvm-$llvm.src.tar.xz && \ + tar xJpf /tmp/polly-$llvm.src.tar.xz && \ + /tmp/llvm.sh && \ + rm -fr /tmp/llvm-$llvm.src + +add https://downloads.haskell.org/~ghc/$ghc/ghc-$ghc-$arch-deb8-linux.tar.xz /tmp/ + +# Install debian ghc binary from upstream. +workdir /tmp +run openssl sha1 ghc-$ghc-$arch-deb8-linux.tar.xz | grep "SHA1(ghc-7.10.3-x86_64-deb8-linux.tar.xz)= bab16f95ef4fe6b7cc2fb6b36a02dceeeb53faa4" && \ + tar xJpf /tmp/ghc-$ghc-$arch-deb8-linux.tar.xz +workdir /tmp/ghc-$ghc +run ./configure --prefix=/usr && \ + make -j1 install && \ + rm -fr /tmp/ghc-$ghc + +add https://www.haskell.org/cabal/release/cabal-install-$cabal/cabal-install-$cabal.tar.gz /tmp/ + +# Install cabal so we can install alex/happy to pull off of git +# bootstrap cabal and install alex/happy the same way apks are built +# only globally +workdir /tmp +run openssl sha1 cabal-install-$cabal.tar.gz | grep "SHA1(cabal-install-1.22.9.0.tar.gz)= f1375c928794f45f253b8ec92c2af4732fec597b" && \ + tar xzpf /tmp/cabal-install-$cabal.tar.gz +workdir /tmp/cabal-install-$cabal +run ./bootstrap.sh --global --no-doc && \ + cabal update && \ + cabal install --global alex happy && \ + rm -fr /tmp/cabal-install-$cabal + +# First up, install/compile the cross compiler with musl libc +# armv7 hard float cross compiler, we basically rebuild ghc again here with +# the cross compiler, and the llvm we built for x86_64 as well +workdir /tmp +run git clone --depth 1 https://github.com/GregorR/musl-cross.git musl-cross +workdir /tmp/musl-cross +run echo GCC_BUILTIN_PREREQS=yes >> config.sh && \ + echo ARCH=arm >> config.sh && \ + echo TRIPLE=arm-linux-musleabihf >> config.sh && \ + echo GCC_BOOTSTRAP_CONFFLAGS=\"--with-arch=armv6 --with-float=hard --with-fpu=vfp\" >> config.sh && \ + echo GCC_CONFFLAGS=\"--with-arch=armv6 --with-float=hard --with-fpu=vfp\" >> config.sh && \ + echo GCC_STAGE1_NOOPT=1 >> config.sh && \ + echo CC_BASE_PREFIX=/usr >> config.sh && \ + echo MAKEFLAGS=-j$(grep -c processor /proc/cpuinfo) >> config.sh && \ + echo "BINUTILS_CONFFLAGS='CXXFLAGS=-fpermissive --enable-gold --enable-plugins --disable-werror'" >> config.sh && \ + echo "CFLAGS='-g -O2 -fPIC -DPIC'" >> config.sh && \ + echo "CPPFLAGS='-fPIC -DPIC'" >> config.sh && \ + echo "LDFLAGS='-fPIC -DPIC'" >> config.sh +copy bootstrap/gmpurl.patch gmpurl.patch +run patch -p1 < gmpurl.patch && \ + ./build.sh && \ + rm -fr /tmp/musl-cross + +add http://downloads.haskell.org/~ghc/8.0.1/ghc-8.0.1-src.tar.xz /tmp/ + +env tardir /tmp/root +env destdir /tmp/root/armhf +env crosscc arm-linux-musleabihf-gcc +env target arm-linux-musleabihf +env triple arm-unknown-linux-musleabihf +env ghc 8.0.1 + +# add cross toolchain to PATH +env PATH /usr/$target/bin:$PATH + +workdir /tmp +run openssl sha1 ghc-$ghc-src.tar.xz | grep "SHA1(ghc-8.0.1-src.tar.xz)= 9b513ef7b1ab106eec3a9c59df8bd0245886010c" && \ + tar xJpf /tmp/ghc-$ghc-src.tar.xz +workdir /tmp/ghc-$ghc +env PATH $PATH:/usr/$triple/bin +copy bootstrap/$arch/bootstrap.patch bootstrap.patch +run patch -p1 < bootstrap.patch +run cp mk/build.mk.sample mk/build.mk && \ + ./boot && \ + echo "BuildFlavour = quick-llvm" >> mk/build.mk && \ + echo "INTEGER_LIBRARY = integer-simple" >> mk/build.mk && \ + echo "HADDOCK_DOCS = NO" >> mk/build.mk && \ + echo "BUILD_SPHINX_HTML = NO" >> mk/build.mk && \ + echo "BUILD_SPHINX_PS = NO" >> mk/build.mk && \ + echo "BUILD_SPHINX_PDF = NO" >> mk/build.mk && \ + ./configure \ + --target=$target \ + --prefix=/usr +run make -j$(grep -c processor /proc/cpuinfo) || make -j1 +run make -j1 install STRIP_CMD=$target-strip DESTDIR=$destdir + +# 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 $(find $destdir -name "*-hp2ps") + +# 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 $(find $destdir -name unlit) + +# remove target prefix from stage2 binaries +workdir $destdir/usr/bin +run (for i in $triple-* ; do ln -s $i ${i#$triple-} || /bin/true ; done ) +copy bootstrap/armhf/settings /tmp/settings +run mv /tmp/settings $(find $destdir -name settings -type f) +run rm -fr $destdir/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-$triple.tar.xz . diff --git a/testing/ghc-bootstrap/bootstrap/armhf/bootstrap.patch b/testing/ghc-bootstrap/bootstrap/armhf/bootstrap.patch new file mode 100644 index 0000000..7e5fc95 --- /dev/null +++ b/testing/ghc-bootstrap/bootstrap/armhf/bootstrap.patch @@ -0,0 +1,112 @@ +diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs +index fa1141e..6ff2ac4 100644 +--- a/compiler/main/DynFlags.hs ++++ b/compiler/main/DynFlags.hs +@@ -2448,8 +2448,7 @@ dynamic_flags_deps = [ + , make_ord_flag defGhcFlag "dynload" (hasArg parseDynLibLoaderMode) + , make_ord_flag defGhcFlag "dylib-install-name" (hasArg setDylibInstallName) + -- -dll-split is an internal flag, used only during the GHC build +- , make_ord_flag defHiddenFlag "dll-split" +- (hasArg (\f d -> d { dllSplitFile = Just f, dllSplit = Nothing })) ++ , make_ord_flag defHiddenFlag "dll-split" (NoArg (addWarn "ignoring -dll-split")) + + ------- Libraries --------------------------------------------------- + , make_ord_flag defFlag "L" (Prefix addLibraryPath) +diff --git a/ghc.mk b/ghc.mk +index 5e4ecc6..a07ff73 100644 +--- a/ghc.mk ++++ b/ghc.mk +@@ -433,7 +433,7 @@ else # CLEANING + PACKAGES_STAGE0 = binary Cabal/Cabal hpc ghc-boot hoopl transformers template-haskell + ifeq "$(Windows_Host)" "NO" + ifneq "$(HostOS_CPP)" "ios" +-PACKAGES_STAGE0 += terminfo ++PACKAGES_STAGE0 += + endif + endif + +@@ -471,7 +471,7 @@ endif + + ifeq "$(Windows_Target)" "NO" + ifneq "$(TargetOS_CPP)" "ios" +-PACKAGES_STAGE1 += terminfo ++PACKAGES_STAGE1 += + endif + endif + PACKAGES_STAGE1 += haskeline +@@ -968,8 +968,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 +diff --git a/rules/build-package-way.mk b/rules/build-package-way.mk +index 905b7f0..3e23b1f 100644 +--- a/rules/build-package-way.mk ++++ b/rules/build-package-way.mk +@@ -62,17 +62,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 $$@ +- + # 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 f099d4e..6dcf911 100644 +--- a/rules/distdir-way-opts.mk ++++ b/rules/distdir-way-opts.mk +@@ -160,13 +160,6 @@ $1_$2_$3_ALL_HC_OPTS = \ + $$(if $$(findstring YES,$$($1_$2_SplitSections)),$$(if $$(findstring dyn,$3),,-split-sections),) \ + $$(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) \ +diff --git a/utils/ghc-pkg/Main.hs b/utils/ghc-pkg/Main.hs +index af3032d..1c38e8e 100644 +--- a/utils/ghc-pkg/Main.hs ++++ b/utils/ghc-pkg/Main.hs +@@ -1,5 +1,6 @@ + {-# LANGUAGE CPP, TypeSynonymInstances, FlexibleInstances #-} + {-# 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 5f76e1b..2f9b558 100644 +--- a/utils/ghc-pkg/ghc-pkg.cabal ++++ b/utils/ghc-pkg/ghc-pkg.cabal +@@ -31,7 +31,7 @@ Executable ghc-pkg + ghc-boot, + 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/armhf/settings b/testing/ghc-bootstrap/bootstrap/armhf/settings new file mode 100644 index 0000000..b986a65 --- /dev/null +++ b/testing/ghc-bootstrap/bootstrap/armhf/settings @@ -0,0 +1,32 @@ +[("GCC extra via C opts", " -fwrapv -fno-builtin"), + ("C compiler command", "gcc"), + ("C compiler flags", " -marm -fno-stack-protector"), + ("C compiler link flags", " --no-pie -fuse-ld=gold -Wl,-z,noexecstack"), + ("Haskell CPP command","gcc"), + ("Haskell CPP flags","-E -undef -traditional"), + ("ld command", "ld.gold"), + ("ld flags", " -z noexecstack"), + ("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"), + ("perl command", "/usr/bin/perl"), + ("cross compiling", "YES"), + ("target os", "OSLinux"), + ("target arch", "ArchARM {armISA = ARMv6, armISAExt = [VFPv2], armABI = HARD}"), + ("target word size", "4"), + ("target has GNU nonexec stack", "False"), + ("target has .ident directive", "True"), + ("target has subsections via symbols", "False"), + ("Unregisterised", "NO"), + ("LLVM llc command", "/usr/lib/ghc/llc-3.7"), + ("LLVM opt command", "/usr/lib/ghc/opt-3.7") + ] + 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 @@ -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 +@@ -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 +@@ -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.7.1.sh b/testing/ghc-bootstrap/bootstrap/llvm-3.7.1.sh new file mode 100755 index 0000000..49e44df --- /dev/null +++ b/testing/ghc-bootstrap/bootstrap/llvm-3.7.1.sh @@ -0,0 +1,88 @@ +#!/usr/bin/env sh +#-*-mode: Shell-script; coding: utf-8;-*- +export script=$(basename "$0") +export dir=$(cd "$(dirname "$0")"; pwd) +export iam=${dir}/${script} +llvm_major=3.7 +llvm_version=${llvm_major}.1 +llvm_srcdir="/tmp/llvm-${llvm_version}.src" +suffix="-${llvm_major}" +llvm_builddir=/tmp/build +polly_orig_srcdir="/tmp/polly-$llvm_version.src" + +cd "$llvm_srcdir" + +_cmake_flags="\ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_VERBOSE_MAKEFILE=NO \ + -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_BUILD_DOCS=NO \ + -DLLVM_BUILD_TESTS=NO \ + -DLLVM_ENABLE_CXX1Y=NO \ + -DLLVM_ENABLE_FFI=YES \ + -DLLVM_ENABLE_SPHINX=NO \ + -DLLVM_ENABLE_TERMINFO=NO \ + -DLLVM_ENABLE_CURSES=NO \ + -DWITH_POLLY=YES \ + -DLLVM_INCLUDE_EXAMPLES=NO \ + -DLLVM_INCLUDE_TESTS=NO \ + " +srcdir_polly="$llvm_srcdir"/tools/polly +mv /tmp/polly-$llvm_version.src "$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 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..eb069e7 --- /dev/null +++ b/testing/ghc-bootstrap/bootstrap/x86_64/Dockerfile @@ -0,0 +1,143 @@ +# Mostly self contained setup to build a stage2 ghc for musl +from debian:8.0 + +# Install stock bindist for cross compile +env ghc 7.10.3 +env arch x86_64 +env llvm 3.7.1 +env cabal 1.22.9.0 + +# all needed packages for compiling +run apt-get clean && \ + 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 \ + openssl \ + git \ + bison \ + flex + +add http://llvm.org/releases/$llvm/llvm-$llvm.src.tar.xz /tmp/ +add http://llvm.org/releases/$llvm/polly-$llvm.src.tar.xz /tmp/ + +# Install a non ancient version of llvm on debian, I'm purposefully ignoring +# debian repos in favor of compiling to not have to deal with +# "what debian upstream has a current version of llvm" nonsense, takes more +# time to do that than just build the right llvm from source. +workdir /tmp +copy bootstrap/llvm-$llvm.sh /tmp/llvm.sh +run openssl sha1 llvm-$llvm.src.tar.xz | grep "SHA1(llvm-3.7.1.src.tar.xz)= 5dbdcafac105273dcbff94c68837a66c6dd78cef" && \ + openssl sha1 polly-$llvm.src.tar.xz | grep "SHA1(polly-3.7.1.src.tar.xz)= 0e3a461907cde7505fbdb44bf61ff318aa9254f7" && \ + tar xJpf /tmp/llvm-$llvm.src.tar.xz && \ + tar xJpf /tmp/polly-$llvm.src.tar.xz && \ + /tmp/llvm.sh && \ + rm -fr /tmp/llvm-$llvm.src + +add https://downloads.haskell.org/~ghc/$ghc/ghc-$ghc-$arch-deb8-linux.tar.xz /tmp/ + +# Install debian ghc binary from upstream. +workdir /tmp +run openssl sha1 ghc-$ghc-$arch-deb8-linux.tar.xz | grep "SHA1(ghc-7.10.3-x86_64-deb8-linux.tar.xz)= bab16f95ef4fe6b7cc2fb6b36a02dceeeb53faa4" && \ + tar xJpf /tmp/ghc-$ghc-$arch-deb8-linux.tar.xz +workdir /tmp/ghc-$ghc +run ./configure --prefix=/usr && \ + make -j1 install && \ + rm -fr /tmp/ghc-$ghc + +add https://www.haskell.org/cabal/release/cabal-install-$cabal/cabal-install-$cabal.tar.gz /tmp/ + +# Install cabal so we can install alex/happy to pull off of git +# bootstrap cabal and install alex/happy the same way apks are built +# only globally +workdir /tmp +run openssl sha1 cabal-install-$cabal.tar.gz | grep "SHA1(cabal-install-1.22.9.0.tar.gz)= f1375c928794f45f253b8ec92c2af4732fec597b" && \ + tar xzpf /tmp/cabal-install-$cabal.tar.gz +workdir /tmp/cabal-install-$cabal +run ./bootstrap.sh --global --no-doc && \ + cabal update && \ + cabal install --global alex happy && \ + rm -fr /tmp/cabal-install-$cabal + +# Build our cross compiler with musl libc from the sabotage linux stuff +workdir /tmp +run git clone --depth 1 https://github.com/GregorR/musl-cross.git musl-cross +workdir /tmp/musl-cross +run echo GCC_BUILTIN_PREREQS=yes >> config.sh && \ + echo ARCH=x86_64 >> config.sh && \ + echo TRIPLE=x86_64-pc-linux-musl >> config.sh && \ + echo GCC_STAGE1_NOOPT=1 >> config.sh && \ + echo CC_BASE_PREFIX=/usr >> config.sh && \ + echo MAKEFLAGS=-j$(grep -c processor /proc/cpuinfo) >> config.sh && \ + echo "BINUTILS_CONFFLAGS='CXXFLAGS=-fpermissive --enable-gold --enable-plugins --disable-werror'" >> config.sh && \ + echo "CFLAGS='-g -O2 -fPIC -DPIC'" >> config.sh && \ + echo "CPPFLAGS='-fPIC -DPIC'" >> config.sh && \ + echo "LDFLAGS='-fPIC -DPIC'" >> config.sh +copy bootstrap/gmpurl.patch gmpurl.patch +run patch -p1 < gmpurl.patch && \ + ./build.sh && \ + rm -fr /tmp/musl-cross + +add http://downloads.haskell.org/~ghc/8.0.1/ghc-8.0.1-src.tar.xz /tmp/ + +env tardir /tmp/root +env destdir /tmp/root/x86_64 +env triple x86_64-pc-linux-musl +env crosscc $triple-gcc +env ghc 8.0.1 + +workdir /tmp +run openssl sha1 ghc-$ghc-src.tar.xz | grep "SHA1(ghc-8.0.1-src.tar.xz)= 9b513ef7b1ab106eec3a9c59df8bd0245886010c" && \ + tar xJpf /tmp/ghc-$ghc-src.tar.xz +workdir /tmp/ghc-$ghc +env PATH $PATH:/usr/$triple/bin +copy bootstrap/$arch/bootstrap.patch bootstrap.patch +run patch -p1 < bootstrap.patch +run cp mk/build.mk.sample mk/build.mk && \ + ./boot && \ + echo "BuildFlavour = quick-llvm" >> mk/build.mk && \ + echo "INTEGER_LIBRARY = integer-simple" >> mk/build.mk && \ + echo "HADDOCK_DOCS = NO" >> mk/build.mk && \ + echo "BUILD_SPHINX_HTML = NO" >> mk/build.mk && \ + echo "BUILD_SPHINX_PS = NO" >> mk/build.mk && \ + echo "BUILD_SPHINX_PDF = NO" >> mk/build.mk && \ + ./configure \ + --target=$triple \ + --prefix=/usr +run make -j$(grep -c processor /proc/cpuinfo) || make -j1 +run make -j1 install DESTDIR=$destdir + +run rm $(find $destdir -name "*-hp2ps") + +# 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 $(find $destdir -name unlit) + +# remove target prefix from stage2 binaries +workdir $destdir/usr/bin +run (for i in $triple-* ; do ln -s $i ${i#$triple-} ; done ) +copy bootstrap/$arch/settings /tmp/settings +run mv /tmp/settings $(find $destdir -name settings -type f) +run rm -fr $destdir/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-$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..7e5fc95 --- /dev/null +++ b/testing/ghc-bootstrap/bootstrap/x86_64/bootstrap.patch @@ -0,0 +1,112 @@ +diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs +index fa1141e..6ff2ac4 100644 +--- a/compiler/main/DynFlags.hs ++++ b/compiler/main/DynFlags.hs +@@ -2448,8 +2448,7 @@ dynamic_flags_deps = [ + , make_ord_flag defGhcFlag "dynload" (hasArg parseDynLibLoaderMode) + , make_ord_flag defGhcFlag "dylib-install-name" (hasArg setDylibInstallName) + -- -dll-split is an internal flag, used only during the GHC build +- , make_ord_flag defHiddenFlag "dll-split" +- (hasArg (\f d -> d { dllSplitFile = Just f, dllSplit = Nothing })) ++ , make_ord_flag defHiddenFlag "dll-split" (NoArg (addWarn "ignoring -dll-split")) + + ------- Libraries --------------------------------------------------- + , make_ord_flag defFlag "L" (Prefix addLibraryPath) +diff --git a/ghc.mk b/ghc.mk +index 5e4ecc6..a07ff73 100644 +--- a/ghc.mk ++++ b/ghc.mk +@@ -433,7 +433,7 @@ else # CLEANING + PACKAGES_STAGE0 = binary Cabal/Cabal hpc ghc-boot hoopl transformers template-haskell + ifeq "$(Windows_Host)" "NO" + ifneq "$(HostOS_CPP)" "ios" +-PACKAGES_STAGE0 += terminfo ++PACKAGES_STAGE0 += + endif + endif + +@@ -471,7 +471,7 @@ endif + + ifeq "$(Windows_Target)" "NO" + ifneq "$(TargetOS_CPP)" "ios" +-PACKAGES_STAGE1 += terminfo ++PACKAGES_STAGE1 += + endif + endif + PACKAGES_STAGE1 += haskeline +@@ -968,8 +968,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 +diff --git a/rules/build-package-way.mk b/rules/build-package-way.mk +index 905b7f0..3e23b1f 100644 +--- a/rules/build-package-way.mk ++++ b/rules/build-package-way.mk +@@ -62,17 +62,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 $$@ +- + # 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 f099d4e..6dcf911 100644 +--- a/rules/distdir-way-opts.mk ++++ b/rules/distdir-way-opts.mk +@@ -160,13 +160,6 @@ $1_$2_$3_ALL_HC_OPTS = \ + $$(if $$(findstring YES,$$($1_$2_SplitSections)),$$(if $$(findstring dyn,$3),,-split-sections),) \ + $$(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) \ +diff --git a/utils/ghc-pkg/Main.hs b/utils/ghc-pkg/Main.hs +index af3032d..1c38e8e 100644 +--- a/utils/ghc-pkg/Main.hs ++++ b/utils/ghc-pkg/Main.hs +@@ -1,5 +1,6 @@ + {-# LANGUAGE CPP, TypeSynonymInstances, FlexibleInstances #-} + {-# 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 5f76e1b..2f9b558 100644 +--- a/utils/ghc-pkg/ghc-pkg.cabal ++++ b/utils/ghc-pkg/ghc-pkg.cabal +@@ -31,7 +31,7 @@ Executable ghc-pkg + ghc-boot, + 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..dbc15d4 --- /dev/null +++ b/testing/ghc-bootstrap/bootstrap/x86_64/settings @@ -0,0 +1,32 @@ +[("GCC extra via C opts", " -fwrapv -fno-builtin"), + ("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.7"), + ("LLVM opt command", "/usr/lib/ghc/opt-3.7") + ] -- 2.8.0 --- Unsubscribe: alpine-aports+unsubscribe@lists.alpinelinux.org Help: alpine-aports+help@lists.alpinelinux.org ---