Skip to content

Commit

Permalink
testing/ghc: init at 8.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchty committed Dec 31, 2016
1 parent da0e932 commit 6181b32
Show file tree
Hide file tree
Showing 3 changed files with 279 additions and 24 deletions.
28 changes: 28 additions & 0 deletions testing/ghc/0001-Correct-issue-with-libffi-and-glibc.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
From 843bd68ea83ba011d593ad7162d1df89c230004b Mon Sep 17 00:00:00 2001
From: Mitch Tishmack <mitch.tishmack@gmail.com>
Date: Sat, 15 Oct 2016 21:53:13 -0500
Subject: [PATCH 1/1] Correct issue with libffi and glibc

Ref: https://github.com/mitchty/alpine-linux-ghc-bootstrap/issues/16

Shamelessly learnt from here
https://github.com/nilcons/ghc-musl/blob/master/ghc-musl/Dockerfile#L24
---
libffi/ghc.mk | 1 +
1 file changed, 1 insertion(+)

diff --git a/libffi/ghc.mk b/libffi/ghc.mk
index 404cce9..2034873 100644
--- a/libffi/ghc.mk
+++ b/libffi/ghc.mk
@@ -61,6 +61,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.
+ sed -i s/__gnu_linux__/1/ libffi/build/src/closures.c
chmod +x libffi/ln

# We need to use -MMD rather than -MD, as otherwise we get paths
--
2.9.0

209 changes: 209 additions & 0 deletions testing/ghc/0002-rm-ghc-pwd.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
commit 4c56ad36ee0d1f8b6f1b2bc0d8fff1c9acd1a389
Author: Thomas Miedema <thomasmiedema@gmail.com>
Date: Mon Jan 4 18:29:49 2016 +0100

Build system: delete ghc-pwd

On Windows, with msys2, `pwd` works (as can be seen by the use of `pwd`
that slipped into the validate script), so there is really no need for
`ghc-pwd` anymore.

Test Plan: try it

Reviewers: austin, bgamari, Phyx

Reviewed By: Phyx

Subscribers: Phyx, erikd

Differential Revision: https://phabricator.haskell.org/D1731

diff --git a/aclocal.m4 b/aclocal.m4
index 8e97726..0c93de4 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1737,33 +1737,9 @@ AC_DEFUN([FP_CURSES],
# Calculate absolute path to build tree
# --------------------------------------------------------------

-AC_DEFUN([FP_INTREE_GHC_PWD],[
-AC_MSG_NOTICE(Building in-tree ghc-pwd)
- dnl This would be
- dnl make -C utils/ghc-pwd clean && make -C utils/ghc-pwd
- dnl except we don't want to have to know what make is called. Sigh.
- rm -rf utils/ghc-pwd/dist-boot
- mkdir utils/ghc-pwd/dist-boot
- dnl If special linker flags are needed to build things, then allow
- dnl the user to pass them in via LDFLAGS.
- changequote(, )dnl
- GHC_LDFLAGS=`perl -e 'foreach (@ARGV) { print "-optl$_ " }' -- $LDFLAGS`
- changequote([, ])dnl
- if ! "$WithGhc" $GHC_LDFLAGS -v0 -no-user-$GHC_PACKAGE_DB_FLAG -hidir utils/ghc-pwd/dist-boot -odir utils/ghc-pwd/dist-boot -stubdir utils/ghc-pwd/dist-boot --make utils/ghc-pwd/Main.hs -o utils/ghc-pwd/dist-boot/ghc-pwd
- then
- AC_MSG_ERROR([Building ghc-pwd failed])
- fi
-
- GHC_PWD=utils/ghc-pwd/dist-boot/ghc-pwd
-])
-
-AC_DEFUN([FP_BINDIST_GHC_PWD],[
- GHC_PWD=utils/ghc-pwd/dist-install/build/tmp/ghc-pwd-bindist
-])
-
AC_DEFUN([FP_FIND_ROOT],[
AC_MSG_CHECKING(for path to top of build tree)
- hardtop=`$GHC_PWD`
+ hardtop=`pwd`

dnl Remove common automounter nonsense
hardtop=`echo $hardtop | sed 's|^/tmp_mnt.*\(/local/.*\)$|\1|' | sed 's|^/tmp_mnt/|/|'`
diff --git a/configure.ac b/configure.ac
index 042b417..ab82bb0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,6 +26,8 @@ AC_INIT([The Glorious Glasgow Haskell Compilation System], [8.1], [glasgow-haske
# checkout), then we ship a file 'VERSION' containing the full version
# when the source distribution was created.

+FP_FIND_ROOT
+
if test ! -f mk/config.h.in; then
echo "mk/config.h.in doesn't exist: perhaps you haven't run 'perl boot'?"
exit 1
@@ -258,10 +260,6 @@ AC_ARG_WITH(hc,
)
AC_SUBST(WithHc)

-# This uses GHC, so put it after the "GHC is required" check above:
-FP_INTREE_GHC_PWD
-FP_FIND_ROOT
-
fail() {
echo >&2
echo "$1" >&2
diff --git a/distrib/configure.ac.in b/distrib/configure.ac.in
index 0f68a52..4d57cd8 100644
--- a/distrib/configure.ac.in
+++ b/distrib/configure.ac.in
@@ -6,7 +6,6 @@ dnl

AC_INIT([The Glorious Glasgow Haskell Compilation System], [@ProjectVersion@], [glasgow-haskell-bugs@haskell.org], [ghc])

-FP_BINDIST_GHC_PWD
FP_FIND_ROOT

dnl--------------------------------------------------------------------
diff --git a/ghc.mk b/ghc.mk
index ba708a1..3ccc496 100644
--- a/ghc.mk
+++ b/ghc.mk
@@ -516,7 +516,6 @@ $(foreach pkg,$(PACKAGES_STAGE1),$(eval $(call fixed_pkg_dep,$(pkg),dist-install
# 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)
@@ -660,7 +659,6 @@ BUILD_DIRS += utils/testremove
BUILD_DIRS += utils/ghctags
BUILD_DIRS += utils/check-api-annotations
BUILD_DIRS += utils/dll-split
-BUILD_DIRS += utils/ghc-pwd
BUILD_DIRS += utils/ghc-cabal
BUILD_DIRS += utils/hpc
BUILD_DIRS += utils/runghc
@@ -1020,7 +1018,6 @@ $(eval $(call bindist-list,.,\
mk/config.mk.in \
$(INPLACE_BIN)/mkdirhier \
utils/ghc-cabal/dist-install/build/tmp/ghc-cabal \
- utils/ghc-pwd/dist-install/build/tmp/ghc-pwd \
$(BINDIST_WRAPPERS) \
$(BINDIST_PERL_SOURCES) \
$(BINDIST_LIBS) \
@@ -1366,9 +1363,6 @@ distclean : clean
# Internal files generated by ./configure for itself.
$(call removeFiles,config.cache config.status config.log)

-# ./configure build ghc-pwd in utils/ghc-pwd/dist-boot, so clean it up.
- $(call removeTrees,utils/ghc-pwd/dist-boot)
-
# The root Makefile makes .old versions of some files that configure
# generates, so we clean those too.
$(call removeFiles,mk/config.mk.old)
diff --git a/utils/ghc-pwd/Main.hs b/utils/ghc-pwd/Main.hs
deleted file mode 100644
index 91a5606..0000000
--- a/utils/ghc-pwd/Main.hs
+++ /dev/null
@@ -1,22 +0,0 @@
-
-module Main where
-
-import System.Directory
-import System.Environment
-import System.Exit
-import System.IO
-
-main :: IO ()
-main = do
- args <- getArgs
- case args of
- [] -> do d <- getCurrentDirectory
- putStr $ map forwardifySlashes d
- _ -> do hPutStrLn stderr ("Bad args: " ++ show args)
- hPutStrLn stderr "Usage: ghc-pwd"
- exitFailure
-
-forwardifySlashes :: Char -> Char
-forwardifySlashes '\\' = '/'
-forwardifySlashes c = c
-
diff --git a/utils/ghc-pwd/Setup.hs b/utils/ghc-pwd/Setup.hs
deleted file mode 100644
index 9a994af..0000000
--- a/utils/ghc-pwd/Setup.hs
+++ /dev/null
@@ -1,2 +0,0 @@
-import Distribution.Simple
-main = defaultMain
diff --git a/utils/ghc-pwd/ghc-pwd.cabal b/utils/ghc-pwd/ghc-pwd.cabal
deleted file mode 100644
index dcd9529..0000000
--- a/utils/ghc-pwd/ghc-pwd.cabal
+++ /dev/null
@@ -1,19 +0,0 @@
-Name: ghc-pwd
-Version: 0.1
-Copyright: XXX
-License: BSD3
--- XXX License-File: LICENSE
--- XXX Author:
--- XXX Maintainer:
-Synopsis: XXX
-Description:
- XXX
-build-type: Simple
-cabal-version: >=1.10
-
-Executable ghc-pwd
- Default-Language: Haskell2010
- Main-Is: Main.hs
- Build-Depends: base >= 3 && < 5,
- directory >= 1 && < 1.3
-
diff --git a/utils/ghc-pwd/ghc.mk b/utils/ghc-pwd/ghc.mk
deleted file mode 100644
index ac6bc76..0000000
--- a/utils/ghc-pwd/ghc.mk
+++ /dev/null
@@ -1,9 +0,0 @@
-
-utils/ghc-pwd_USES_CABAL = YES
-utils/ghc-pwd_PACKAGE = ghc-pwd
-utils/ghc-pwd_dist-install_INSTALL_INPLACE = YES
-utils/ghc-pwd_dist-install_WANT_BINDIST_WRAPPER = YES
-utils/ghc-pwd_dist-install_PROGNAME = ghc-pwd
-
-$(eval $(call build-prog,utils/ghc-pwd,dist-install,1))
-
66 changes: 42 additions & 24 deletions testing/ghc/APKBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ arch="x86_64 armhf"
builddir="$srcdir/$pkgname-$pkgver"
source="
http://downloads.haskell.org/~ghc/${pkgver}/ghc-${pkgver}-src.tar.xz
0001-Correct-issue-with-libffi-and-glibc.patch
0002-rm-ghc-pwd.patch
"

# Note ghc's license is basically bsd3. If you'd like to know more visit:
Expand All @@ -28,59 +30,75 @@ install=""
# ghc build dependencies
makedepends="
$depends
autoconf
linux-headers
musl-dev
ncurses-dev
gmp-dev
libffi-dev
zlib-dev
binutils-dev
binutils-gold
ghc-bootstrap
paxmark
"

_ghc_build_tmp="$builddir/tmp"

build() {
cd "$builddir"
cp mk/build.mk.sample mk/build.mk || return 1
# Note we diverge from "stock" ghc with -fPIC
# to ensure we can link against alpine libraries.
# TODO: get html/sphinx docs building
cat >> mk/build.mk <<-EOF
BuildFlavour = perf-llvm
SRC_HC_OPTS += -fllvm
SRC_HC_OPTS += -fPIC
SRC_CC_OPTS += -fPIC
SRC_CC_OPTS += -DPIC
GhcLibHcOpts += -fPIC
GhcRtsCcOpts += -fPIC
INTEGER_LIBRARY = integer-gmp
BeConservative = YES
GhcLibWays = v
GhcLibWays += dyn
GhcLibWays += p
BUILD_SPHINX_HTML = NO
BUILD_SPHINX_PS = NO
BUILD_SPHINX_PDF = NO
HADDOCK_DOCS = NO
V = 0
GhcStage3HcOpts += -O3
SRC_HC_OPTS += -fPIC
SRC_CC_OPTS += -fno-stack-protector
SRC_CC_OPTS += -fno-PIE
SRC_CC_OPTS += -fPIC
SRC_CC_OPTS += -nopie
EOF
./configure --prefix=/usr \
if [ "$CARCH" = "x86_64" ]; then
cat >> mk/build.mk <<-EOF
SplitObjs = YES
EOF
fi

# Due to patches to the configure script
autoreconf || return 1

./configure \
CONF_CC_OPTS_STAGE2=-fno-PIE \
CONF_GCC_LINKER_OPTS_STAGE2=-nopie \
CONF_LD_LINKER_OPTS_STAGE2=-nopie \
--prefix=/usr \
--with-ld=ld.gold || return 1
make || return 1
}

doc() {
default_doc
install -Dm644 "$builddir/LICENSE" "$subpkgdir/usr/share/licenses/$subpkgname/LICENSE" || return 1
}

# Note, -nopie due to this bug, and must remain until fixed.
# https://ghc.haskell.org/trac/ghc/ticket/9007
package() {
cd "$builddir"
make -j1 DESTDIR="$pkgdir" install || return 1
rm -fr "$pkgdir/usr/share"
sed -i 's/.*C compiler link flags.*/ \(\"C compiler link flags\"\, \" -nopie\"\)\,/' "$(find $pkgdir -name settings -type f)"
local settings="$(find $pkgdir -name settings -type f)"
sed -i 's/.*C compiler link flags", "/& -nopie /' "$settings"
paxmark -m "$pkgdir/usr/lib/ghc-$pkgver/bin/ghc"
paxmark -m "$pkgdir/usr/lib/ghc-$pkgver/bin/ghc-iserv"
paxmark -m "$pkgdir/usr/lib/ghc-$pkgver/bin/ghc-iserv-dyn"
paxmark -m "$pkgdir/usr/lib/ghc-$pkgver/bin/ghc-iserv-prof"
}
md5sums="c185b8a1f3e67e43533ec590b751c2ff ghc-8.0.1-src.tar.xz"
sha256sums="90fb20cd8712e3c0fbeb2eac8dab6894404c21569746655b9b12ca9684c7d1d2 ghc-8.0.1-src.tar.xz"
sha512sums="5fa69fd0f7a639a10221a35e16c30b00e801644fcb8581903d3e215ecc0b3bd67960fc07a23d84d083b25e17024c69824fc21925cf82c26d8b36ee6c1fc9d28d ghc-8.0.1-src.tar.xz"
md5sums="c185b8a1f3e67e43533ec590b751c2ff ghc-8.0.1-src.tar.xz
13c68861fdbab7239c7b9d8d13592046 0001-Correct-issue-with-libffi-and-glibc.patch
309d46c58befe59d803f07fcaa8be84a 0002-rm-ghc-pwd.patch"
sha256sums="90fb20cd8712e3c0fbeb2eac8dab6894404c21569746655b9b12ca9684c7d1d2 ghc-8.0.1-src.tar.xz
fc35b8e669189a4e95069f901ce2b3132c36a292f1f23fb14c6123cd784afa15 0001-Correct-issue-with-libffi-and-glibc.patch
1a6bdbcca832de8e7835e4dc32c64e5480932cdbe41b704122b5f61123dae390 0002-rm-ghc-pwd.patch"
sha512sums="5fa69fd0f7a639a10221a35e16c30b00e801644fcb8581903d3e215ecc0b3bd67960fc07a23d84d083b25e17024c69824fc21925cf82c26d8b36ee6c1fc9d28d ghc-8.0.1-src.tar.xz
6f90b0de1e34c286e54ef14514ffabe17f9012fbc5448b4aacb3687aac065942e0a3a2c1c57b6338121140369a8870b4ce2a6b355c83c43344d4de8909a253a4 0001-Correct-issue-with-libffi-and-glibc.patch
0a95a2164562fa64794263c799fda1873b060b5f860b978e27d7cfcd6c0ebcde1362744c18143d646310ad6ddd8460e6cdc480a7a0e3d7031fd50224270f3bd8 0002-rm-ghc-pwd.patch"

0 comments on commit 6181b32

Please sign in to comment.