From 2e7a904612087edcbdfc4bc6b44b12353b5a9215 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20Ter=C3=A4s?= Date: Fri, 24 Feb 2017 12:00:33 +0000 Subject: testing/ghc: support cross-building --- scripts/bootstrap.sh | 2 +- testing/ghc/0000-alpine.patch | 11 ++++ testing/ghc/0000-bootstrap.patch | 16 +++++ testing/ghc/0007-build-hp2ps-twice.patch | 25 ++++++++ testing/ghc/0008-build-unlit-twice.patch | 58 +++++++++++++++++ testing/ghc/APKBUILD | 105 +++++++++++++++++++++---------- 6 files changed, 184 insertions(+), 33 deletions(-) create mode 100644 testing/ghc/0000-alpine.patch create mode 100644 testing/ghc/0000-bootstrap.patch create mode 100644 testing/ghc/0007-build-hp2ps-twice.patch create mode 100644 testing/ghc/0008-build-unlit-twice.patch diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index 93a1e1a36f..ac9622e9af 100755 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -103,7 +103,7 @@ for PKG in fortify-headers linux-headers musl libc-dev pkgconf zlib \ attr libcap patch sudo acl fakeroot tar \ pax-utils abuild openssh \ ncurses util-linux lvm2 popt xz cryptsetup kmod lddtree mkinitfs \ - community/go \ + community/go libffi testing/ghc \ $KERNEL_PKG ; do CHOST=$TARGET_ARCH BOOTSTRAP=bootimage APKBUILD=$(apkbuildname $PKG) abuild -r diff --git a/testing/ghc/0000-alpine.patch b/testing/ghc/0000-alpine.patch new file mode 100644 index 0000000000..0487096862 --- /dev/null +++ b/testing/ghc/0000-alpine.patch @@ -0,0 +1,11 @@ +--- ghc-8.0.2/aclocal.m4.orig 2017-02-17 12:00:45.179765870 +0000 ++++ ghc-8.0.2/aclocal.m4 2017-02-17 12:00:56.033299769 +0000 +@@ -227,7 +227,7 @@ + + checkVendor() { + case [$]1 in +- dec|unknown|hp|apple|next|sun|sgi|ibm|montavista|portbld) ++ dec|unknown|hp|apple|next|sun|sgi|ibm|montavista|portbld|alpine) + ;; + *) + echo "Unknown vendor [$]1" diff --git a/testing/ghc/0000-bootstrap.patch b/testing/ghc/0000-bootstrap.patch new file mode 100644 index 0000000000..95a3f5de4f --- /dev/null +++ b/testing/ghc/0000-bootstrap.patch @@ -0,0 +1,16 @@ +diff --git a/ghc.mk b/ghc.mk +index 5e4ecc6..a07ff73 100644 +--- a/ghc.mk ++++ b/ghc.mk +@@ -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/testing/ghc/0007-build-hp2ps-twice.patch b/testing/ghc/0007-build-hp2ps-twice.patch new file mode 100644 index 0000000000..47e8a8f266 --- /dev/null +++ b/testing/ghc/0007-build-hp2ps-twice.patch @@ -0,0 +1,25 @@ +--- a/utils/hp2ps/ghc.mk 2017-02-25 22:37:12.000000000 -0600 ++++ b/utils/hp2ps/ghc.mk 2017-02-25 23:21:33.000000000 -0600 +@@ -17,10 +17,21 @@ + Utilities.c + utils/hp2ps_dist_EXTRA_LIBRARIES = m + utils/hp2ps_dist_PROGNAME = $(CrossCompilePrefix)hp2ps +-utils/hp2ps_dist_INSTALL = YES ++utils/hp2ps_dist_INSTALL = NO + utils/hp2ps_dist_INSTALL_INPLACE = YES + + utils/hp2ps_CC_OPTS += $(addprefix -I,$(GHC_INCLUDE_DIRS)) + + $(eval $(call build-prog,utils/hp2ps,dist,0)) + ++utils/hp2ps_dist-install_C_SRCS = AreaBelow.c Curves.c Error.c Main.c \ ++ Reorder.c TopTwenty.c AuxFile.c Deviation.c \ ++ HpFile.c Marks.c Scale.c TraceElement.c \ ++ Axes.c Dimensions.c Key.c PsFile.c Shade.c \ ++ Utilities.c ++utils/hp2ps_dist-install_PROGNAME = hp2ps ++utils/hp2ps_dist-install_TOPDIR = YES ++utils/hp2ps_dist-install_INSTALL = YES ++utils/hp2ps_dist-install_INSTALL_INPLACE = NO ++ ++$(eval $(call build-prog,utils/hp2ps,dist-install,1)) diff --git a/testing/ghc/0008-build-unlit-twice.patch b/testing/ghc/0008-build-unlit-twice.patch new file mode 100644 index 0000000000..91380a5c26 --- /dev/null +++ b/testing/ghc/0008-build-unlit-twice.patch @@ -0,0 +1,58 @@ +From eba93774c3ce2f151e7c72f6d068b753f24dbcfa Mon Sep 17 00:00:00 2001 +From: Thomas Miedema +Date: Wed, 15 Jun 2016 14:56:46 +0200 +Subject: [PATCH] Build system: build unlit twice + +See Note [Why build certain utils twice?] in utils/ghc-pkg/ghc.mk +--- + utils/ghc-pkg/ghc.mk | 7 ++++++- + utils/unlit/ghc.mk | 10 +++++++++- + 2 files changed, 15 insertions(+), 2 deletions(-) + +diff --git a/utils/ghc-pkg/ghc.mk b/utils/ghc-pkg/ghc.mk +index f7d97de..410de72 100644 +--- a/utils/ghc-pkg/ghc.mk ++++ b/utils/ghc-pkg/ghc.mk +@@ -27,7 +27,7 @@ utils/ghc-pkg_PACKAGE = ghc-pkg + # Note [Why build certain utils twice?] + # + # We build certain utils twice: once with stage0, and once with stage1. +-# Examples are ghc-pkg and hsc2hs. ++# Examples are ghc-pkg, hsc2hs and unlit. + # + # These tools are needed during the bootstrapping process, so we have to use + # stage0 to build them at first (stage1 doesn't exist yet). (side note: they're +@@ -38,6 +38,11 @@ utils/ghc-pkg_PACKAGE = ghc-pkg + # dynamically linked. But the stage0 copies are either statically linked, or + # linked against libraries on the build machine. + # ++# Another reason why we can't install the stage0 copies is that they are ++# built to run on the build(=host) platform, but when installing a ++# "cross-compiled stage2 compiler" we need copies that run on the target ++# platform. ++# + # Therefore we build fresh copies, using the stage1 compiler, and install them + # when you run 'make install'. They are not used for any other purpose. + +diff --git a/utils/unlit/ghc.mk b/utils/unlit/ghc.mk +index e947989..6805c4e 100644 +--- a/utils/unlit/ghc.mk ++++ b/utils/unlit/ghc.mk +@@ -13,8 +13,16 @@ + utils/unlit_dist_C_SRCS = unlit.c + utils/unlit_dist_PROGNAME = unlit + utils/unlit_dist_TOPDIR = YES +-utils/unlit_dist_INSTALL = YES ++utils/unlit_dist_INSTALL = NO + utils/unlit_dist_INSTALL_INPLACE = YES + + $(eval $(call build-prog,utils/unlit,dist,0)) + ++utils/unlit_dist-install_C_SRCS = unlit.c ++utils/unlit_dist-install_PROGNAME = unlit ++utils/unlit_dist-install_TOPDIR = YES ++utils/unlit_dist-install_INSTALL = YES ++utils/unlit_dist-install_INSTALL_INPLACE = NO ++ ++# See Note [Why build certain utils twice?]. ++$(eval $(call build-prog,utils/unlit,dist-install,1)) diff --git a/testing/ghc/APKBUILD b/testing/ghc/APKBUILD index d1d0bb873e..e3fbfcce96 100644 --- a/testing/ghc/APKBUILD +++ b/testing/ghc/APKBUILD @@ -2,19 +2,23 @@ # Maintainer: Mitch Tishmack pkgname=ghc pkgver=8.0.2 -pkgrel=1 +pkgrel=2 pkgdesc="The Glasgow Haskell Compiler" url="http://haskell.org" subpackages="$pkgname-doc $pkgname-dev" -arch="x86_64" +arch="x86_64 armhf" builddir="$srcdir/$pkgname-$pkgver" source="http://downloads.haskell.org/~ghc/${pkgver}/ghc-${pkgver}-src.tar.xz + 0000-alpine.patch + 0000-bootstrap.patch 0001-rm-ghc-pwd.patch 0002-Correct-issue-with-libffi-and-glibc.patch 0003-do-not-use-SHELL.patch 0004-reproducible-tmp-names.patch 0005-buildpath-abi-stability.patch 0006-fix-madvise.patch + 0007-build-hp2ps-twice.patch + 0008-build-unlit-twice.patch " # Note ghc's license is basically bsd3. If you'd like to know more visit: @@ -61,39 +65,52 @@ provides="ghc-bootstrap=$pkgver-r$pkgrel install="$pkgname.post-install" # ghc build dependencies -makedepends=" - $depends - autoconf - cpio - linux-headers - musl-dev - ncurses-dev - libffi-dev - zlib-dev - binutils-dev - binutils-gold - paxmark - ghc-bootstrap - " +makedepends_build="autoconf cpio binutils-gold paxmark ghc-bootstrap binutils-gold libffi-dev ncurses-dev" +makedepends_host="linux-headers musl-dev zlib-dev gmp-dev binutils-dev libffi-dev ncurses-dev" +makedepends="$makedepends_build $makedepends_host" -build() { - cd "$builddir" +prepare() { + default_prepare || return 1 cp mk/build.mk.sample mk/build.mk || return 1 cat >> mk/build.mk <<-EOF - BuildFlavour = perf-llvm - INTEGER_LIBRARY = integer-gmp - BeConservative = YES - V = 0 - GhcStage3HcOpts += -O3 - SplitSections = YES + BuildFlavour = perf-llvm + INTEGER_LIBRARY = integer-gmp + BeConservative = YES + V = 0 + GhcStage3HcOpts += -O3 + SplitSections = YES EOF + if [ "$CBUILD" != "$CTARGET" ]; then + # cross-build + cat >> mk/build.mk <<-EOF + HADDOCK_DOCS = NO + BUILD_SPHINX_HTML = NO + BUILD_SPHINX_PS = NO + BUILD_SPHINX_PDF = NO + EOF + fi + # Due to patches to the configure script autoreconf || return 1 +} +build() { + cd "$builddir" + local _ffi_inc=$(pkg-config libffi --cflags-only-I); _ffi_inc="${_ffi_inc%% }" + local _ffi_lib=$(pkg-config libffi --libs-only-L); _ffi_lib="${_ffi_lib%% }" ./configure \ + --target=$CTARGET \ --prefix=/usr \ - --with-ld=ld.gold || return 1 + --with-system-libffi \ + ${_ffi_inc:+--with-ffi-includes="${_ffi_inc#-I}"} \ + ${_ffi_lib:+--with-ffi-libraries="${_ffi_lib#-L}"} \ + --with-ar=${CROSS_COMPILE}ar \ + --with-nm=${CROSS_COMPILE}nm \ + --with-ranlib=${CROSS_COMPILE}ranlib \ + --with-objdump=${CROSS_COMPILE}objdump \ + --with-ld=${CROSS_COMPILE}ld.gold \ + || return 1 make || return 1 } @@ -105,13 +122,33 @@ doc() { package() { cd "$builddir" make -j1 DESTDIR="$pkgdir" install || return 1 + + local _ghclib="usr/lib/ghc-$pkgver" + + # Fixup install tree if needed + if [ -d "$pkgdir/usr/lib/$CTARGET-ghc-$pkgver" ]; then + # different location + _ghclib="usr/lib/$CTARGET-ghc-$pkgver" + # rename binaries, and fix links + local fn; for fn in "$pkgdir"/usr/bin/"$CTARGET"-*; do + local _new="${fn//${CTARGET}-/}" + if [ -h "$fn" ]; then + local _target="$(readlink $fn)" + ln -sf "${_target//${CTARGET}-/}" "$_new" || return 1 + rm "$fn" || return 1 + else + mv "$fn" "$_new" || return 1 + fi + done + fi + # Can't do a full strip on archives. - find "$pkgdir" -type f \( -name "*.so" -o -name "*.a" \) -exec strip --strip-unneeded {} \; - find "$pkgdir/usr/lib/ghc-$pkgver/bin" -type f -exec strip {} \; - 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" + find "$pkgdir" -type f \( -name "*.so" -o -name "*.a" \) -exec ${CROSS_COMPILE}strip --strip-unneeded {} \; + find "$pkgdir/$_ghclib/bin" -type f -exec ${CROSS_COMPILE}strip {} \; + paxmark -m "$pkgdir/$_ghclib/bin/ghc" \ + "$pkgdir/$_ghclib/bin/ghc-iserv" \ + "$pkgdir/$_ghclib/bin/ghc-iserv-dyn" \ + "$pkgdir/$_ghclib/bin/ghc-iserv-prof" } dev() { @@ -125,9 +162,13 @@ dev() { } sha512sums="58ea3853cd93b556ecdc4abd0be079b2621171b8491f59004ea4e036a4cba4470aaafe6591b942e0a50a64bdc47540e01fe6900212a1ef7087850112d9bfc5ef ghc-8.0.2-src.tar.xz +23a52467fe83322e7b1d5f3e17a9defd08969666acb5a40e40ad93aa4f3feec028389448d4620edbe3ee8b246b3b6e338b267dce09cb14bdd0949b98e75d7562 0000-alpine.patch +82cecce9e42c12cc3c8d484331b76ac5c6d2529887cd73181d4798f95057883be47489919379e6ebf7daba95b7c25b5d9d689b30ed8d01b13dda20a3b921ce3d 0000-bootstrap.patch 128eece1b103f286b915a1563a628b638f03509d18cdb2e6510957d26eb56a4ae66e33c946c0e6c2aac2f947b9646dc88c1f390c69ea21f9dc64e0bef4de4e97 0001-rm-ghc-pwd.patch 6f90b0de1e34c286e54ef14514ffabe17f9012fbc5448b4aacb3687aac065942e0a3a2c1c57b6338121140369a8870b4ce2a6b355c83c43344d4de8909a253a4 0002-Correct-issue-with-libffi-and-glibc.patch 59194e6994c8344c579ec16c3adf3e0cdc7c356b524b12f8b10ec940191463d686782e525537c94ffa8e1bf9efcc36a2b3da3004183586ab0e354ab0a7036e0a 0003-do-not-use-SHELL.patch b5a5e73a2f01c0cabc96a49776d0d0f3d1d7a10759bb0b2982e7c7f6dc525d0559c0183ee779feb77ec6f2cec3bac17c1a5ba4c3bc0c6f780dfc1ed3dcf6c80e 0004-reproducible-tmp-names.patch e1c2cef06d307eda4b35521204e95eb54ace5dbcd22de659e95356f884b4424d6304365e4ab45c5116192cba4c095e2e91114bc7cb73d7c7173a7035287d0854 0005-buildpath-abi-stability.patch -478f9c9990ee01b70e88daf97138f853816d862731a02e9286ad787845dcb40c1443a30520598d805d0ff7cea8c3d604ed5d9033dbe8e572e8a85911ee739ff7 0006-fix-madvise.patch" +478f9c9990ee01b70e88daf97138f853816d862731a02e9286ad787845dcb40c1443a30520598d805d0ff7cea8c3d604ed5d9033dbe8e572e8a85911ee739ff7 0006-fix-madvise.patch +a1032b800515908eae1602454c03bd80c92e39faa4004b52dba698d84166abea1bb4ce4afc2b69aad4a25a4e9acb2d12704453e512ab2b2ceae02c6df180bd76 0007-build-hp2ps-twice.patch +0a53264a2066869379cbcb3a6175b93d4461d9a9fe6d2594bf0c9438daa176fbccf033832fa61bd482a23335c4528d8087301e3bdc08d08160acb789befbe005 0008-build-unlit-twice.patch" -- cgit v1.2.3