[arch-commits] Commit in ghc/trunk (MADV_FREE.patch PKGBUILD)
Felix Yan
felixonmars at archlinux.org
Sat Jul 15 16:18:08 UTC 2017
Date: Saturday, July 15, 2017 @ 16:18:08
Author: felixonmars
Revision: 245243
upgpkg: ghc 8.0.2-3
- rebuild with new gcc flags
- add a patch to fix running with kernel <4.5
Added:
ghc/trunk/MADV_FREE.patch
Modified:
ghc/trunk/PKGBUILD
-----------------+
MADV_FREE.patch | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
PKGBUILD | 11 ++++++---
2 files changed, 70 insertions(+), 4 deletions(-)
Added: MADV_FREE.patch
===================================================================
--- MADV_FREE.patch (rev 0)
+++ MADV_FREE.patch 2017-07-15 16:18:08 UTC (rev 245243)
@@ -0,0 +1,63 @@
+From 6576bf83cdf4eac05eb88a24aa934a736c91e3da Mon Sep 17 00:00:00 2001
+From: Ben Gamari <bgamari.foss at 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
+
Modified: PKGBUILD
===================================================================
--- PKGBUILD 2017-07-15 15:30:40 UTC (rev 245242)
+++ PKGBUILD 2017-07-15 16:18:08 UTC (rev 245243)
@@ -14,7 +14,7 @@
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/'
@@ -22,12 +22,13 @@
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"
@@ -36,6 +37,8 @@
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
@@ -135,7 +138,7 @@
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 \
More information about the arch-commits
mailing list