community/ghc to 8.0.2-3

This commit is contained in:
Kevin Mihelich 2017-07-15 16:50:57 +00:00
parent aaa5b3c762
commit d5dfcda7c4
2 changed files with 70 additions and 4 deletions

View file

@ -0,0 +1,63 @@
From 6576bf83cdf4eac05eb88a24aa934a736c91e3da Mon Sep 17 00:00:00 2001
From: Ben Gamari <bgamari.foss@gmail.com>
Date: Thu, 1 Dec 2016 12:55:23 -0500
Subject: [PATCH] rts: Ensure we always give MADV_DONTNEED a chance in
osDecommitMemory
As described in #12865, newer Linux kernels support both MADV_FREE and
MADV_DONTNEED. Previously a runtime would fail to try MADV_DONTNEED if
MADV_FREE failed (e.g. since the kernel which the image is running on
doesn't support the latter). Now we try MADV_DONTNEED if MADV_FREE
failed to ensure that binaries compiled on a kernel supporting MADV_FREE
don't fail on decommit.
Test Plan: Validate
Reviewers: austin, erikd, simonmar
Reviewed By: simonmar
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2780
GHC Trac Issues: #12865
---
rts/posix/OSMem.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/rts/posix/OSMem.c b/rts/posix/OSMem.c
index 5291745..beffeda 100644
--- a/rts/posix/OSMem.c
+++ b/rts/posix/OSMem.c
@@ -541,11 +541,24 @@ void osDecommitMemory(void *at, W_ size)
#ifdef MADV_FREE
// Try MADV_FREE first, FreeBSD has both and MADV_DONTNEED
- // just swaps memory out
+ // just swaps memory out. Linux >= 4.5 has both DONTNEED and FREE; either
+ // will work as they both allow the system to free anonymous pages.
+ // It is important that we try both methods as the kernel which we were
+ // built on may differ from the kernel we are now running on.
r = madvise(at, size, MADV_FREE);
-#else
- r = madvise(at, size, MADV_DONTNEED);
+ if(r < 0) {
+ if (errno == EINVAL) {
+ // Perhaps the system doesn't support MADV_FREE; fall-through and
+ // try MADV_DONTNEED.
+ } else {
+ sysErrorBelch("unable to decommit memory");
+ }
+ } else {
+ return;
+ }
#endif
+
+ r = madvise(at, size, MADV_DONTNEED);
if(r < 0)
sysErrorBelch("unable to decommit memory");
}
--
1.9.1

View file

@ -19,7 +19,7 @@ buildarch=4
pkgbase=ghc
pkgname=(ghc ghc-static)
pkgver=8.0.2
pkgrel=2
pkgrel=3
pkgdesc='The Glasgow Haskell Compiler'
arch=('i686' 'x86_64')
url='http://www.haskell.org/ghc/'
@ -27,12 +27,13 @@ license=('custom')
makedepends=('ghc-static' 'perl' 'libxslt' 'docbook-xsl' 'python-sphinx' 'haskell-hscolour'
'texlive-bin' 'texlive-latexextra' 'ttf-dejavu')
source=("https://downloads.haskell.org/~ghc/$pkgver/$pkgname-${pkgver}-src.tar.xz"
ghc-rebuild-doc-index.hook ghc-register.hook ghc-unregister.hook)
ghc-rebuild-doc-index.hook ghc-register.hook ghc-unregister.hook MADV_FREE.patch)
noextract=("$pkgname-${pkgver}-src.tar.xz")
md5sums=('d0afb5ec441b14527a53d2445cc26ec3'
'cc9aa11fddde15d8e5e15e99748874a1'
'3b1949e77038b0276ebd5590ab89e1af'
'587efb0cb73a6b336cd9333fc5697de4')
'587efb0cb73a6b336cd9333fc5697de4'
'3bf341c04e2e501a5ace07127de23e8f')
prepare() {
# Need to extract this tarball with a UTF-8 locale instead of a chroot's "C"
@ -41,6 +42,8 @@ prepare() {
LANG=en_US.UTF-8 bsdtar xf $pkgname-${pkgver}-src.tar.xz
cd ghc-$pkgver
# FS#54823
patch -p1 -i ../MADV_FREE.patch
cp mk/build.mk{.sample,}
sed -i '1iBuildFlavour = perf' mk/build.mk
@ -140,7 +143,7 @@ package_ghc() {
install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
# Remove static libs and the compiler itself, but keep ghc-pkg for library (un)register
# Remove static libs
find "$pkgdir"/usr/lib \( -name "*.a" -o -name "*.p_hi" \) -delete
install -Dm644 utils/completion/ghc.bash \