summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpho <pho@pkgsrc.org>2020-01-09 12:32:24 +0000
committerpho <pho@pkgsrc.org>2020-01-09 12:32:24 +0000
commitfe10fee2a4883dead2884154ae064d080f2f37b7 (patch)
treea9e9a4e5b246e0580c21c9313a31205bbad3ab09
parentb8402145b7a91e0a8fbe4fe393dde141cf525707 (diff)
downloadpkgsrc-fe10fee2a4883dead2884154ae064d080f2f37b7.tar.gz
Import GHC 8.8.1
GHC: The Glasgow Haskell Compiler. The Glasgow Haskell Compiler is a robust, fully-featured, optimising compiler for the functional programming language Haskell 98 (http://www.haskell.org). GHC compiles Haskell to either native code or C. It implements numerous experimental language extensions to Haskell, including concurrency, a foreign language interface, several type-system extensions, exceptions, and so on. GHC comes with a generational garbage collector, a space and time profiler, and a comprehensive set of libraries. This package provides the 8.8.x release series.
-rw-r--r--lang/ghc88/BOOTSTRAP.txt20
-rw-r--r--lang/ghc88/DEINSTALL9
-rw-r--r--lang/ghc88/DESCR12
-rw-r--r--lang/ghc88/INSTALL8
-rw-r--r--lang/ghc88/Makefile212
-rw-r--r--lang/ghc88/bootstrap.mk286
-rw-r--r--lang/ghc88/buildlink3.mk24
-rw-r--r--lang/ghc88/distinfo24
-rw-r--r--lang/ghc88/files/bootstrap.build.mk44
-rw-r--r--lang/ghc88/patches/patch-aclocal.m416
-rw-r--r--lang/ghc88/patches/patch-compiler_main_DynFlags.hs17
-rw-r--r--lang/ghc88/patches/patch-configure.ac15
-rw-r--r--lang/ghc88/patches/patch-ghc_ghc.mk22
-rw-r--r--lang/ghc88/patches/patch-libraries_base_GHC_Event_KQueue.hsc16
-rw-r--r--lang/ghc88/patches/patch-libraries_base_System_CPUTime_Posix_Times.hsc16
-rw-r--r--lang/ghc88/patches/patch-libraries_base_System_Environment.hs23
-rw-r--r--lang/ghc88/patches/patch-libraries_time_lib_Data_Time_Clock_Internal_CTimespec.hsc23
-rw-r--r--lang/ghc88/patches/patch-libraries_time_lib_Data_Time_Clock_Internal_CTimeval.hs33
-rw-r--r--lang/ghc88/patches/patch-libraries_unix_System_Posix_Env.hsc16
-rw-r--r--lang/ghc88/patches/patch-libraries_unix_System_Posix_Env_ByteString.hsc16
-rw-r--r--lang/ghc88/patches/patch-libraries_unix_System_Posix_Files_Common.hsc33
-rw-r--r--lang/ghc88/patches/patch-libraries_unix_System_Posix_Signals.hsc22
-rw-r--r--lang/ghc88/patches/patch-libraries_unix_include_execvpe.h17
23 files changed, 924 insertions, 0 deletions
diff --git a/lang/ghc88/BOOTSTRAP.txt b/lang/ghc88/BOOTSTRAP.txt
new file mode 100644
index 00000000000..586613025bf
--- /dev/null
+++ b/lang/ghc88/BOOTSTRAP.txt
@@ -0,0 +1,20 @@
+GHC requires itself to build, and unfortunately the only way to get a
+working GHC for a foreign target is to do a cross-compilation.
+
+In order to build a bootkit for a new platform, you need to manually
+set up a cross-building C compiler and binutils, libc, libterminfo,
+and libiconv for the target. Then you can follow instructions in
+https://gitlab.haskell.org/ghc/ghc/wikis/building/cross-compiling
+
+Once you get a working GHC for the target platform, install it
+somewhere in your PATH, run "cd lang/ghc88; make clean; make bootstrap"
+on the target platform and you'll have a bootkit for the target.
+
+--
+
+GHC in fact has never supported bootstrapping only with a C compiler.
+Prior to GHC 7, it had a thing called "HC source", which was a set of
+C source files compiled from Haskell source, but it wasn't actually
+cross-platform. It was because HC files were generated with many
+assumptions about the platform, such as the layout of libc structs,
+the size of off_t and time_t, byte-order, word size, etc.
diff --git a/lang/ghc88/DEINSTALL b/lang/ghc88/DEINSTALL
new file mode 100644
index 00000000000..dae09d89ea0
--- /dev/null
+++ b/lang/ghc88/DEINSTALL
@@ -0,0 +1,9 @@
+#!/bin/sh
+#
+GHC_VERSION="@GHC_VERSION@"
+
+case ${STAGE} in
+ DEINSTALL)
+ ${RM} -f ${PKG_PREFIX}/lib/${PKGBASE}-${GHC_VERSION}/package.conf.d/package.cache
+ ;;
+esac
diff --git a/lang/ghc88/DESCR b/lang/ghc88/DESCR
new file mode 100644
index 00000000000..b7ca417f94b
--- /dev/null
+++ b/lang/ghc88/DESCR
@@ -0,0 +1,12 @@
+GHC: The Glasgow Haskell Compiler.
+
+The Glasgow Haskell Compiler is a robust, fully-featured, optimising
+compiler for the functional programming language Haskell 98
+(http://www.haskell.org). GHC compiles Haskell to either native code
+or C. It implements numerous experimental language extensions to
+Haskell, including concurrency, a foreign language interface, several
+type-system extensions, exceptions, and so on. GHC comes with a
+generational garbage collector, a space and time profiler, and a
+comprehensive set of libraries.
+
+This package provides the 8.8.x release series.
diff --git a/lang/ghc88/INSTALL b/lang/ghc88/INSTALL
new file mode 100644
index 00000000000..a1c8ec4669b
--- /dev/null
+++ b/lang/ghc88/INSTALL
@@ -0,0 +1,8 @@
+#!/bin/sh
+#
+
+case ${STAGE} in
+ POST-INSTALL)
+ ${PKG_PREFIX}/bin/ghc-pkg recache
+ ;;
+esac
diff --git a/lang/ghc88/Makefile b/lang/ghc88/Makefile
new file mode 100644
index 00000000000..7679c7abe7f
--- /dev/null
+++ b/lang/ghc88/Makefile
@@ -0,0 +1,212 @@
+# $NetBSD: Makefile,v 1.1 2020/01/09 12:32:24 pho Exp $
+# -----------------------------------------------------------------------------
+# Package metadata
+#
+DISTNAME= ghc-8.8.1-src
+PKGNAME= ${DISTNAME:S/-src$//}
+CATEGORIES= lang
+MASTER_SITES= https://downloads.haskell.org/~ghc/${PKGVERSION_NOREV}/
+EXTRACT_SUFX= .tar.xz
+
+MAINTAINER= pho@cielonegro.org
+HOMEPAGE= https://www.haskell.org/ghc/
+COMMENT= Compiler for the functional language Haskell - 8.0 Release Series
+LICENSE= modified-bsd
+
+# TODO: We should be using the alternatives framework.
+CONFLICTS+= ghc-[0-9]*
+
+# GHC requires GHC to build itself. We have to prepare stripped-down
+# binaries sufficient to bootstrap compilers for each platforms. If
+# you want to build them yourself, follow instructions in
+# BOOTSTRAP.txt and ./bootstrap.mk
+#BROKEN_EXCEPT_ON_PLATFORM+= Darwin-*-powerpc # Not available yet
+#BROKEN_EXCEPT_ON_PLATFORM+= FreeBSD-*-i386 # Not available yet
+BROKEN_EXCEPT_ON_PLATFORM+= NetBSD-*-x86_64
+#BROKEN_EXCEPT_ON_PLATFORM+= SunOS-*-i386 # Not available yet
+#BROKEN_EXCEPT_ON_PLATFORM+= SunOS-*-x86_64 # Not available yet
+
+
+# -----------------------------------------------------------------------------
+# Distfiles
+#
+DISTFILES= ${DEFAULT_DISTFILES}
+WRKSRC= ${WRKDIR}/${PKGNAME_NOREV}
+
+# We don't want to extract all of the DISTFILEs.
+EXTRACT_ONLY= ${DEFAULT_DISTFILES}
+
+
+# -----------------------------------------------------------------------------
+# Tools
+#
+# The runtime dependency on perl is due to the evil splitter
+# (lib/${PKGNAME_NOREV}/ghc-split).
+USE_TOOLS+= autoconf gmake perl:run
+GNU_CONFIGURE= yes
+USE_GNU_CONFIGURE_HOST= no
+USE_LIBTOOL= yes
+
+CONFIGURE_ARGS.common= \
+ --with-curses-libraries=${BUILDLINK_PREFIX.curses}/${BUILDLINK_LIBDIRS.curses:Q} \
+ --with-gmp-includes=${BUILDLINK_PREFIX.gmp}/${BUILDLINK_INCDIRS.gmp:Q} \
+ --with-gmp-libraries=${BUILDLINK_PREFIX.gmp}/${BUILDLINK_LIBDIRS.gmp:Q} \
+ --with-iconv-includes=${BUILDLINK_PREFIX.iconv}/${BUILDLINK_INCDIRS.iconv:Q} \
+ --with-iconv-libraries=${BUILDLINK_PREFIX.iconv}/${BUILDLINK_LIBDIRS.iconv:Q} \
+ --with-system-libffi \
+ --with-ffi-includes=${BUILDLINK_PREFIX.libffi}/${BUILDLINK_INCDIRS.libffi:Q} \
+ --with-ffi-libraries=${BUILDLINK_PREFIX.libffi}/${BUILDLINK_LIBDIRS.libffi:Q}
+
+CONFIGURE_ARGS+= ${CONFIGURE_ARGS.common}
+
+# We must pass non-wrapper tools to ./configure because they will be
+# embedded in the compiler (actually ${WRKSRC}/settings).
+CONFIGURE_ENV+= \
+ ac_cv_prog_fp_prog_ar=${AR:Q} \
+ ac_cv_prog_LIBTOOL=libtool \
+ PerlCmd=${PERL5:Q} \
+ CC=${CC:Q} \
+ LD=${LD:Q}
+
+# LDFLAGS is currently not honored by "./configure". Since LDFLAGS
+# contains rpath flags it's very important to force GHC to honor
+# it. Otherwise neither GHC itself nor executables it produces will
+# have any rpaths so users will have to put "${PREFIX}/lib" into their
+# "/etc/ld-elf.so.conf". See
+# http://hackage.haskell.org/trac/ghc/ticket/2933
+.for stage in 0 1 2
+CONFIGURE_ENV+= \
+ CONF_GCC_LINKER_OPTS_STAGE${stage}=${LDFLAGS:M*:Q}
+# Note that CONF_LD_LINKER_OPTS_STAGE{0,1,2} are only used for
+# creating static GHCi libraries (HS*.o). Setting them to ${LDFLAGS}
+# does more harm than good because our ${LDFLAGS} contains -Wl,*
+# flags. It's true that ../../mk/wrapper/cmd-sink-ld transforms them
+# but those flags will also be baked into the compiler (see
+# ${WRKSRC}/compiler/ghc.mk) so they cause problems when used outside
+# the buildlink.
+.endfor
+
+# The runtime system of GHC (rts) tends to conflict with PaX MPROTECT
+# because it needs to generate various kinds of code at run time. The
+# RTS linker, whose job is to load *static* objects at run time,
+# doesn't play nice with ASLR either. This means most executables
+# produced by GHC need them to be disabled. Perhaps we should patch
+# rts/sm/Storage.c so that it uses ffi_closure_alloc(3) on every
+# platform, not just Linux, and also drop support for static library
+# loading and switch to dynamic libraries entirely.
+.for f in ghc ghc-iserv ghc-iserv-dyn ghc-iserv-prof ghc-pkg haddock hpc hsc2hs runghc
+NOT_PAX_MPROTECT_SAFE+= lib/${PKGNAME_NOREV}/bin/${f}
+NOT_PAX_ASLR_SAFE+= lib/${PKGNAME_NOREV}/bin/${f}
+.endfor
+
+
+# -----------------------------------------------------------------------------
+# Build hooks
+#
+
+# We patch configure.ac in some directories.
+post-patch:
+ @${PHASE_MSG} "Regenerating configuration scripts for ${PKGNAME}"
+ ${RUN} cd ${WRKSRC} && autoconf
+
+# Define the target "pre-configure" and non-standard "bootstrap".
+.include "../../lang/ghc88/bootstrap.mk"
+
+# Our pre-configure phase installs a bindist of bootstrapping compiler
+# directly into TOOLS_DIR so that ./configure can find it.
+
+# The version restriction on Sphinx in ${WRKSRC}/configure.ac is too
+# loose, and building docs/users_guide rarely succeeds. We don't know
+# which version is actually required for it.
+.include "../../mk/bsd.prefs.mk"
+BUILD_SPHINX_HTML?= no
+
+# Here we generate mk/build.mk dynamically.
+post-configure:
+ ${RUN} ${RM} -f ${WRKSRC}/mk/build.mk
+
+# If there is HsColour in the PATH, GHC's build system tries to use it
+# without even checking if it really works. That's not what we
+# appreciate.
+ ${RUN} ${ECHO} "HSCOLOUR_SRCS = NO" >> ${WRKSRC}/mk/build.mk
+
+.if ${BUILD_SPHINX_HTML} == "no"
+ ${RUN} ${ECHO} "BUILD_SPHINX_HTML = NO" >> ${WRKSRC}/mk/build.mk
+.endif
+
+# Don't even think of PDF.
+ ${RUN} ${ECHO} "BUILD_SPHINX_PDF = NO" >> ${WRKSRC}/mk/build.mk
+
+
+# -----------------------------------------------------------------------------
+# Installation/removal hooks
+#
+
+# Substitutions for INSTALL and DEINSTALL that handles package.cache.
+FILES_SUBST+= GHC_VERSION=${PKGVERSION_NOREV}
+
+# We don't want package.cache to be in the PLIST.
+post-install:
+ ${RM} -f ${DESTDIR}${PREFIX}/lib/${PKGNAME_NOREV}/package.conf.d/package.cache
+
+
+# -----------------------------------------------------------------------------
+# PLIST
+#
+# We can't use static PLIST because the package installs files with a
+# hashed name. And "PLIST_TYPE = dynamic" appears to be broken atm
+# [2019-12-27; pho].
+GENERATE_PLIST+= \
+ cd ${DESTDIR}${PREFIX} && \
+ ${FIND} * \( -type f -o -type l \) | ${SORT};
+
+
+# -----------------------------------------------------------------------------
+# Sanity checks
+#
+
+# There is an unused script which don't pass the portability test.
+CHECK_PORTABILITY_SKIP+= distrib/prep-bin-dist-mingw
+
+# Dynamically linked Haskell executables and libraries have rpaths to
+# dependent Haskell libraries, but the problem is that they are
+# specified with $ORIGIN, which isn't currently supported by
+# ../../mk/check/check-shlibs-elf.awk.
+CHECK_SHLIBS_SKIP+= */libHS*-ghc${PKGVERSION_NOREV}.*
+.for f in ghc ghc-iserv-dyn ghc-pkg haddock hpc hsc2hs runghc
+CHECK_SHLIBS_SKIP+= lib/${PKGNAME_NOREV}/bin/${f}
+.endfor
+
+# ghc57207_0.s: failed to add inputs for merge: Resource temporarily unavailable
+CTF_FILES_SKIP+= */libHS*-ghc${PKGVERSION_NOREV}.*
+
+# ld: fatal: relocation error ... relocation requires reference symbol
+STRIP_FILES_SKIP+= lib/${PKGNAME_NOREV}/libHSrts.a
+
+
+# -----------------------------------------------------------------------------
+# Dependencies
+#
+.if ${BUILD_SPHINX_HTML} != "no"
+BUILDLINK_DEPMETHOD.python:= build
+.include "../../lang/python/pyversion.mk"
+BUILD_DEPENDS+= ${PYPKGPREFIX}-sphinx-[0-9]*:../../textproc/py-sphinx
+.endif
+
+# NetBSD 9.x have libcurses with a newer major version than the
+# bootstrap kit is linked against. For now, work around this with
+# compat80.
+.if ${OPSYS} == "NetBSD" && empty(OS_VERSION:M[0-8].*)
+BUILD_DEPENDS+= compat80-[0-9]*:../../emulators/compat80
+# In a sandboxed build environment, we have to reach over to the
+# installed libraries themselves, since the symlinks compat80 adds
+# to the /usr tree can't be applied.
+MAKE_ENV+= LD_LIBRARY_PATH=${PREFIX}/emul/netbsd/usr/lib
+.endif
+
+.include "../../converters/libiconv/buildlink3.mk"
+.include "../../devel/libffi/buildlink3.mk"
+.include "../../devel/gmp/buildlink3.mk"
+.include "../../mk/curses.buildlink3.mk"
+.include "../../mk/pthread.buildlink3.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/lang/ghc88/bootstrap.mk b/lang/ghc88/bootstrap.mk
new file mode 100644
index 00000000000..b6a10062972
--- /dev/null
+++ b/lang/ghc88/bootstrap.mk
@@ -0,0 +1,286 @@
+# $NetBSD: bootstrap.mk,v 1.1 2020/01/09 12:32:24 pho Exp $
+# -----------------------------------------------------------------------------
+# Select a bindist of bootstrapping compiler on a per-platform basis.
+#
+# BOOT_ARCHIVE
+# This variable is set to the name of compressed archive file of a
+# bootstrapping compiler for the current platform.
+#
+# BOOT_VERSION
+# Version of the bootstrapping compiler to use. This can be
+# overriden for specific platforms.
+#
+.include "../../mk/bsd.prefs.mk"
+
+# Notes on version dependencies:
+# * GHC 8.8.1 requires 8.4 or later to bootstrap.
+# * GHC 8.4.4 requires 8.0 or later to bootstrap.
+# * GHC 8.0.2 requires 7.8 or later to bootstrap.
+# * GHC 7.10.3 requires 7.6 or later to bootstrap.
+
+########################################################################
+# Please note that GHC 8.8.1 fails to build itself due to this bug: #
+# https://gitlab.haskell.org/ghc/ghc/issues/17146 #
+# #
+# It is expected to be fixed in 8.8.2 but until that we must bootstrap #
+# it with 8.4.4. WE MUST NOT REMOVE lang/ghc84 UNTIL THAT. #
+########################################################################
+
+.if !empty(MACHINE_PLATFORM:MDarwin-*-powerpc) || make(distinfo) || make (makesum) || make(mdi)
+#BOOT_VERSION:= 8.4.4
+#BOOT_ARCHIVE:= ghc-${BOOT_VERSION}-boot-powerpc-apple-darwin.tar.xz
+#DISTFILES:= ${DISTFILES} ${BOOT_ARCHIVE} # Available in LOCAL_PORTS
+.endif
+
+.if !empty(MACHINE_PLATFORM:MFreeBSD-*-i386) || make(distinfo) || make (makesum) || make(mdi)
+#BOOT_VERSION:= 8.4.4
+#BOOT_ARCHIVE:= ghc-${BOOT_VERSION}-boot-i386-unknown-freebsd.tar.xz
+#DISTFILES:= ${DISTFILES} ${BOOT_ARCHIVE} # Available in LOCAL_PORTS
+.endif
+
+.if !empty(MACHINE_PLATFORM:MNetBSD-*-x86_64) || make(distinfo) || make (makesum) || make(mdi)
+BOOT_VERSION:= 8.4.4
+BOOT_ARCHIVE:= ghc-${BOOT_VERSION}-boot-x86_64-unknown-netbsd.tar.xz
+DISTFILES:= ${DISTFILES} ${BOOT_ARCHIVE} # Available in LOCAL_PORTS
+.endif
+
+.if !empty(MACHINE_PLATFORM:MSunOS-*-i386) || make(distinfo) || make (makesum) || make(mdi)
+#BOOT_VERSION:= 8.4.4
+#BOOT_ARCHIVE:= ghc-${BOOT_VERSION}-boot-i386-unknown-solaris2.tar.xz
+#DISTFILES:= ${DISTFILES} ${BOOT_ARCHIVE} # Available in LOCAL_PORTS
+.endif
+
+.if !empty(MACHINE_PLATFORM:MSunOS-*-x86_64) || make(distinfo) || make (makesum) || make(mdi)
+#BOOT_VERSION:= 8.4.4
+#BOOT_ARCHIVE:= ghc-${BOOT_VERSION}-boot-x86_64-unknown-solaris2.tar.xz
+#DISTFILES:= ${DISTFILES} ${BOOT_ARCHIVE} # Available in LOCAL_PORTS
+.endif
+
+.if empty(BOOT_ARCHIVE)
+BOOT_ARCHIVE:= ghc-${BOOT_VERSION}-boot-unknown.tar.xz
+PKG_FAIL_REASON+= "internal error: unsupported platform"
+.endif
+
+# For package developers, please do not upload any bootkits unsafely
+# built. That is, machines shared with someone or on a cloud hosting
+# service should be avoided for building bootkits.
+.for i in ${DISTFILES:M*-boot-*}
+SITES.${i}?= ${MASTER_SITE_LOCAL}
+.endfor
+
+# Existence of libelf makes LeadingUnderscore being "NO", which is
+# incorrect for this platform. See ${WRKSRC}/aclocal.m4
+# (FP_LEADING_UNDERSCORE)
+.if ${OPSYS} == "Darwin"
+CONFLICTS+= libelf-[0-9]*
+.endif
+
+# FreeBSD < 10 surprisingly doesn't have a native iconv so we need to
+# use pkgsrc libiconv for this OPSYS. And if a bootkit depends on
+# pkgsrc libiconv, the "normal" build must do the same because GHC
+# always needs to link executables with libiconv, just like libgmp
+# when integer-gmp is used. For this reason it might be desirable to
+# create two separate bootkits, one for < 10 and another for >= 10.
+.if ${OPSYS} == "FreeBSD"
+USE_BUILTIN.iconv= no
+.endif
+
+# current bootstrap binary kit for SmartOS is built with ncurses5
+.if !empty(MACHINE_PLATFORM:MSunOS-*) && ${OS_VARIANT:U} == "SmartOS"
+BUILD_DEPENDS+= ncurses>=5.0:../../devel/ncurses
+.endif
+
+
+# -----------------------------------------------------------------------------
+# The "pre-configure" hook
+#
+# Install a bootstrapping compiler directly into TOOLS_DIR so that
+# ./configure can find it.
+#
+USE_TOOLS+= gmake xzcat xz gtar
+
+pre-configure:
+ ${RUN}${TEST} -f ${DISTDIR}/${DIST_SUBDIR}/${BOOT_ARCHIVE} || \
+ ${FAIL_MSG} "Put your trusted bootstrap archive as ${DISTDIR}/${DIST_SUBDIR}/${BOOT_ARCHIVE}"
+
+ @${PHASE_MSG} "Extracting bootstrapping compiler for ${PKGNAME}"
+ ${RUN}${MKDIR} ${WRKDIR}/build-extract
+ ${RUN}cd ${WRKDIR}/build-extract && \
+ ${XZCAT} ${DISTDIR}/${DIST_SUBDIR}/${BOOT_ARCHIVE} | \
+ ${GTAR} -xf -
+
+# It is important to install the stage-0 compiler with our rpath flags
+# configured, otherwise it will produce executables with no rpath and
+# fail at the configure phase.
+ @${PHASE_MSG} "Preparing bootstrapping compiler for ${PKGNAME}"
+ ${RUN}cd ${WRKDIR}/build-extract/ghc-${BOOT_VERSION}-boot && \
+ ${PKGSRC_SETENV} ${CONFIGURE_ENV} ${SH} ./configure \
+ --prefix=${TOOLS_DIR:Q} && \
+ ${MAKE_PROGRAM} install
+
+
+# -----------------------------------------------------------------------------
+# An unusual target "bootstrap"
+#
+# Build a bootstrapping compiler using an already installed GHC. This
+# can certainly be impossible if you don't have one. It's absolutely
+# important to build it with the fewest possible run-time
+# dependencies, otherwise the resulting binary can easily get
+# unusable.
+
+# We don't want our bootkits to have a run-time dependency on
+# libgcc. In fact GHC's implementation of Haskell exception handling
+# does not depend on libgcc's facilities so it is attractive to do the
+# same for "normal" build... but we can't. This is because Haskell
+# programs may call C functions via FFI, and those C functions may
+# call C++ functions in turn, possibly in a different shared library.
+.include "../../mk/compiler.mk"
+.if make(bootstrap) && !empty(CC_VERSION:Mgcc-*)
+# But on some platforms, gcc automagically inserts a dependency on a
+# shared libgcc when -lpthread is given, which is seemingly
+# unavoidable.
+LDFLAGS+= -static-libgcc
+.endif
+
+# Gather information about packages on which bootkit depends. It will
+# be used in the post-bootstrap phase.
+BOOT_GHC_DEPS:= curses iconv
+BOOT_GHC_PKGSRC_DEPS:= # empty
+.for pkg in ${BOOT_GHC_DEPS}
+
+# NOTE: pkglint(1) complains for including these builtin.mk files,
+# telling that we must include buildlink3.mk instead. But then how do
+# we get variables like USE_BUILTIN.${pkg} defined before including
+# ../../mk/bsd.pkg.mk, given that ../../mk/bsd.buildlink3.mk isn't
+# protected against multiple inclusion?
+CHECK_BUILTIN.${pkg}:= yes
+. if ${pkg} == "curses"
+. include "../../mk/curses.builtin.mk"
+. elif ${pkg} == "iconv"
+. include "../../converters/libiconv/builtin.mk"
+. endif
+CHECK_BUILTIN.${pkg}:= no
+
+# BOOT_GHC_PKGSRC_DEPS is a list of packages whose pkgsrc version is
+# preferred over native one, either by user or ../../mk/platform
+. if ${PREFER.${pkg}} == "pkgsrc"
+BOOT_GHC_PKGSRC_DEPS+= ${pkg}
+. endif
+.endfor
+
+# Compiler wrappers must not remove -I/-L flags for the installed
+# GHC's libdir, otherwise the stage-0 GHC (which we are going to use
+# for building our bootstraping kit) will not work. Ideally it should
+# be added to BUILDLINK_PASSTHRU_DIRS only .if make(bootstrap), but
+# then running "${MAKE} wrapper" before "${MAKE} bootstrap" will
+# result in a cryptic error which we can't easily catch.
+BOOT_GHC_LIBDIR_CMD= ghc --print-libdir
+.if !defined(BOOT_GHC_LIBDIR)
+BOOT_GHC_LIBDIR!= (${BOOT_GHC_LIBDIR_CMD}) 2>/dev/null || ${ECHO}
+.endif
+MAKEVARS+= BOOT_GHC_LIBDIR
+BUILDLINK_PASSTHRU_DIRS+= ${BOOT_GHC_LIBDIR}
+
+# Default values for BUILDLINK_INCDIRS.<pkg> are only generated in the
+# barrier. See ../../mk/buildlink3/bsd.buildlink3.mk and
+# ../../mk/bsd.pkg.barrier.mk
+.PHONY: bootstrap
+BOOT_ARCHIVE.new= ${BOOT_ARCHIVE:S/-${BOOT_VERSION}-/-${PKGVERSION_NOREV}-/}
+.if make(bootstrap)
+_BARRIER_CMDLINE_TARGETS+= bootstrap
+.endif
+.if !defined(_PKGSRC_BARRIER)
+bootstrap: barrier
+.else
+bootstrap: pre-bootstrap .WAIT ${WRKDIR}/stamp-dist-boot .WAIT post-bootstrap
+.endif
+
+# For normal build we use pkgsrc libffi, but for bootkits we can't do
+# that because that would mean bootkits have run-time dependency on
+# it. So we build the bundled one and statically link with it.
+CONFIGURE_ARGS.boot= ${CONFIGURE_ARGS.common}
+CONFIGURE_ARGS.boot+= --without-system-libffi
+
+.PHONY: pre-bootstrap
+pre-bootstrap: wrapper
+.if empty(BOOT_GHC_LIBDIR)
+ ${RUN}if ${BOOT_GHC_LIBDIR_CMD} 2>/dev/null 1>&2; then \
+ ${ERROR_MSG} "Running \"${BOOT_GHC_LIBDIR_CMD}\" has failed during wrapper phase."; \
+ ${FAIL_MSG} "Please run \"${MAKE} clean\" and try again."; \
+ else \
+ ${ERROR_MSG} "Failed to run \"${BOOT_GHC_LIBDIR_CMD}\":"; \
+ ${BOOT_GHC_LIBDIR_CMD}; \
+ ${ERROR_MSG} "You don't seem to have a working GHC in your PATH."; \
+ ${FAIL_MSG} "Please install one and then run \"${MAKE} clean bootstrap\"."; \
+ fi
+.endif
+# ${_COOKIE.configure} is not defined yet so we can't use .if here.
+ ${RUN}if ${TEST} -f ${_COOKIE.configure}; then \
+ ${ERROR_MSG} "You have already configured the package in a way\
+ that building bootstrapping compiler is impossible."; \
+ ${FAIL_MSG} "Please run \"${MAKE} clean\" first."; \
+ fi
+
+${WRKDIR}/lndir:
+ @${PHASE_MSG} "Building lndir(1) to duplicate the source tree."
+ cd ${WRKSRC}/utils/lndir && \
+ ${PKG_CC:Q} lndir.c -I../fs ../fs/fs.c -o ${.TARGET}
+
+${WRKDIR}/stamp-lndir-boot: ${WRKDIR}/lndir
+ @${PHASE_MSG} "Duplicating the source tree for bootstrapping ${PKGNAME_NOREV}"
+ ${MKDIR} ${WRKDIR}/build-boot
+ cd ${WRKDIR}/build-boot && \
+ ${WRKDIR}/lndir -silent ../${PKGNAME_NOREV}
+ ${TOUCH} ${.TARGET}
+
+${WRKDIR}/stamp-configure-boot: ${WRKDIR}/stamp-lndir-boot
+ @${PHASE_MSG} "Configuring bootstrapping compiler ${PKGNAME_NOREV}"
+ ${MKDIR} ${WRKDIR}/build-boot
+ cd ${WRKDIR}/build-boot && \
+ ${PKGSRC_SETENV} ${CONFIGURE_ENV} ${SH} ./configure ${CONFIGURE_ARGS.boot} && \
+ ${CP} -f ${FILESDIR}/bootstrap.build.mk mk/build.mk
+ ${TOUCH} ${.TARGET}
+
+${WRKDIR}/stamp-build-boot: ${WRKDIR}/stamp-configure-boot
+ @${PHASE_MSG} "Building bootstrapping compiler ${PKGNAME_NOREV}"
+ ${RUN}cd ${WRKDIR}/build-boot && ${BUILD_MAKE_CMD}
+ ${TOUCH} ${.TARGET}
+
+${WRKDIR}/stamp-dist-boot: ${WRKDIR}/stamp-build-boot
+ @${PHASE_MSG} "Creating binary distribution of bootstrapping ${PKGNAME_NOREV}"
+ ${RUN}cd ${WRKDIR}/build-boot && ${BUILD_MAKE_CMD} binary-dist
+ ${MV} -f ${WRKDIR}/build-boot/${BOOT_ARCHIVE.new} ${WRKDIR}/${BOOT_ARCHIVE.new}
+
+.PHONY: post-bootstrap
+post-bootstrap:
+ @${ECHO} "=========================================================================="
+ @${ECHO} "Done creating ${BOOT_ARCHIVE.new}"
+ @${ECHO} " in ${WRKDIR}"
+ @${ECHO}
+ @${ECHO} "Now you can copy it into ${DISTDIR}/${DIST_SUBDIR} to use as your"
+ @${ECHO} "bootstrap kit. You may want to take a backup in case \"lintpkgsrc -r\""
+ @${ECHO} "removes it."
+ @${ECHO}
+ @${ECHO} "Your bootstrap kit has the following run-time dependencies:"
+.for pkg in ${BOOT_GHC_DEPS}
+ @${PRINTF} " * %-8s" "${pkg}:"
+. if !empty(USE_BUILTIN.${pkg}:M[nN][oO])
+ @${ECHO_N} " pkgsrc ${BUILDLINK_PKGNAME.${pkg}}"
+. else
+ @${ECHO_N} " native"
+. if empty(BUILTIN_PKG.${pkg})
+ @${ECHO_N} " (version/variant unknown)"
+. else
+ @${ECHO_N} " ${BUILTIN_PKG.${pkg}}"
+. endif
+. endif
+ @${ECHO}
+.endfor
+.if !empty(BOOT_GHC_PKGSRC_DEPS)
+ @${ECHO}
+ @${ECHO} "Please note that it is generally not a good idea for a bootkit to depend"
+ @${ECHO} "on pkgsrc packages, as pkgsrc tends to move faster than operating systems"
+ @${ECHO} "so your bootkit may bitrot more quickly. You may want to rebuild it"
+ @${ECHO} "without setting PREFER_PKGSRC to \"yes\"."
+.endif
+ @${ECHO} "=========================================================================="
diff --git a/lang/ghc88/buildlink3.mk b/lang/ghc88/buildlink3.mk
new file mode 100644
index 00000000000..6ced00227a1
--- /dev/null
+++ b/lang/ghc88/buildlink3.mk
@@ -0,0 +1,24 @@
+# $NetBSD: buildlink3.mk,v 1.1 2020/01/09 12:32:24 pho Exp $
+
+BUILDLINK_TREE+= ghc
+
+.if !defined(GHC_BUILDLINK3_MK)
+GHC_BUILDLINK3_MK:=
+
+BUILDLINK_API_DEPENDS.ghc+= ghc>=8.8.1
+BUILDLINK_ABI_DEPENDS.ghc+= ghc>=8.8.1
+BUILDLINK_PKGSRCDIR.ghc?= ../../lang/ghc88
+
+# On FreeBSD we need pkgsrc libiconv. See bootstrap.mk for details.
+.include "../../mk/bsd.fast.prefs.mk"
+.if ${OPSYS} == "FreeBSD"
+USE_BUILTIN.iconv= no
+.endif
+
+.include "../../converters/libiconv/buildlink3.mk"
+.include "../../devel/libffi/buildlink3.mk"
+.include "../../devel/gmp/buildlink3.mk"
+.include "../../mk/curses.buildlink3.mk"
+.endif # GHC_BUILDLINK3_MK
+
+BUILDLINK_TREE+= -ghc
diff --git a/lang/ghc88/distinfo b/lang/ghc88/distinfo
new file mode 100644
index 00000000000..e0f7ad228b3
--- /dev/null
+++ b/lang/ghc88/distinfo
@@ -0,0 +1,24 @@
+$NetBSD: distinfo,v 1.1 2020/01/09 12:32:24 pho Exp $
+
+SHA1 (ghc-8.4.4-boot-x86_64-unknown-netbsd.tar.xz) = bc7b0e203a6e7e6804c4be46957352d032cd22ec
+RMD160 (ghc-8.4.4-boot-x86_64-unknown-netbsd.tar.xz) = dd50835c50cd2102c1af4d2ed8f1148c8ac4d4d9
+SHA512 (ghc-8.4.4-boot-x86_64-unknown-netbsd.tar.xz) = 0cc836390985c56d79a5c08dd2117c53fc9802b969db408dab14cfd441d95b2b5c18fed5d0b6da8a8555501e668ba471d0b878ea11a0021fba76265ed4ef8f76
+Size (ghc-8.4.4-boot-x86_64-unknown-netbsd.tar.xz) = 53040892 bytes
+SHA1 (ghc-8.8.1-src.tar.xz) = 9d8c1b2e0bad002fed39ba8f53684615a96bc218
+RMD160 (ghc-8.8.1-src.tar.xz) = c514d565e9f808a58991e47b17dccb85f0c01056
+SHA512 (ghc-8.8.1-src.tar.xz) = 7268b012c3a6c34e7eac05c7d6959de6005651d33e870860bbfe589295502e8794a76580130b8f4da2f88032b68116dbbdbc4c1e900e0c862aaa9891fa788bef
+Size (ghc-8.8.1-src.tar.xz) = 28634672 bytes
+SHA1 (patch-aclocal.m4) = e4065df0cfc2924aa12f7b0f18a58ff80b1ff1dc
+SHA1 (patch-compiler_main_DynFlags.hs) = 07bb2a5afdd087f4d2da5c035feecc13273aec70
+SHA1 (patch-configure.ac) = f521200b519fdaab1082c4a2fcac9c3dd9135d7b
+SHA1 (patch-ghc_ghc.mk) = 331b947f6a5af09b3fda82697f071941166edbd0
+SHA1 (patch-libraries_base_GHC_Event_KQueue.hsc) = 8ee5da667a241a05fde3c580d3dc9bdc05aa5f00
+SHA1 (patch-libraries_base_System_CPUTime_Posix_Times.hsc) = 2bfb779d534d12073287274ce5e90b99e457a860
+SHA1 (patch-libraries_base_System_Environment.hs) = 7d79a91f295915b4408d5f41d5405739d7189215
+SHA1 (patch-libraries_time_lib_Data_Time_Clock_Internal_CTimespec.hsc) = 588270767f8a9cbde0648fc99807891fef65d721
+SHA1 (patch-libraries_time_lib_Data_Time_Clock_Internal_CTimeval.hs) = b2811ec4a845e6b2b44414e940b6108178b597c5
+SHA1 (patch-libraries_unix_System_Posix_Env.hsc) = e94936c139ca15d45cac4a7feb74a601567913ab
+SHA1 (patch-libraries_unix_System_Posix_Env_ByteString.hsc) = 3f675fc5d6bf5cc59a2d5ccffeb9ccd51521645a
+SHA1 (patch-libraries_unix_System_Posix_Files_Common.hsc) = 6efef280832d376915a8987e4e8aac283408f607
+SHA1 (patch-libraries_unix_System_Posix_Signals.hsc) = 49215dce493a6bbc440f91a3959e592f86fc779b
+SHA1 (patch-libraries_unix_include_execvpe.h) = 67dd9720a71a6a55bbe2b50e61621ca60187ef00
diff --git a/lang/ghc88/files/bootstrap.build.mk b/lang/ghc88/files/bootstrap.build.mk
new file mode 100644
index 00000000000..7e4fffd544b
--- /dev/null
+++ b/lang/ghc88/files/bootstrap.build.mk
@@ -0,0 +1,44 @@
+# -*- makefile-gmake -*-
+#
+# This is a build conf for bootstrapping compilers.
+#
+
+# We don't want any docs.
+HADDOCK_DOCS = NO
+BUILD_MAN = NO
+BUILD_SPHINX_HTML = NO
+BUILD_SPHINX_PDF = NO
+
+# Enabling evil-splitter reduces bindist size, which is good. However
+# it introduces a run-time dependency on perl, which is unacceptable.
+SplitObjs = NO
+
+# We only want vanilla libraries and rts. No profiling, no shared
+# libraries, no debugging, no event logging.
+GhcLibWays = v
+GhcRTSWays =
+
+# I'm not sure disabling GHCi significantly reduces the bindist size,
+# but we don't need it anyway.
+GhcWithInterpreter = NO
+
+# We don't want in-place GMP to be statically linked as it increases
+# the bindist size. Dynamic linkage is even worse.
+INTEGER_LIBRARY = integer-simple
+
+# We'd like to distinguish bootstrapping bindists from normal ones.
+BIN_DIST_NAME = ghc-$(ProjectVersion)-boot
+
+# Don't build or use dynamic Haskell libraries.
+DYNAMIC_GHC_PROGRAMS = NO
+
+ghc_stage1_CONFIGURE_OPTS += -f-threaded
+ghc_stage2_CONFIGURE_OPTS += -f-threaded
+ghc_stage3_CONFIGURE_OPTS += -f-threaded
+
+# We want our bootkits to be as small as possible, even though `xz
+# -9e' is very slow and consumes about 680 MiB of memory.
+TAR_COMP = xz
+TAR_COMP_CMD = $(XZ_CMD) $(TAR_COMP_OPTS)
+TAR_COMP_EXT = xz
+TAR_COMP_OPTS = --verbose -9 --extreme
diff --git a/lang/ghc88/patches/patch-aclocal.m4 b/lang/ghc88/patches/patch-aclocal.m4
new file mode 100644
index 00000000000..ec494e732eb
--- /dev/null
+++ b/lang/ghc88/patches/patch-aclocal.m4
@@ -0,0 +1,16 @@
+$NetBSD: patch-aclocal.m4,v 1.1 2020/01/09 12:32:24 pho Exp $
+
+Canonicalize OS name netbsd* to "netbsd".
+
+--- aclocal.m4.orig 2019-08-25 12:03:36.000000000 +0000
++++ aclocal.m4
+@@ -2044,6 +2044,9 @@ AC_DEFUN([GHC_CONVERT_OS],[
+ openbsd*)
+ $3="openbsd"
+ ;;
++ netbsd*)
++ $3="netbsd"
++ ;;
+ # As far as I'm aware, none of these have relevant variants
+ freebsd|netbsd|dragonfly|hpux|linuxaout|kfreebsdgnu|freebsd2|mingw32|darwin|nextstep2|nextstep3|sunos4|ultrix|haiku)
+ $3="$1"
diff --git a/lang/ghc88/patches/patch-compiler_main_DynFlags.hs b/lang/ghc88/patches/patch-compiler_main_DynFlags.hs
new file mode 100644
index 00000000000..eee854b12b0
--- /dev/null
+++ b/lang/ghc88/patches/patch-compiler_main_DynFlags.hs
@@ -0,0 +1,17 @@
+$NetBSD: patch-compiler_main_DynFlags.hs,v 1.1 2020/01/09 12:32:24 pho Exp $
+
+Fix building bootkits: the stage being >= 2 doesn't imply that GHCI is
+enabled. This is a logic error. We build our bootkits with GHCI
+disabled.
+
+--- compiler/main/DynFlags.hs.orig 2020-01-08 12:22:53.874596542 +0000
++++ compiler/main/DynFlags.hs
+@@ -250,7 +250,7 @@ import qualified EnumSet
+ import GHC.Foreign (withCString, peekCString)
+ import qualified GHC.LanguageExtensions as LangExt
+
+-#if defined(GHCI)
++#if STAGE >= 2
+ import Foreign (Ptr) -- needed for 2nd stage
+ #endif
+
diff --git a/lang/ghc88/patches/patch-configure.ac b/lang/ghc88/patches/patch-configure.ac
new file mode 100644
index 00000000000..f4293c78788
--- /dev/null
+++ b/lang/ghc88/patches/patch-configure.ac
@@ -0,0 +1,15 @@
+$NetBSD: patch-configure.ac,v 1.1 2020/01/09 12:32:24 pho Exp $
+
+Don't use non-portable operator ==.
+
+--- configure.ac.orig 2020-01-04 08:10:34.453377650 +0000
++++ configure.ac
+@@ -914,7 +914,7 @@ FP_CHECK_SIZEOF_AND_ALIGNMENT(uint64_t)
+
+ dnl for use in settings.in
+ TargetWordSize=$ac_cv_sizeof_void_p
+-if test "x$TargetWordSize" == 8; then
++if test "x$TargetWordSize" = 8; then
+ AC_SUBST([Cabal64bit],[True])
+ else
+ AC_SUBST([Cabal64bit],[False])
diff --git a/lang/ghc88/patches/patch-ghc_ghc.mk b/lang/ghc88/patches/patch-ghc_ghc.mk
new file mode 100644
index 00000000000..ef5e5f8e581
--- /dev/null
+++ b/lang/ghc88/patches/patch-ghc_ghc.mk
@@ -0,0 +1,22 @@
+$NetBSD: patch-ghc_ghc.mk,v 1.1 2020/01/09 12:32:24 pho Exp $
+
+Fix building bootkits: the ghc-bin package is threaded by default, but
+the build system fails to opt out from it when threaded RTS is
+disabled.
+
+--- ghc/ghc.mk.orig 2019-08-25 12:03:36.000000000 +0000
++++ ghc/ghc.mk
+@@ -61,7 +61,13 @@ ifeq "$(GhcThreaded)" "YES"
+ # Use threaded RTS with GHCi, so threads don't get blocked at the prompt.
+ ghc_stage2_MORE_HC_OPTS += -threaded
+ ghc_stage3_MORE_HC_OPTS += -threaded
++else
++# Opt out from threaded GHC. See ghc-bin.cabal.in
++ghc_stage2_CONFIGURE_OPTS += -f-threaded
++ghc_stage3_CONFIGURE_OPTS += -f-threaded
+ endif
++# Stage-0 compiler isn't guaranteed to have a threaded RTS.
++ghc_stage1_CONFIGURE_OPTS += -f-threaded
+
+ ifeq "$(GhcProfiled)" "YES"
+ ghc_stage2_PROGRAM_WAY = p
diff --git a/lang/ghc88/patches/patch-libraries_base_GHC_Event_KQueue.hsc b/lang/ghc88/patches/patch-libraries_base_GHC_Event_KQueue.hsc
new file mode 100644
index 00000000000..701ea309227
--- /dev/null
+++ b/lang/ghc88/patches/patch-libraries_base_GHC_Event_KQueue.hsc
@@ -0,0 +1,16 @@
+$NetBSD: patch-libraries_base_GHC_Event_KQueue.hsc,v 1.1 2020/01/09 12:32:24 pho Exp $
+
+Suppress linker warnings about compatibility syscall wrappers by using
+"capi" instead of "ccall".
+
+--- libraries/base/GHC/Event/KQueue.hsc.orig 2019-12-26 18:05:56.276488590 +0000
++++ libraries/base/GHC/Event/KQueue.hsc
+@@ -284,7 +284,7 @@ foreign import capi safe "sys/event.h ke
+ c_kevent :: KQueueFd -> Ptr Event -> CInt -> Ptr Event -> CInt
+ -> Ptr TimeSpec -> IO CInt
+
+-foreign import ccall unsafe "kevent"
++foreign import capi unsafe "sys/event.h kevent"
+ c_kevent_unsafe :: KQueueFd -> Ptr Event -> CInt -> Ptr Event -> CInt
+ -> Ptr TimeSpec -> IO CInt
+ #else
diff --git a/lang/ghc88/patches/patch-libraries_base_System_CPUTime_Posix_Times.hsc b/lang/ghc88/patches/patch-libraries_base_System_CPUTime_Posix_Times.hsc
new file mode 100644
index 00000000000..1014770061e
--- /dev/null
+++ b/lang/ghc88/patches/patch-libraries_base_System_CPUTime_Posix_Times.hsc
@@ -0,0 +1,16 @@
+$NetBSD: patch-libraries_base_System_CPUTime_Posix_Times.hsc,v 1.1 2020/01/09 12:32:24 pho Exp $
+
+Suppress linker warnings about compatibility syscall wrappers by using
+"capi" instead of "ccall".
+
+--- libraries/base/System/CPUTime/Posix/Times.hsc.orig 2020-01-04 12:08:39.515726533 +0000
++++ libraries/base/System/CPUTime/Posix/Times.hsc
+@@ -27,7 +27,7 @@ getCPUTime = allocaBytes (#const sizeof(
+ `div` fromIntegral clockTicks)
+
+ type CTms = ()
+-foreign import ccall unsafe times :: Ptr CTms -> IO CClock
++foreign import capi unsafe "sys/times.h times" times :: Ptr CTms -> IO CClock
+
+ getCpuTimePrecision :: IO Integer
+ getCpuTimePrecision =
diff --git a/lang/ghc88/patches/patch-libraries_base_System_Environment.hs b/lang/ghc88/patches/patch-libraries_base_System_Environment.hs
new file mode 100644
index 00000000000..6fae51a5e09
--- /dev/null
+++ b/lang/ghc88/patches/patch-libraries_base_System_Environment.hs
@@ -0,0 +1,23 @@
+$NetBSD: patch-libraries_base_System_Environment.hs,v 1.1 2020/01/09 12:32:24 pho Exp $
+
+Suppress linker warnings about compatibility syscall wrappers by using
+"capi" instead of "ccall".
+
+--- libraries/base/System/Environment.hs.orig 2018-02-25 20:02:28.000000000 +0000
++++ libraries/base/System/Environment.hs
+@@ -1,5 +1,6 @@
+ {-# LANGUAGE Safe #-}
+ {-# LANGUAGE CPP #-}
++{-# LANGUAGE CApiFFI #-}
+
+ -----------------------------------------------------------------------------
+ -- |
+@@ -246,7 +247,7 @@ putEnv keyvalue = do
+ -- environment.
+ throwErrnoIf_ (/= 0) "putenv" (c_putenv s)
+
+-foreign import ccall unsafe "putenv" c_putenv :: CString -> IO CInt
++foreign import capi unsafe "stdlib.h putenv" c_putenv :: CString -> IO CInt
+ #endif
+
+ -- | @unsetEnv name@ removes the specified environment variable from the
diff --git a/lang/ghc88/patches/patch-libraries_time_lib_Data_Time_Clock_Internal_CTimespec.hsc b/lang/ghc88/patches/patch-libraries_time_lib_Data_Time_Clock_Internal_CTimespec.hsc
new file mode 100644
index 00000000000..b9148a775c6
--- /dev/null
+++ b/lang/ghc88/patches/patch-libraries_time_lib_Data_Time_Clock_Internal_CTimespec.hsc
@@ -0,0 +1,23 @@
+$NetBSD: patch-libraries_time_lib_Data_Time_Clock_Internal_CTimespec.hsc,v 1.1 2020/01/09 12:32:24 pho Exp $
+
+Suppress linker warnings about compatibility symbols.
+
+--- libraries/time/lib/Data/Time/Clock/Internal/CTimespec.hsc.orig 2020-01-04 02:21:30.506303962 +0000
++++ libraries/time/lib/Data/Time/Clock/Internal/CTimespec.hsc
+@@ -1,3 +1,4 @@
++{-# LANGUAGE CApiFFI #-}
+ module Data.Time.Clock.Internal.CTimespec where
+
+ #include "HsTimeConfig.h"
+@@ -29,9 +30,9 @@ instance Storable CTimespec where
+ #{poke struct timespec, tv_sec } p s
+ #{poke struct timespec, tv_nsec} p ns
+
+-foreign import ccall unsafe "time.h clock_gettime"
++foreign import capi unsafe "time.h clock_gettime"
+ clock_gettime :: ClockID -> Ptr CTimespec -> IO CInt
+-foreign import ccall unsafe "time.h clock_getres"
++foreign import capi unsafe "time.h clock_getres"
+ clock_getres :: ClockID -> Ptr CTimespec -> IO CInt
+
+ -- | Get the resolution of the given clock.
diff --git a/lang/ghc88/patches/patch-libraries_time_lib_Data_Time_Clock_Internal_CTimeval.hs b/lang/ghc88/patches/patch-libraries_time_lib_Data_Time_Clock_Internal_CTimeval.hs
new file mode 100644
index 00000000000..bbd0117b102
--- /dev/null
+++ b/lang/ghc88/patches/patch-libraries_time_lib_Data_Time_Clock_Internal_CTimeval.hs
@@ -0,0 +1,33 @@
+$NetBSD: patch-libraries_time_lib_Data_Time_Clock_Internal_CTimeval.hs,v 1.1 2020/01/09 12:32:24 pho Exp $
+
+Suppress linker warnings about compatibility syscall wrappers by using
+"capi" instead of "ccall". In Haskell FFI, "ccall" is actually an
+interface to C ABI rather than C API. That is, GHC generates direct
+references to the symbol even if it's actually defined as a cpp macro
+or something like that, because GHC knows nothing about those macros
+in foreign headers. Hence the following warnings:
+
+ .../libHStime-1.4.0.1.a(CTimeval.o): In function `s1Kp_info':
+ (.text+0x2f): warning: warning: reference to compatibility
+ gettimeofday(); include <sys/time.h> to generate correct reference
+
+In other words, you can safely use "ccall" only when you are sure the
+symbol you want to import is actually a symbol in the ABI sense, which
+is not always the case for the POSIX API.
+
+--- libraries/time/lib/Data/Time/Clock/Internal/CTimeval.hs.orig 2020-01-04 06:13:10.008205366 +0000
++++ libraries/time/lib/Data/Time/Clock/Internal/CTimeval.hs
+@@ -1,3 +1,4 @@
++{-# LANGUAGE CApiFFI #-}
+ module Data.Time.Clock.Internal.CTimeval where
+
+ #ifndef mingw32_HOST_OS
+@@ -23,7 +24,7 @@ instance Storable CTimeval where
+ pokeElemOff (castPtr p) 0 s
+ pokeElemOff (castPtr p) 1 mus
+
+-foreign import ccall unsafe "time.h gettimeofday" gettimeofday :: Ptr CTimeval -> Ptr () -> IO CInt
++foreign import capi unsafe "sys/time.h gettimeofday" gettimeofday :: Ptr CTimeval -> Ptr () -> IO CInt
+
+ -- | Get the current POSIX time from the system clock.
+ getCTimeval :: IO CTimeval
diff --git a/lang/ghc88/patches/patch-libraries_unix_System_Posix_Env.hsc b/lang/ghc88/patches/patch-libraries_unix_System_Posix_Env.hsc
new file mode 100644
index 00000000000..d534d84523e
--- /dev/null
+++ b/lang/ghc88/patches/patch-libraries_unix_System_Posix_Env.hsc
@@ -0,0 +1,16 @@
+$NetBSD: patch-libraries_unix_System_Posix_Env.hsc,v 1.1 2020/01/09 12:32:24 pho Exp $
+
+Suppress linker warnings about compatibility symbols by using "capi"
+instead of "ccall".
+
+--- libraries/unix/System/Posix/Env.hsc.orig 2016-11-17 22:08:50.000000000 +0000
++++ libraries/unix/System/Posix/Env.hsc
+@@ -156,7 +156,7 @@ putEnv keyvalue = do s <- newFilePath ke
+ newFilePath fp = getFileSystemEncoding >>= \enc -> GHC.newCString enc fp
+ #endif
+
+-foreign import ccall unsafe "putenv"
++foreign import capi unsafe "stdlib.h putenv"
+ c_putenv :: CString -> IO CInt
+
+ {- |The 'setEnv' function inserts or resets the environment variable name in
diff --git a/lang/ghc88/patches/patch-libraries_unix_System_Posix_Env_ByteString.hsc b/lang/ghc88/patches/patch-libraries_unix_System_Posix_Env_ByteString.hsc
new file mode 100644
index 00000000000..9042e49f995
--- /dev/null
+++ b/lang/ghc88/patches/patch-libraries_unix_System_Posix_Env_ByteString.hsc
@@ -0,0 +1,16 @@
+$NetBSD: patch-libraries_unix_System_Posix_Env_ByteString.hsc,v 1.1 2020/01/09 12:32:24 pho Exp $
+
+Suppress linker warnings about compatibility symbols by using "capi"
+instead of "ccall".
+
+--- libraries/unix/System/Posix/Env/ByteString.hsc.orig 2016-11-17 22:08:50.000000000 +0000
++++ libraries/unix/System/Posix/Env/ByteString.hsc
+@@ -130,7 +130,7 @@ putEnv :: ByteString {- ^ "key=value" -}
+ putEnv keyvalue = B.useAsCString keyvalue $ \s ->
+ throwErrnoIfMinus1_ "putenv" (c_putenv s)
+
+-foreign import ccall unsafe "putenv"
++foreign import capi unsafe "stdlib.h putenv"
+ c_putenv :: CString -> IO CInt
+
+ {- |The 'setEnv' function inserts or resets the environment variable name in
diff --git a/lang/ghc88/patches/patch-libraries_unix_System_Posix_Files_Common.hsc b/lang/ghc88/patches/patch-libraries_unix_System_Posix_Files_Common.hsc
new file mode 100644
index 00000000000..67ddabcf460
--- /dev/null
+++ b/lang/ghc88/patches/patch-libraries_unix_System_Posix_Files_Common.hsc
@@ -0,0 +1,33 @@
+$NetBSD: patch-libraries_unix_System_Posix_Files_Common.hsc,v 1.1 2020/01/09 12:32:24 pho Exp $
+
+Suppress linker warnings about compatibility syscall wrappers by using
+"capi" instead of "ccall".
+
+--- libraries/unix/System/Posix/Files/Common.hsc.orig 2016-04-20 10:08:26.000000000 +0000
++++ libraries/unix/System/Posix/Files/Common.hsc
+@@ -1,4 +1,5 @@
+ {-# LANGUAGE Trustworthy #-}
++{-# LANGUAGE CApiFFI #-}
+
+ -----------------------------------------------------------------------------
+ -- |
+@@ -448,16 +449,16 @@ toCTimeVal t = CTimeVal sec (truncate $
+ (sec, frac) = if (frac' < 0) then (sec' - 1, frac' + 1) else (sec', frac')
+ (sec', frac') = properFraction $ toRational t
+
+-foreign import ccall unsafe "utimes"
++foreign import capi unsafe "sys/time.h utimes"
+ c_utimes :: CString -> Ptr CTimeVal -> IO CInt
+
+ #ifdef HAVE_LUTIMES
+-foreign import ccall unsafe "lutimes"
++foreign import capi unsafe "sys/time.h lutimes"
+ c_lutimes :: CString -> Ptr CTimeVal -> IO CInt
+ #endif
+
+ #if HAVE_FUTIMES
+-foreign import ccall unsafe "futimes"
++foreign import capi unsafe "sys/time.h futimes"
+ c_futimes :: CInt -> Ptr CTimeVal -> IO CInt
+ #endif
+
diff --git a/lang/ghc88/patches/patch-libraries_unix_System_Posix_Signals.hsc b/lang/ghc88/patches/patch-libraries_unix_System_Posix_Signals.hsc
new file mode 100644
index 00000000000..801dbcd68ca
--- /dev/null
+++ b/lang/ghc88/patches/patch-libraries_unix_System_Posix_Signals.hsc
@@ -0,0 +1,22 @@
+$NetBSD: patch-libraries_unix_System_Posix_Signals.hsc,v 1.1 2020/01/09 12:32:24 pho Exp $
+
+Suppress linker warnings about compatibility symbols.
+
+--- libraries/unix/System/Posix/Signals.hsc.orig 2016-04-20 10:08:26.000000000 +0000
++++ libraries/unix/System/Posix/Signals.hsc
+@@ -590,7 +590,7 @@ awaitSignal maybe_sigset = do
+ -- XXX My manpage says it can also return EFAULT. And why is ignoring
+ -- EINTR the right thing to do?
+
+-foreign import ccall unsafe "sigsuspend"
++foreign import capi unsafe "signal.h sigsuspend"
+ c_sigsuspend :: Ptr CSigset -> IO CInt
+
+ #if defined(darwin_HOST_OS) && __GLASGOW_HASKELL__ < 706
+@@ -615,5 +615,5 @@ foreign import capi unsafe "signal.h sig
+ c_sigismember :: Ptr CSigset -> CInt -> IO CInt
+ #endif
+
+-foreign import ccall unsafe "sigpending"
++foreign import capi unsafe "signal.h sigpending"
+ c_sigpending :: Ptr CSigset -> IO CInt
diff --git a/lang/ghc88/patches/patch-libraries_unix_include_execvpe.h b/lang/ghc88/patches/patch-libraries_unix_include_execvpe.h
new file mode 100644
index 00000000000..89575aa2553
--- /dev/null
+++ b/lang/ghc88/patches/patch-libraries_unix_include_execvpe.h
@@ -0,0 +1,17 @@
+$NetBSD: patch-libraries_unix_include_execvpe.h,v 1.1 2020/01/09 12:32:24 pho Exp $
+
+Don't conflict with builtin execvpe(3).
+
+--- libraries/unix/include/execvpe.h.orig 2016-02-04 16:16:38.000000000 +0000
++++ libraries/unix/include/execvpe.h
+@@ -15,8 +15,10 @@ __hsunix_execvpe(const char *name, char
+ #include "HsUnixConfig.h"
+ #if HAVE_EXECVPE
+ # include <unistd.h>
++# if !defined(execvpe) && !HAVE_DECL_EXECVPE
+ extern int
+ execvpe(const char *name, char *const argv[], char *const envp[]);
++# endif
+ #else
+ # define execvpe(name,argv,envp) __hsunix_execvpe(name,argv,envp)
+ #endif