pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/lang/ghc92 lang/ghc92: Work around an issue where GHCi...
details: https://anonhg.NetBSD.org/pkgsrc/rev/99323466d5ea
branches: trunk
changeset: 374246:99323466d5ea
user: pho <pho%pkgsrc.org@localhost>
date: Thu Feb 17 07:16:10 2022 +0000
description:
lang/ghc92: Work around an issue where GHCi sometimes crashes on NetBSD
diffstat:
lang/ghc92/Makefile | 14 +-------
lang/ghc92/distinfo | 3 +-
lang/ghc92/patches/patch-rts_Linker.c | 58 +++++++++++++++++++++++++++++++++++
3 files changed, 62 insertions(+), 13 deletions(-)
diffs (112 lines):
diff -r 1f9c69dc02d8 -r 99323466d5ea lang/ghc92/Makefile
--- a/lang/ghc92/Makefile Thu Feb 17 00:28:29 2022 +0000
+++ b/lang/ghc92/Makefile Thu Feb 17 07:16:10 2022 +0000
@@ -1,10 +1,10 @@
-# $NetBSD: Makefile,v 1.2 2022/02/10 12:21:11 pho Exp $
+# $NetBSD: Makefile,v 1.3 2022/02/17 07:16:10 pho Exp $
# -----------------------------------------------------------------------------
# Package metadata
#
DISTNAME= ghc-9.2.1-src
PKGNAME= ${DISTNAME:S/-src$//}
-PKGREVISION= 1
+PKGREVISION= 2
CATEGORIES= lang
MASTER_SITES= https://downloads.haskell.org/~ghc/${PKGVERSION_NOREV}/
EXTRACT_SUFX= .tar.xz
@@ -66,16 +66,6 @@
--with-ffi-libraries=${BUILDLINK_PREFIX.libffi}/${BUILDLINK_LIBDIRS.libffi:Q}
.include "../../mk/bsd.prefs.mk"
-.if ${OPSYS} == "NetBSD"
-# The GHC rts, by default, creates executable objects on the heap by first
-# mmap(2)'ing an anonymous memory with PROT_READ|PROT_WRITE and then calling
-# mprotect(2) with PROT_READ|PROT_EXEC after filling its content. However,
-# NetBSD PaX mprotect doesn't allow this practice. That is, turning pages that
-# have been initially mapped as non-executable into something executable is a
-# no-no. We must therefore take a different path although it might be a bit slower.
-CONFIGURE_ARGS.common+= --enable-libffi-adjustors
-# See rts/adjustor/NativeAmd64.c and rts/adjustor/LibffiAdjustor.c
-.endif
# We must pass non-wrapper tools to ./configure because they will be
# embedded in the compiler (actually ${WRKSRC}/settings).
diff -r 1f9c69dc02d8 -r 99323466d5ea lang/ghc92/distinfo
--- a/lang/ghc92/distinfo Thu Feb 17 00:28:29 2022 +0000
+++ b/lang/ghc92/distinfo Thu Feb 17 07:16:10 2022 +0000
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.2 2022/02/08 07:45:02 pho Exp $
+$NetBSD: distinfo,v 1.3 2022/02/17 07:16:10 pho Exp $
BLAKE2s (ghc-8.10.4-boot-x86_64-unknown-netbsd.tar.xz) = 03efbb455a52d0dbc246b1c8b30f82121f5354a1ca0eb1b08b6225b90286a18f
SHA512 (ghc-8.10.4-boot-x86_64-unknown-netbsd.tar.xz) = 730347bb5eaac4efac8ec487fafd2da6fe2932db45f59e324c83698eb0b0e8a6a4b4fd513de17fb9c152ccee328660cfe1638cad631ce5e35b2dbfddda0d8850
@@ -46,6 +46,7 @@
SHA1 (patch-m4_find__llvm__prog.m4) = cc56b21739aff5faec378a1c47f514613c18db9e
SHA1 (patch-m4_fptools__set__c__ld__flags.m4) = 2d37b779d662e66521d2b5fda994174c9dfcbc29
SHA1 (patch-mk_config.mk.in) = ae2134a50e571090d504549b2b3fed8bb953fceb
+SHA1 (patch-rts_Linker.c) = aa04adb7d3275f4cf4e6b516a489beaed8642f21
SHA1 (patch-rts_ProfHeap.c) = fafbb740ee87949da12749834478769548322993
SHA1 (patch-rts_ghc.mk) = 6e3daf71fb7e656131aa2aeeb0346c651520216a
SHA1 (patch-rts_posix_GetTime.c) = 036e09510c893ab8677a2b4add0193e7f811bb82
diff -r 1f9c69dc02d8 -r 99323466d5ea lang/ghc92/patches/patch-rts_Linker.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lang/ghc92/patches/patch-rts_Linker.c Thu Feb 17 07:16:10 2022 +0000
@@ -0,0 +1,58 @@
+$NetBSD: patch-rts_Linker.c,v 1.1 2022/02/17 07:16:10 pho Exp $
+
+NetBSD-specific way of switching pages from rw- to r-x. Should not be
+upstreamed until we figure out why the hunk #0 is necessary.
+
+Even when the RTS linker is not used, libraries/ghci/GHCi/InfoTable.hsc
+(fillExecBuffer) calls rts/ExecPage.c (allocateExecPage) to store some
+executable code, which in turn calls mmapForLinker() and fails.
+
+Minimal test case:
+https://gist.github.com/depressed-pho/a629247b48b3e6178e35a14c62e9d44f
+
+This was previously not an issue, until
+https://gitlab.haskell.org/ghc/ghc/-/issues/20051 happened and lead to
+https://gitlab.haskell.org/ghc/ghc/-/merge_requests/6155
+
+--- rts/Linker.c.orig 2021-10-28 20:41:34.000000000 +0000
++++ rts/Linker.c
+@@ -1115,9 +1115,17 @@ mmapForLinker (size_t bytes, uint32_t pr
+ mmap_again:
+ #endif
+
++#if defined(DYNAMIC) && defined(netbsd_HOST_OS)
++ /* Dynamic RTS only uses this function for allocating some anonymous pages
++ * for code generated on-the-fly, which doesn't need to be in a certain
++ * range. On NetBSD, when ASLR is enabled, specifying an address hint
++ * sometimes fail with ENOMEM even when MAP_FIXED is not used.
++ */
++#else
+ if (mmap_32bit_base != 0) {
+ map_addr = mmap_32bit_base;
+ }
++#endif
+
+ IF_DEBUG(linker,
+ debugBelch("mmapForLinker: \tprotection %#0x\n", prot));
+@@ -1218,7 +1226,20 @@ mmap_again:
+ void *
+ mmapAnonForLinker (size_t bytes)
+ {
+- return mmapForLinker (bytes, PROT_READ|PROT_WRITE, MAP_ANONYMOUS, -1, 0);
++ int prot;
++
++#if defined(netbsd_HOST_OS)
++ /* PROT_MPROTECT(PROT_EXEC) means that the pages are going to be marked as
++ * executable in the future. On NetBSD requesting additional permissions with
++ * mprotect(2) only succeeds when permissions were initially requested in this
++ * manner.
++ */
++ prot = PROT_READ|PROT_WRITE|PROT_MPROTECT(PROT_EXEC);
++#else
++ prot = PROT_READ|PROT_WRITE;
++#endif
++
++ return mmapForLinker (bytes, prot, MAP_ANONYMOUS, -1, 0);
+ }
+
+ void munmapForLinker (void *addr, size_t bytes, const char *caller)
Home |
Main Index |
Thread Index |
Old Index