# Contributor: Sören Tempel # Contributor: Mitch Tishmack # Maintainer: Sören Tempel pkgname=ghc # XXX: GHC is tightly coupled with community/cabal-stage0. # Only update to GHC versions supported by cabal bootstrapping setup. pkgver=9.4.5 pkgrel=2 # GHC version used to bootstrap the build. This is relevant for the # bootstrapping of the Hadrian build system used by GHC these days. _bootstrapver=9.4.5 # Normal non rc candidate _urlprefix="$pkgver" _pkgprefix="$pkgname-$pkgver" _llvmver=14 pkgdesc="The Glasgow Haskell Compiler" # Next 5 variables only needed for release candidate testing #pkgrcver=8.2.2 #pkgrc=rc3 #pkgdate=20171108 #urlprefix="$pkgrcver-$pkgrc" #pkgprefix="ghc-$pkgver.$pkgdate" url="https://haskell.org/ghc" arch="aarch64 x86_64" # Note ghc's license is basically BSD-3. If you'd like to know more visit: # * https://www.haskell.org/ghc/license # * https://ghc.haskell.org/trac/ghc/wiki/Licensing license="BSD-3-Clause" # Note that ghc is sensitive to the version of llvm used. # # Ref: https://ghc.haskell.org/trac/ghc/wiki/Status/GHC-8.0.1 # https://ghc.haskell.org/trac/ghc/wiki/ImprovedLLVMBackend # # Without libffi-dev in $depends linking of software via ghc(1) fails. depends="gmp-dev libffi-dev perl gcc>=6.2.1 llvm$_llvmver" # ghc is self-hosted, so we need ghc to build ghc. ghc-bootstrap is provided by # this aport (see below). makedepends_build="$pkgname-bootstrap~=$_bootstrapver autoconf automake binutils libffi-dev ncurses-dev xz coreutils grep py3-sphinx" makedepends_host="linux-headers musl-dev zlib-dev gmp-dev binutils-dev libffi-dev ncurses-dev" makedepends="$makedepends_build $makedepends_host" checkdepends="python3 diffutils bash" # XXX: ghc-bootstrap is a hack to allow this abuild to depend on itself. # Adding "ghc" to makedepends would not work, because abuild implicitly removes # $pkgname and $subpackages from the abuild's dependencies. provides="$pkgname-bootstrap=$pkgver-r$pkgrel" subpackages="$pkgname-doc $pkgname-dev" install="$pkgname.post-install" ldpath="/usr/lib/ghc-$pkgver" options="!strip ldpath-recursive" # we strip it manually in build() source="https://downloads.haskell.org/~ghc/$_urlprefix/$_pkgprefix-src.tar.xz https://downloads.haskell.org/~ghc/$_urlprefix/$_pkgprefix-testsuite.tar.xz $pkgname-$pkgver-hadrian-ghc-$_bootstrapver.tar.gz::https://dev.alpinelinux.org/archive/ghc-hadrian/ghc-$pkgver/ghc-$_bootstrapver-hadrian-bootstrap-source.tar.gz 0001-testsuite-unset-MAKEFLAGS-when-calling-python.patch 0001-testsuite-Make-tests-compatible-with-GNU-grep-3.8.patch 0005-buildpath-abi-stability.patch ghc-9.4.4-bootstrap.patch sphinx-6.1.3.patch llvm14.patch fix-T7060.patch fix-T21035.patch " # Adjust path for LLVM-14. export PATH="$PATH:/usr/lib/llvm14/bin" case "$CARCH" in aarch64) # 116 more failures options="$options !check" ;; esac _hadrian="hadrian/bootstrap/_build/bin/hadrian" _hadrian_args="-j${JOBS:-1}" if [ "$CBUILD" != "$CTARGET" ]; then _hadrian_args="$_hadrian_args --docs=none --flavour=quickest" else _hadrian_args="$_hadrian_args --docs=no-sphinx-pdfs --flavour=release" fi build() { # Build the hadrian build system. # # See: # * https://gitlab.haskell.org/ghc/ghc/-/tree/master/hadrian/bootstrap # * https://www.haskell.org/ghc/blog/20220805-make-to-hadrian.html cd hadrian/bootstrap/ ./bootstrap.py -w /usr/bin/ghc -s "$srcdir"/$pkgname-$pkgver-hadrian-ghc-$_bootstrapver.tar.gz # NOTE: ghc build system requires host == build, and it ends up # compiling the cross-compiler (stage1) and cross-compiling with # that the native compiler (stage2) cd "$builddir" ./configure \ --build=$CBUILD \ --host=$CBUILD \ --target=$CTARGET \ --prefix=/usr \ --with-system-libffi \ --disable-ld-override \ LD=${LD:-ld} # Switch llvm-targets from unknown-linux-gnueabihf->alpine-linux # so we can match the llvm vendor string alpine uses sed -i -e 's/unknown-linux-gnueabihf/alpine-linux/g' llvm-targets sed -i -e 's/unknown-linux-gnueabi/alpine-linux/g' llvm-targets sed -i -e 's/unknown-linux-gnu/alpine-linux/g' llvm-targets "$_hadrian" $_hadrian_args } check() { # Broken tests are known upstream to be broken on musl. # See: https://gitlab.haskell.org/ghc/ghc/-/commit/cdd45a61ecfc34d3610dff4b654f1bca5dcb6829 "$_hadrian" $_hadrian_args test --skip-perf --test-speed=fast \ --broken-test=encoding004 --broken-test=T10458 \ --broken-test=linker_unload_native } package() { local ghclib="$pkgdir/usr/lib/ghc-$pkgver/lib" local newpath path target # Hadrian's install command doesn't support DESTDIR. # Hence, we need to install via the bindist. "$_hadrian" $_hadrian_args binary-dist-dir cd _build/bindist/ghc-* # Need to re-run configure. # See: https://gitlab.haskell.org/ghc/ghc/-/issues/22058 ./configure --prefix=/usr \ --with-system-libffi \ --disable-ld-override \ LD=${LD:-ld} make DESTDIR="$pkgdir" RECACHE_PACKAGE_DB=NO install install -Dm644 "$builddir/LICENSE" \ "$pkgdir/usr/share/licenses/$pkgname/LICENSE" cd "$pkgdir" # Fixup install tree if needed. if [ -d usr/lib/$CTARGET-ghc-$pkgver ]; then # different location ghclib="usr/lib/$CTARGET-ghc-$pkgver" # Rename binaries and fix links. local path; for path in usr/bin/"$CTARGET"-*; do newpath="${path//$CTARGET-/}" if [ -h "$path" ]; then target="$(readlink $path)" ln -sf "${target//$CTARGET-/}" "$newpath" rm "$path" else mv "$path" "$newpath" fi done fi # Remove triplet prefix from settings -- the intention is # that the native compiler will use native gcc/ld on the target. sed -i "s|$CTARGET-||g" "$ghclib"/settings # Can't do a full strip on archives. find . -type f \( -name "*.so" -o -name "*.a" \) \ -exec ${CROSS_COMPILE}strip --strip-unneeded {} \; find $ghclib/bin -type f -exec ${CROSS_COMPILE}strip {} \; } # Like debian, we split apart the profiled archives/etc... # This drastically reduces the install size of the ghc pkg. dev() { pkgdesc="$pkgdesc (development files)" depends="$pkgname=$pkgver-r$pkgrel" cd "$pkgdir" install -dm755 "$subpkgdir" amove $(find . \( -type f -o -type l \) \( -name "*.p_*" -o -name "lib*_p.a" \)) } sha512sums=" 6e469558433e9d1d83ae348fb242a178ee7008fcb5c9707f0bdf93f17c394dc05d993b9cd7f9cd65d20c32fadcd1276ed49c3a74ade98235735de5268c3c1315 ghc-9.4.5-src.tar.xz f4f2530347be8fffe6f3da98441f9f268552128f90967ee4d6fe48e71289d95538db4606b0d25ea0a171ee966c1219e45272f025c7eb142cdb62990b8b897d60 ghc-9.4.5-testsuite.tar.xz 76486960cc86a539005bd1e7f59c2572df358aa4357e704d7664df3f6db7d148d9906f7b133f71e820556865c690f6eb8b74548cb52ac3dce1f6b0e209809891 ghc-9.4.5-hadrian-ghc-9.4.5.tar.gz ac2ad793b4d33ea890e236820af4cd10996b47d0f4249c825b31450145cb8195c2be62f2d7942cc3bf564f768dca187379196b251f4b37ed326ed2a0a5f59e8a 0001-testsuite-unset-MAKEFLAGS-when-calling-python.patch 524dec6a4fc2ce45f7a35f089f936fb3020aa8283612de6f0dad34146213df638d654c0943147c77126d54c24f632edc53a0400f1af15bfe0d9d3f20cc4ae869 0001-testsuite-Make-tests-compatible-with-GNU-grep-3.8.patch b9339a7220bab708eff6233db610f900183cd75b59c4fb479c557b1ef8dd7ccca258da2305218f18ba576c3561d048ce2c07deab3c78c15309e6bb1d1d8342d7 0005-buildpath-abi-stability.patch cb41baaf60f7813201187544c96c6a0b2b12c0634054eb62b752380a2cd0a9d26fccc26e757250e6c22f0eb9b61b515d3fef1e12c1a27877abcb8f25e8d7a783 ghc-9.4.4-bootstrap.patch 7a79a5e9591b1ddd78fa349526a85cf9fee64db80639dcf1f3d6edef422fd4454222aedf5581e21489a20d748656265a40e7645004e4d5220280f6214c568e64 sphinx-6.1.3.patch 2dbfec447171dbe86b34fe7bd99c61376c25f5713b19876d4b59eeedcbb7158eee604e278a6430cb9fd5eb61985ea526c376f6f9fb1837759bed4939c18192fa llvm14.patch 28433f5e86b571ef591ee61153c804eb4a540fda120b7a7aa14f39af46eda6917361d0cd41127356e20f24cf5b9d493ae404023eae31b863c2485fb8cffa0c6a fix-T7060.patch be5a8639b151b7828ad50b0f63775d34411d971aae73b0fe5c0226e4c70d1ee8353545b1d04c8de7825730b6d73a2e75f855757348b5ffa2d620d20d7e57f8c6 fix-T21035.patch "