pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc/lang/ghc92



Module Name:    pkgsrc
Committed By:   pho
Date:           Sun Feb  6 05:36:16 UTC 2022

Added Files:
        pkgsrc/lang/ghc92: BOOTSTRAP.txt DEINSTALL DESCR INSTALL Makefile
            bootstrap.mk buildlink3.mk distinfo options.mk
        pkgsrc/lang/ghc92/files: bootstrap.build.mk
        pkgsrc/lang/ghc92/patches: patch-compiler_GHC_Driver_Pipeline.hs
            patch-compiler_GHC_SysTools_Process.hs patch-configure.ac
            patch-ghc.mk patch-ghc_ghc-bin.cabal.in patch-ghc_ghc.mk
            patch-libraries_Cabal_Cabal_src_Distribution_Simple_GHC.hs
            patch-libraries_base_GHC_Event_KQueue.hsc
            patch-libraries_base_System_CPUTime_Posix_Times.hsc
            patch-libraries_base_System_Environment.hs
            patch-libraries_base_configure
            patch-libraries_time_lib_Data_Time_Clock_Internal_CTimespec.hsc
            patch-libraries_time_lib_Data_Time_Clock_Internal_CTimeval.hs
            patch-libraries_unix_System_Posix_Env.hsc
            patch-libraries_unix_System_Posix_Env_ByteString.hsc
            patch-libraries_unix_System_Posix_Files_Common.hsc
            patch-libraries_unix_System_Posix_Signals.hsc
            patch-libraries_unix_include_execvpe.h patch-llvm-targets
            patch-m4_find__llvm__prog.m4 patch-m4_fptools__set__c__ld__flags.m4
            patch-mk_config.mk.in patch-rts_ProfHeap.c patch-rts_ghc.mk
            patch-rts_posix_GetTime.c patch-rts_posix_OSThreads.c
            patch-rules_build-package-way.mk patch-rules_distdir-way-opts.mk
            patch-utils_ghc-cabal_ghc.mk patch-utils_haddock_driver_Main.hs

Log Message:
Import GHC 9.2.1

The compiler now has a native codegen on aarch64. LLVM backend is now
optional, and is disabled by default.

The full release note is too long to paste here. See:
https://downloads.haskell.org/~ghc/9.2.1/docs/html/users_guide/9.2.1-notes.html


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 pkgsrc/lang/ghc92/BOOTSTRAP.txt \
    pkgsrc/lang/ghc92/DEINSTALL pkgsrc/lang/ghc92/DESCR \
    pkgsrc/lang/ghc92/INSTALL pkgsrc/lang/ghc92/Makefile \
    pkgsrc/lang/ghc92/bootstrap.mk pkgsrc/lang/ghc92/buildlink3.mk \
    pkgsrc/lang/ghc92/distinfo pkgsrc/lang/ghc92/options.mk
cvs rdiff -u -r0 -r1.1 pkgsrc/lang/ghc92/files/bootstrap.build.mk
cvs rdiff -u -r0 -r1.1 \
    pkgsrc/lang/ghc92/patches/patch-compiler_GHC_Driver_Pipeline.hs \
    pkgsrc/lang/ghc92/patches/patch-compiler_GHC_SysTools_Process.hs \
    pkgsrc/lang/ghc92/patches/patch-configure.ac \
    pkgsrc/lang/ghc92/patches/patch-ghc.mk \
    pkgsrc/lang/ghc92/patches/patch-ghc_ghc-bin.cabal.in \
    pkgsrc/lang/ghc92/patches/patch-ghc_ghc.mk \
    pkgsrc/lang/ghc92/patches/patch-libraries_Cabal_Cabal_src_Distribution_Simple_GHC.hs \
    pkgsrc/lang/ghc92/patches/patch-libraries_base_GHC_Event_KQueue.hsc \
    pkgsrc/lang/ghc92/patches/patch-libraries_base_System_CPUTime_Posix_Times.hsc \
    pkgsrc/lang/ghc92/patches/patch-libraries_base_System_Environment.hs \
    pkgsrc/lang/ghc92/patches/patch-libraries_base_configure \
    pkgsrc/lang/ghc92/patches/patch-libraries_time_lib_Data_Time_Clock_Internal_CTimespec.hsc \
    pkgsrc/lang/ghc92/patches/patch-libraries_time_lib_Data_Time_Clock_Internal_CTimeval.hs \
    pkgsrc/lang/ghc92/patches/patch-libraries_unix_System_Posix_Env.hsc \
    pkgsrc/lang/ghc92/patches/patch-libraries_unix_System_Posix_Env_ByteString.hsc \
    pkgsrc/lang/ghc92/patches/patch-libraries_unix_System_Posix_Files_Common.hsc \
    pkgsrc/lang/ghc92/patches/patch-libraries_unix_System_Posix_Signals.hsc \
    pkgsrc/lang/ghc92/patches/patch-libraries_unix_include_execvpe.h \
    pkgsrc/lang/ghc92/patches/patch-llvm-targets \
    pkgsrc/lang/ghc92/patches/patch-m4_find__llvm__prog.m4 \
    pkgsrc/lang/ghc92/patches/patch-m4_fptools__set__c__ld__flags.m4 \
    pkgsrc/lang/ghc92/patches/patch-mk_config.mk.in \
    pkgsrc/lang/ghc92/patches/patch-rts_ProfHeap.c \
    pkgsrc/lang/ghc92/patches/patch-rts_ghc.mk \
    pkgsrc/lang/ghc92/patches/patch-rts_posix_GetTime.c \
    pkgsrc/lang/ghc92/patches/patch-rts_posix_OSThreads.c \
    pkgsrc/lang/ghc92/patches/patch-rules_build-package-way.mk \
    pkgsrc/lang/ghc92/patches/patch-rules_distdir-way-opts.mk \
    pkgsrc/lang/ghc92/patches/patch-utils_ghc-cabal_ghc.mk \
    pkgsrc/lang/ghc92/patches/patch-utils_haddock_driver_Main.hs

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Added files:

Index: pkgsrc/lang/ghc92/BOOTSTRAP.txt
diff -u /dev/null pkgsrc/lang/ghc92/BOOTSTRAP.txt:1.1
--- /dev/null   Sun Feb  6 05:36:16 2022
+++ pkgsrc/lang/ghc92/BOOTSTRAP.txt     Sun Feb  6 05:36:15 2022
@@ -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.
Index: pkgsrc/lang/ghc92/DEINSTALL
diff -u /dev/null pkgsrc/lang/ghc92/DEINSTALL:1.1
--- /dev/null   Sun Feb  6 05:36:16 2022
+++ pkgsrc/lang/ghc92/DEINSTALL Sun Feb  6 05:36:15 2022
@@ -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
Index: pkgsrc/lang/ghc92/DESCR
diff -u /dev/null pkgsrc/lang/ghc92/DESCR:1.1
--- /dev/null   Sun Feb  6 05:36:16 2022
+++ pkgsrc/lang/ghc92/DESCR     Sun Feb  6 05:36:15 2022
@@ -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 9.2.x release series.
Index: pkgsrc/lang/ghc92/INSTALL
diff -u /dev/null pkgsrc/lang/ghc92/INSTALL:1.1
--- /dev/null   Sun Feb  6 05:36:16 2022
+++ pkgsrc/lang/ghc92/INSTALL   Sun Feb  6 05:36:15 2022
@@ -0,0 +1,8 @@
+#!/bin/sh
+#
+
+case ${STAGE} in
+    POST-INSTALL)
+        ${PKG_PREFIX}/bin/ghc-pkg recache
+        ;;
+esac
Index: pkgsrc/lang/ghc92/Makefile
diff -u /dev/null pkgsrc/lang/ghc92/Makefile:1.1
--- /dev/null   Sun Feb  6 05:36:16 2022
+++ pkgsrc/lang/ghc92/Makefile  Sun Feb  6 05:36:15 2022
@@ -0,0 +1,255 @@
+# $NetBSD: Makefile,v 1.1 2022/02/06 05:36:15 pho Exp $
+# -----------------------------------------------------------------------------
+# Package metadata
+#
+DISTNAME=      ghc-9.2.1-src
+PKGNAME=       ${DISTNAME:S/-src$//}
+CATEGORIES=    lang
+MASTER_SITES=  https://downloads.haskell.org/~ghc/${PKGVERSION_NOREV}/
+EXTRACT_SUFX=  .tar.xz
+
+MAINTAINER=    pkgsrc-users%NetBSD.org@localhost
+HOMEPAGE=      https://www.haskell.org/ghc/
+COMMENT=       Compiler for the functional language Haskell - 9.2 Release Series
+LICENSE=       modified-bsd
+
+UNLIMIT_RESOURCES=     datasize virtualsize
+
+# GHC requires GHC to build itself. We have to prepare stripped-down
+# binaries sufficient to bootstrap compilers for each platform. If
+# you want to build them yourself, follow instructions in
+# BOOTSTRAP.txt and ./bootstrap.mk
+BROKEN_EXCEPT_ON_PLATFORM+=    Darwin-*-x86_64
+BROKEN_EXCEPT_ON_PLATFORM+=    FreeBSD-*-i386
+BROKEN_EXCEPT_ON_PLATFORM+=    FreeBSD-*-x86_64
+BROKEN_EXCEPT_ON_PLATFORM+=    NetBSD-*-aarch64
+BROKEN_EXCEPT_ON_PLATFORM+=    NetBSD-*-x86_64
+BROKEN_EXCEPT_ON_PLATFORM+=    SunOS-*-x86_64
+
+# We are going to do a PIE build on our responsibility. Do not put -pie in
+# wrappers, as that would prevent us from building stage-1 compiler.
+PKGSRC_OVERRIDE_MKPIE= yes
+
+.include "options.mk"
+
+
+# -----------------------------------------------------------------------------
+# Distfiles
+#
+DISTFILES=     ${DEFAULT_DISTFILES}
+WRKSRC=                ${WRKDIR}/${PKGNAME_NOREV}
+
+# We don't want to extract all of the DISTFILEs.
+EXTRACT_ONLY=  ${DEFAULT_DISTFILES}
+
+
+# -----------------------------------------------------------------------------
+# Tools
+#
+USE_TOOLS+=                    autoconf gmake
+GNU_CONFIGURE=                 yes
+USE_GNU_CONFIGURE_HOST=                no
+USE_LIBTOOL=                   yes
+
+
+# -----------------------------------------------------------------------------
+# Configuration
+#
+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-ffi-includes=${BUILDLINK_PREFIX.libffi}/${BUILDLINK_INCDIRS.libffi:Q} \
+       --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).
+CONFIGURE_ENV+=                ac_cv_prog_fp_prog_ar=${AR:Q}
+CONFIGURE_ENV+=                ac_cv_prog_LIBTOOL=libtool
+CONFIGURE_ARGS.common+=        LD=${LD:Q}
+
+CONFIGURE_ARGS+=       ${CONFIGURE_ARGS.common}
+CONFIGURE_ARGS+=       --with-system-libffi
+
+# CFLAGS and LDFLAGS are 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 use of internal variable in mk/bsd.prefs.mk is not very satisfying,
+# but the current infrastructure does not export a public variable
+# indicating whether a PIE build is requested or not. Note that we can't
+# build stage-1 compiler as PIE, because our bootkit libraries aren't
+# necessarily built as PIC.
+.for stage in 0 1 2
+.  if ${stage} == 0
+CONFIGURE_ENV+=        CONF_CC_OPTS_STAGE${stage}=${CFLAGS:M*:Q}
+.  else
+CONFIGURE_ENV+=        CONF_HC_OPTS_STAGE${stage}=-fPIC\ -pie
+CONFIGURE_ENV+=        CONF_CC_OPTS_STAGE${stage}=${CFLAGS:M*:Q}\ -fPIC
+.  endif
+.endfor
+
+
+# -----------------------------------------------------------------------------
+# Security
+#
+# The runtime system of GHC (rts) has a mechanism called "RTS linker" whose
+# job is to load and execute *static* objects (.a and .o files) at run
+# time. It cannot survive PaX MPROTECT because preloadObjectFile() in
+# rts/linker.c tries to mmap pages with w+x. It doesn't play nice with ASLR
+# either because mmapForLinker() in rts/linker.c wants to always mmap pages
+# in the lower 32-bit area on 64-bit platforms.
+#
+# Luckily for us, the RTS linker is only used when the GHC executable (or
+# any user programs which uses GHC API as an interpreter, not a compiler)
+# is statically linked, which is no longer the case except for ghc-iserv
+# and ghc-iesrv-prof. They are launched when ghci is started with
+# -fexternal-interpreter without -dynamic, and their purpose is to run
+# non-PIC code from within a dynamically linked ghci using the evil RTS
+# linker.
+.for f in ghc-iserv ghc-iserv-prof
+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 "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.
+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
+
+# SplitSections is only enabled by default on platforms with GNU ld. On SunOS,
+# whose ld is not the GNU one, it can however be used as well.
+.if ${OPSYS} == "SunOS"
+       ${RUN} ${ECHO} "SplitSections  = YES" >> ${WRKSRC}/mk/build.mk
+.endif
+
+
+# -----------------------------------------------------------------------------
+# 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
+#
+
+# ghc57207_0.s: failed to add inputs for merge: Resource temporarily unavailable
+# XXX: On which platform? Is it still an issue?
+CTF_FILES_SKIP+=               */libHS*-ghc${PKGVERSION_NOREV}.*
+
+# ld: fatal: relocation error ... relocation requires reference symbol
+# XXX: On which platform? Is it still an issue?
+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 !empty(MACHINE_PLATFORM:MNetBSD-*-x86_64) && 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.
+ALL_ENV+=      LD_LIBRARY_PATH=${PREFIX}/emul/netbsd/usr/lib:${WRKDIR}/lib
+# XXX: ${WRKDIR}/lib is a temporary workaround for compat80 not having
+# libterminfo.so.1. See ./bootstrap.mk
+.endif
+
+# On Solaris-based platforms our bootkit tends to depend on
+# pkgsrc-installed shlibs.
+.if ${OPSYS} == "SunOS"
+ALL_ENV+=      LD_LIBRARY_PATH=${PREFIX}/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"
Index: pkgsrc/lang/ghc92/bootstrap.mk
diff -u /dev/null pkgsrc/lang/ghc92/bootstrap.mk:1.1
--- /dev/null   Sun Feb  6 05:36:16 2022
+++ pkgsrc/lang/ghc92/bootstrap.mk      Sun Feb  6 05:36:15 2022
@@ -0,0 +1,293 @@
+# $NetBSD: bootstrap.mk,v 1.1 2022/02/06 05:36:15 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 9.2.1 requires 8.10 or later to bootstrap.
+# * GHC 9.0.1 requires 8.8 or later to bootstrap.
+# * GHC 8.8.4 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.
+
+.if !empty(MACHINE_PLATFORM:MDarwin-*-x86_64) || make(distinfo) || make (makesum) || make(mdi)
+BOOT_VERSION:= 9.0.1
+BOOT_ARCHIVE:= ghc-${BOOT_VERSION}-boot-x86_64-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:= 9.0.1
+BOOT_ARCHIVE:= ghc-${BOOT_VERSION}-boot-i386-unknown-freebsd.tar.xz
+DISTFILES:=    ${DISTFILES} ${BOOT_ARCHIVE} # Available in LOCAL_PORTS
+.endif
+
+.if !empty(MACHINE_PLATFORM:MFreeBSD-*-x86_64) || make(distinfo) || make(makesum) || make(mdi)
+BOOT_VERSION:= 9.0.1
+BOOT_ARCHIVE:= ghc-${BOOT_VERSION}-boot-x86_64-unknown-freebsd.tar.xz
+DISTFILES:=    ${DISTFILES} ${BOOT_ARCHIVE} # Available in LOCAL_PORTS
+.endif
+
+.if !empty(MACHINE_PLATFORM:MNetBSD-*-aarch64) || make(distinfo) || make(makesum) || make(mdi)
+# Cross-compiled from x86_64 on a QEMU guest. It took days to compile...
+BOOT_VERSION:= 9.2.1
+BOOT_ARCHIVE:= ghc-${BOOT_VERSION}-boot-aarch64-unknown-netbsd.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.10.4
+BOOT_ARCHIVE:= ghc-${BOOT_VERSION}-boot-x86_64-unknown-netbsd.tar.xz
+DISTFILES:=    ${DISTFILES} ${BOOT_ARCHIVE} # Available in LOCAL_PORTS
+.  if !empty(MACHINE_PLATFORM:MNetBSD-9.99.*-x86_64) || make(distinfo) || make (makesum) || make(mdi)
+# XXX: emulators/compat80 appears to lack libterminfo.so.1 used by
+# this bootkit.
+DISTFILES+=    netbsd-9.0-amd64-libterminfo.tar.gz
+EXTRACT_ONLY+= netbsd-9.0-amd64-libterminfo.tar.gz
+SITES.netbsd-9.0-amd64-libterminfo.tar.gz?=    ${MASTER_SITE_LOCAL}
+.  endif
+.endif
+
+.if !empty(MACHINE_PLATFORM:MSunOS-*-x86_64) || make(distinfo) || make (makesum) || make(mdi)
+BOOT_VERSION:=         8.10.4
+BOOT_ARCHIVE:=         ghc-${BOOT_VERSION}-boot-x86_64-unknown-solaris2.tar.xz
+SITES.${BOOT_ARCHIVE}= https://us-east.manta.joyent.com/pkgsrc/public/pkg-bootstraps/
+DISTFILES:=            ${DISTFILES} ${BOOT_ARCHIVE}
+.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
+
+# Current bootstrap binary kit for SunOS is built with GNU libiconv
+# and ncurses6.
+.if !empty(MACHINE_PLATFORM:MSunOS-*)
+BUILD_DEPENDS+=        libiconv>=1.9.1:../../converters/libiconv
+BUILD_DEPENDS+=        ncurses>=6.0:../../devel/ncurses
+.endif
+
+.if ${OPSYS} == "SunOS" && ${OS_VARIANT:U} == "OmniOS"
+# Also cpp is missing from /usr/bin. Why? This leads
+# ${WRKSRC}/libffi/configure to fail.
+TOOLS_PLATFORM.cpp=    /usr/lib/cpp
+.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 cpp
+
+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}/bootkit-dist
+       ${RUN}cd ${WRKDIR}/bootkit-dist && \
+               ${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}/bootkit-dist/ghc-${BOOT_VERSION}-boot && \
+               ${PKGSRC_SETENV} ${CONFIGURE_ENV} ${SH} ./configure \
+                       --prefix=${TOOLS_DIR:Q} ${CONFIGURE_ARGS.boot} && \
+               ${PKGSRC_SETENV} ${MAKE_ENV} ${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}"
+# <hack>
+#   We are going to use a static libffi.a, but libffi bundled with GHC
+#   doesn't have patches from pkgsrc which are necessary for
+#   NetBSD/aarch64.
+       ${MKDIR} ${WRKDIR}/build-boot/libffi/build/inst/lib
+       cp -f ${PREFIX:Q}/lib/libffi.a ${WRKDIR}/build-boot/libffi/build/inst/lib/libffi.a
+# </hack>
+       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}"
+       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} "=========================================================================="
Index: pkgsrc/lang/ghc92/buildlink3.mk
diff -u /dev/null pkgsrc/lang/ghc92/buildlink3.mk:1.1
--- /dev/null   Sun Feb  6 05:36:16 2022
+++ pkgsrc/lang/ghc92/buildlink3.mk     Sun Feb  6 05:36:15 2022
@@ -0,0 +1,18 @@
+# $NetBSD: buildlink3.mk,v 1.1 2022/02/06 05:36:15 pho Exp $
+
+BUILDLINK_TREE+=       ghc
+
+.if !defined(GHC_BUILDLINK3_MK)
+GHC_BUILDLINK3_MK:=
+
+BUILDLINK_API_DEPENDS.ghc+=    ghc>=9.2.1
+BUILDLINK_ABI_DEPENDS.ghc+=    ghc>=9.2.1
+BUILDLINK_PKGSRCDIR.ghc?=      ../../lang/ghc92
+
+.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
Index: pkgsrc/lang/ghc92/distinfo
diff -u /dev/null pkgsrc/lang/ghc92/distinfo:1.1
--- /dev/null   Sun Feb  6 05:36:16 2022
+++ pkgsrc/lang/ghc92/distinfo  Sun Feb  6 05:36:15 2022
@@ -0,0 +1,56 @@
+$NetBSD: distinfo,v 1.1 2022/02/06 05:36:15 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
+Size (ghc-8.10.4-boot-x86_64-unknown-netbsd.tar.xz) = 49500236 bytes
+BLAKE2s (ghc-8.10.4-boot-x86_64-unknown-solaris2.tar.xz) = 6374752bf931ebb9908d989f78ae38c62342f8fe14e6357653e32652303b4c9d
+SHA512 (ghc-8.10.4-boot-x86_64-unknown-solaris2.tar.xz) = 3484e865b0b7c3fac4c56cdcee5e42e4579cea6a5fb527a894a9a8eba26a3bd0a691262dfb744c129f2be6bdc1d875756ffbba99fff49e1f19a10a567b4bdb12
+Size (ghc-8.10.4-boot-x86_64-unknown-solaris2.tar.xz) = 64361808 bytes
+BLAKE2s (ghc-9.0.1-boot-i386-unknown-freebsd.tar.xz) = 1dd13bbed8d4b873ccb1bed06706f41093ab616c6a63be8e59dfdfeab0af2b72
+SHA512 (ghc-9.0.1-boot-i386-unknown-freebsd.tar.xz) = f243d2a091dbaa670ecaac913266e428164064e5c73a2d4e96b603f16af94f3c4af4358e01c04d492de8ddd8c4b6d25ebe8b62b929b6191cd87f0f1d13873fde
+Size (ghc-9.0.1-boot-i386-unknown-freebsd.tar.xz) = 48912780 bytes
+BLAKE2s (ghc-9.0.1-boot-x86_64-apple-darwin.tar.xz) = c2b56d049700ce9b5c901ea4d2d2054d6c9d978667439e921529ac94d8c843a6
+SHA512 (ghc-9.0.1-boot-x86_64-apple-darwin.tar.xz) = ab7f8abc94d1e1cf1536c6837ef50ddc741eb057da77c941f645cee3e273ab80f4b0c0e81b189d78b197fb3b93a0815b5ebc02c9adced9c14e13ed4446805cd5
+Size (ghc-9.0.1-boot-x86_64-apple-darwin.tar.xz) = 57580500 bytes
+BLAKE2s (ghc-9.0.1-boot-x86_64-unknown-freebsd.tar.xz) = 4957b6df3c21773d16477ff2d9fc6c4d41e3dee574a39d4672677cbea4f1aa64
+SHA512 (ghc-9.0.1-boot-x86_64-unknown-freebsd.tar.xz) = 01b196eca0a23b64687cb795601ca02a409ea0a1b2db48f5b9ab90a95a1db05a254ac92db43726f15382f4cc9e54052685959467a2925fb67ebe5f68570c1eca
+Size (ghc-9.0.1-boot-x86_64-unknown-freebsd.tar.xz) = 49644112 bytes
+BLAKE2s (ghc-9.2.1-boot-aarch64-unknown-netbsd.tar.xz) = a8b619b3bf7aa28dbbcc3f9a61fb7af6080b5f9e479cdaca1a9c8e343761f2f3
+SHA512 (ghc-9.2.1-boot-aarch64-unknown-netbsd.tar.xz) = 80692415f9380219bbd9aa70fda152f2b8d7dc6e5b296fae1afeac513c52a4485c188304c9a013390de1cf91c42baa300c624eae7c4ed2321428dd507dd7f9d0
+Size (ghc-9.2.1-boot-aarch64-unknown-netbsd.tar.xz) = 63303064 bytes
+BLAKE2s (ghc-9.2.1-src.tar.xz) = 87ee26a40458eb0ff543a7a421e3a58e7c957151ee56d41e8e7b8061568e05b6
+SHA512 (ghc-9.2.1-src.tar.xz) = 1a951939ee3caf046f73fdc667f7b0b0c02c75aca7217c639433b97ac1c8278ed65ab6535a5b9be8f3e1db5cd590253d5ee98d5dcea2372645720e050df39df0
+Size (ghc-9.2.1-src.tar.xz) = 23338772 bytes
+BLAKE2s (netbsd-9.0-amd64-libterminfo.tar.gz) = cf57e942d3331df269d8668bc09c59e8a81fbdfa5bb6c671d758d367a23c84ce
+SHA512 (netbsd-9.0-amd64-libterminfo.tar.gz) = 79288d44b84df8848afc2cdfee628cc4fd1ec0334159403ef8ba994d617bc56a7114af3031198afb5f3b8f45c0463a848099431e32bc6725042908576b6f95b8
+Size (netbsd-9.0-amd64-libterminfo.tar.gz) = 27744 bytes
+SHA1 (patch-compiler_GHC_Driver_Pipeline.hs) = cc2c53f14420b8b75bd70b73e2c95bb52a10cd0c
+SHA1 (patch-compiler_GHC_SysTools_Process.hs) = d9aaed0da037cb87090350951b916d13274c5860
+SHA1 (patch-configure.ac) = 19d3ede0cc2ffcf9a44852a6d11f4a0858646f0f
+SHA1 (patch-ghc.mk) = fdcbc5b0c48b616eb96868e49681536d773eaddd
+SHA1 (patch-ghc_ghc-bin.cabal.in) = 3d5bff8657824b2fa2371a6a90c9aa07b1562331
+SHA1 (patch-ghc_ghc.mk) = d459e55ff966fa4b5f344cae3338e54151967103
+SHA1 (patch-libraries_Cabal_Cabal_src_Distribution_Simple_GHC.hs) = a8b2eeec9a469b43e611f79fbf5b080c1e05aa50
+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_base_configure) = 4e02082cdfde8d927d12f3d2f3d98ace6d4ee116
+SHA1 (patch-libraries_time_lib_Data_Time_Clock_Internal_CTimespec.hsc) = 588270767f8a9cbde0648fc99807891fef65d721
+SHA1 (patch-libraries_time_lib_Data_Time_Clock_Internal_CTimeval.hs) = 68914d012a98cc4a4a245efeabcb9143dba0246a
+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) = 560c6e9b644687fad62e380f73f08359c48639a2
+SHA1 (patch-llvm-targets) = cba672c60c9cb84e0347a3cd6e8770306542e5d8
+SHA1 (patch-m4_find__llvm__prog.m4) = 7d7497f6016f98383f4cd6f354f195ce405f9e39
+SHA1 (patch-m4_fptools__set__c__ld__flags.m4) = 2d37b779d662e66521d2b5fda994174c9dfcbc29
+SHA1 (patch-mk_config.mk.in) = 84b7b6461b895ada8f4cebb0222f050107616947
+SHA1 (patch-rts_ProfHeap.c) = fafbb740ee87949da12749834478769548322993
+SHA1 (patch-rts_ghc.mk) = 6e3daf71fb7e656131aa2aeeb0346c651520216a
+SHA1 (patch-rts_posix_GetTime.c) = 036e09510c893ab8677a2b4add0193e7f811bb82
+SHA1 (patch-rts_posix_OSThreads.c) = 8f88fb2ae7caa910986aba9e1fba75ef564d0e15
+SHA1 (patch-rules_build-package-way.mk) = ec73df0bbc85e962f76a9068683879a1a1ba1815
+SHA1 (patch-rules_distdir-way-opts.mk) = a058c6428faf02ef94aab3336d2d2874f2726f4e
+SHA1 (patch-utils_ghc-cabal_ghc.mk) = c2d2a6ca42f30a05baf4125e3e01f0ba2989f773
+SHA1 (patch-utils_haddock_driver_Main.hs) = 26b015d3aef9fdff66e66c8e3d9a370a2dbd7067
Index: pkgsrc/lang/ghc92/options.mk
diff -u /dev/null pkgsrc/lang/ghc92/options.mk:1.1
--- /dev/null   Sun Feb  6 05:36:16 2022
+++ pkgsrc/lang/ghc92/options.mk        Sun Feb  6 05:36:15 2022
@@ -0,0 +1,65 @@
+# $NetBSD: options.mk,v 1.1 2022/02/06 05:36:15 pho Exp $
+
+PKG_OPTIONS_VAR=       PKG_OPTIONS.ghc
+
+.include "../../mk/bsd.prefs.mk"
+
+# GHC has a native implementation of codegen (NCG) for some platforms. On
+# those platforms LLVM is optional. It's a requirement anywhere else. See
+# compiler/GHC/Driver/Backend.hs
+#
+# The LLVM backend tends to produce slightly faster code than what NCG
+# produces, but it is much slower than NCG. It is therefore not the default
+# backend on platforms where NCG is available. On platforms where NCG is
+# available, LLVM should be disabled by default because it's a huge
+# dependency that takes hours to compile.
+#
+# Note that bootkits also require LLVM/Clang on platforms lacking NCG. This
+# can cause a transitional problem when a new compiler arrives with NCG for
+# a platform which used to lack one. In this case we have to either (1)
+# build a new bootkit for the platform with LLVM backend disabled, or (2)
+# reuse the old bootkit by putting llvm/clang in BUILD_DEPENDS (regardless
+# of user choice) and arrange parameters so that they are used only by the
+# stage-0 compiler. We don't have an infrastructure for (2), as it's not
+# worth the additional complexity, so (1) is the only option atm.
+
+GHC_NCG_SUPPORTED=     aarch64 i386 x86_64 powerpc powerpc64 sparc
+.if !empty(GHC_NCG_SUPPORTED:M${MACHINE_ARCH})
+PKG_SUPPORTED_OPTIONS+=        llvm
+GHC_LLVM_REQUIRED=     no
+.else
+GHC_LLVM_REQUIRED=     yes
+.endif
+
+.if !empty(PKG_SUPPORTED_OPTIONS)
+.  include "../../mk/bsd.options.mk"
+.endif
+
+.if !empty(PKG_OPTIONS:Mllvm) || ${GHC_LLVM_REQUIRED} == "yes"
+DEPENDS+=              llvm-[0-9]*:../../lang/llvm
+CONFIGURE_ARGS.common+=        LLC=${PREFIX:Q}/bin/llc
+CONFIGURE_ARGS.common+=        OPT=${PREFIX:Q}/bin/opt
+
+# When we use the LLVM backend, we *have* to use Clang's integrated
+# assembler because llc emits assembly source files incompatible with
+# Binutils < 2.36 (see https://reviews.llvm.org/D97448). It also requires
+# Clang on Darwin (see runClang in compiler/GHC/SysTools/Tasks.hs).
+DEPENDS+=              clang-[0-9]*:../../lang/clang
+CONFIGURE_ARGS.common+=        CLANG=${PREFIX:Q}/bin/clang
+CONFIGURE_ARGS.common+=        CC=${PREFIX:Q}/bin/clang
+
+# Maybe GHC doesn't like this but it's the only option available to us.
+LLVM_VERSION_CMD=      ${PKG_INFO} -E llvm | ${SED} -E 's/^llvm-([0-9]*)\..*/\1/'
+LLVM_MAX_VERSION_CMD=  ${EXPR} ${LLVM_VERSION_CMD:sh} + 1
+SUBST_CLASSES+=                llvm
+SUBST_STAGE.llvm=      post-extract
+SUBST_MESSAGE.llvm=    Modifying configure.ac to accept whichever version of LLVM installed via pkgsrc
+SUBST_FILES.llvm=      configure.ac
+SUBST_SED.llvm=                -e 's/LlvmMaxVersion=[0-9]*/LlvmMaxVersion=${LLVM_MAX_VERSION_CMD:sh}/'
+
+.else
+CONFIGURE_ARGS.common+=        LLC=${FALSE:Q}
+CONFIGURE_ARGS.common+=        OPT=${FALSE:Q}
+CONFIGURE_ARGS.common+=        CLANG=${FALSE:Q}
+CONFIGURE_ARGS.common+=        CC=${CC:Q}
+.endif

Index: pkgsrc/lang/ghc92/files/bootstrap.build.mk
diff -u /dev/null pkgsrc/lang/ghc92/files/bootstrap.build.mk:1.1
--- /dev/null   Sun Feb  6 05:36:16 2022
+++ pkgsrc/lang/ghc92/files/bootstrap.build.mk  Sun Feb  6 05:36:16 2022
@@ -0,0 +1,42 @@
+# -*- 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
+
+# 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-tree GMP to be statically linked as it increases
+# the bindist size. Dynamic linkage is even worse.
+BIGNUM_BACKEND     = native
+
+# 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
+
+# The build system attempts to link GHC with threaded event-logging RTS by
+# default, which fails because we only build "vanilla" RTS.
+ghc_stage1_CONFIGURE_OPTS += -f-threaded -f-eventlog
+ghc_stage2_CONFIGURE_OPTS += -f-threaded -f-eventlog
+ghc_stage3_CONFIGURE_OPTS += -f-threaded -f-eventlog
+
+# 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

Index: pkgsrc/lang/ghc92/patches/patch-compiler_GHC_Driver_Pipeline.hs
diff -u /dev/null pkgsrc/lang/ghc92/patches/patch-compiler_GHC_Driver_Pipeline.hs:1.1
--- /dev/null   Sun Feb  6 05:36:16 2022
+++ pkgsrc/lang/ghc92/patches/patch-compiler_GHC_Driver_Pipeline.hs     Sun Feb  6 05:36:16 2022
@@ -0,0 +1,19 @@
+$NetBSD: patch-compiler_GHC_Driver_Pipeline.hs,v 1.1 2022/02/06 05:36:16 pho Exp $
+
+Do not use -Xpreprocessor to pass options to CPP. Our tool wrappers
+may remove some of them, and if that happens an unpaired
+-Xpreprocessor will be left behind and confuses CC.
+
+--- compiler/GHC/Driver/Pipeline.hs.orig       2021-05-01 06:52:42.897138372 +0000
++++ compiler/GHC/Driver/Pipeline.hs
+@@ -1293,8 +1293,8 @@ runPhase (RealPhase cc_phase) input_fn d
+         -- (#16737). Doing it in this way is simpler and also enable the C
+         -- compiler to perform preprocessing and parsing in a single pass,
+         -- but it may introduce inconsistency if a different pgm_P is specified.
+-        let more_preprocessor_opts = concat
+-              [ ["-Xpreprocessor", i]
++        let more_preprocessor_opts =
++              [ i
+               | not hcc
+               , i <- getOpts dflags opt_P
+               ]
Index: pkgsrc/lang/ghc92/patches/patch-compiler_GHC_SysTools_Process.hs
diff -u /dev/null pkgsrc/lang/ghc92/patches/patch-compiler_GHC_SysTools_Process.hs:1.1
--- /dev/null   Sun Feb  6 05:36:16 2022
+++ pkgsrc/lang/ghc92/patches/patch-compiler_GHC_SysTools_Process.hs    Sun Feb  6 05:36:16 2022
@@ -0,0 +1,35 @@
+$NetBSD: patch-compiler_GHC_SysTools_Process.hs,v 1.1 2022/02/06 05:36:16 pho Exp $
+
+This is more like pkgsrc-specific than an upstream issue. Unless we
+are on Windows, don't use "response file", the @FILE syntax while
+invoking CC or LD. Our tool wrappers don't look into response files,
+and therefore can't detect mistakes like depending on Cabal packages
+that aren't declared as pkgsrc dependency.
+
+The reason why GHC does it is due to some limitation on the length of
+argv on Windows. So maybe the patch is worth sending to the upstream.
+
+Note that this patch would break GHC if we didn't have its $ORIGIN use
+eliminated because our wrappers hate relative rpaths.
+
+--- compiler/GHC/SysTools/Process.hs.orig      2021-10-28 20:41:34.000000000 +0000
++++ compiler/GHC/SysTools/Process.hs
+@@ -163,6 +163,7 @@ runSomethingResponseFile
+   -> [Option]
+   -> Maybe [(String,String)]
+   -> IO ()
++#if defined(mingw32_HOST_OS)
+ runSomethingResponseFile logger tmpfs dflags filter_fn phase_name pgm args mb_env =
+     runSomethingWith logger dflags phase_name pgm args $ \real_args -> do
+         fp <- getResponseFile real_args
+@@ -205,6 +206,10 @@ runSomethingResponseFile logger tmpfs df
+             x
+         , "\""
+         ]
++#else
++runSomethingResponseFile logger tmpfs dflags filter_fn phase_name pgm args mb_env =
++  runSomethingFiltered logger dflags filter_fn phase_name pgm args Nothing mb_env
++#endif
+ 
+ runSomethingFiltered
+   :: Logger -> DynFlags -> (String->String) -> String -> String -> [Option]
Index: pkgsrc/lang/ghc92/patches/patch-configure.ac
diff -u /dev/null pkgsrc/lang/ghc92/patches/patch-configure.ac:1.1
--- /dev/null   Sun Feb  6 05:36:16 2022
+++ pkgsrc/lang/ghc92/patches/patch-configure.ac        Sun Feb  6 05:36:16 2022
@@ -0,0 +1,82 @@
+$NetBSD: patch-configure.ac,v 1.1 2022/02/06 05:36:16 pho Exp $
+
+Disable DTrace support on solaris2.
+XXX: But why?
+
+--- configure.ac.orig  2022-01-25 09:29:55.257778230 +0000
++++ configure.ac
+@@ -178,13 +178,21 @@ if test "$WithGhc" != ""; then
+   dnl See Note [Linking ghc-bin against threaded stage0 RTS] in
+   dnl hadrian/src/Settings/Packages.hs for details.
+   dnl SMP support which implies a registerised stage0 is also required (see issue 18266)
+-  if echo ${RTS_WAYS_STAGE0} | grep '.*thr.*' 2>&1 >/dev/null && \
++  if echo ${RTS_WAYS_STAGE0} | tr ' ' '\n' | grep '^thr$' 2>&1 >/dev/null && \
+      test "$SUPPORT_SMP_STAGE0" = "YES"
+   then
+       AC_SUBST(GhcThreadedRts, YES)
+   else
+       AC_SUBST(GhcThreadedRts, NO)
+   fi
++
++  dnl Same for an event logging RTS.
++  if echo ${RTS_WAYS_STAGE0} | tr ' ' '\n' | grep '^l$' 2>&1 >/dev/null
++  then
++      AC_SUBST(GhcEventLoggingRts, YES)
++  else
++      AC_SUBST(GhcEventLoggingRts, NO)
++  fi
+ fi
+ 
+ dnl ** Must have GHC to build GHC
+@@ -727,23 +735,23 @@ dnl ------------------------------------
+ dnl ** Copy the files from the "fs" utility into the right folders.
+ dnl --------------------------------------------------------------
+ AC_MSG_NOTICE([Creating links for in-tree file handling routines])
+-ln -f utils/fs/fs.* utils/lndir/
+-ln -f utils/fs/fs.* utils/unlit/
+-ln -f utils/fs/fs.* rts/
+-ln -f utils/fs/fs.h libraries/base/include/
+-ln -f utils/fs/fs.c libraries/base/cbits/
++cp -p utils/fs/fs.* utils/lndir/
++cp -p utils/fs/fs.* utils/unlit/
++cp -p utils/fs/fs.* rts/
++cp -p utils/fs/fs.h libraries/base/include/
++cp -p utils/fs/fs.c libraries/base/cbits/
+ AC_MSG_NOTICE([Routines in place. Packages can now be build normally.])
+ 
+ dnl ** Copy files for ghci wrapper C utilities.
+ dnl --------------------------------------------------------------
+ dnl See Note [Hadrian's ghci-wrapper package] in hadrian/src/Packages.hs
+ AC_MSG_NOTICE([Creating links for ghci wrapper])
+-ln -f driver/utils/getLocation.c driver/ghci/
+-ln -f driver/utils/getLocation.h driver/ghci/
+-ln -f driver/utils/isMinTTY.c driver/ghci/
+-ln -f driver/utils/isMinTTY.h driver/ghci/
+-ln -f driver/utils/cwrapper.c driver/ghci/
+-ln -f driver/utils/cwrapper.h driver/ghci/
++cp -p driver/utils/getLocation.c driver/ghci/
++cp -p driver/utils/getLocation.h driver/ghci/
++cp -p driver/utils/isMinTTY.c driver/ghci/
++cp -p driver/utils/isMinTTY.h driver/ghci/
++cp -p driver/utils/cwrapper.c driver/ghci/
++cp -p driver/utils/cwrapper.h driver/ghci/
+ AC_MSG_NOTICE([done.])
+ 
+ dnl --------------------------------------------------------------
+@@ -870,7 +878,7 @@ if test "x$EnableDtrace" = "xyes"; then
+   if test -n "$DtraceCmd"; then
+     if test "x$TargetOS_CPP-$TargetVendor_CPP" = "xdarwin-apple" \
+       -o "x$TargetOS_CPP-$TargetVendor_CPP" = "xfreebsd-portbld" \
+-      -o "x$TargetOS_CPP-$TargetVendor_CPP" = "xsolaris2-unknown"; then
++      ; then
+       HaveDtrace=YES
+     fi
+   fi
+@@ -1438,6 +1446,7 @@ echo "\
+    Bootstrapping using   : $WithGhc
+       which is version   : $GhcVersion
+       with threaded RTS? : $GhcThreadedRts
++      with eventlog RTS? : $GhcEventLoggingRts
+ "
+ 
+ if test "x$CcLlvmBackend" = "xYES"; then
Index: pkgsrc/lang/ghc92/patches/patch-ghc.mk
diff -u /dev/null pkgsrc/lang/ghc92/patches/patch-ghc.mk:1.1
--- /dev/null   Sun Feb  6 05:36:16 2022
+++ pkgsrc/lang/ghc92/patches/patch-ghc.mk      Sun Feb  6 05:36:16 2022
@@ -0,0 +1,16 @@
+$NetBSD: patch-ghc.mk,v 1.1 2022/02/06 05:36:16 pho Exp $
+
+Use the wrapper scripts for ghc as we can't use the ones from the DESTDIR
+as the libraries are not in the right place yet.
+
+--- ghc.mk.orig        2021-01-25 16:30:28.000000000 +0000
++++ ghc.mk
+@@ -938,7 +938,7 @@ endif
+ 
+ INSTALLED_PACKAGE_CONF=$(DESTDIR)$(topdir)/package.conf.d
+ 
+-ifeq "$(BINDIST) $(CrossCompiling)" "NO YES"
++ifeq "$(BINDIST)" "NO"
+ # when installing ghc-stage2 we can't run target's
+ # 'ghc-pkg' and 'ghc-stage2' but those are needed for registration.
+ INSTALLED_GHC_REAL=$(TOP)/inplace/bin/ghc-stage1
Index: pkgsrc/lang/ghc92/patches/patch-ghc_ghc-bin.cabal.in
diff -u /dev/null pkgsrc/lang/ghc92/patches/patch-ghc_ghc-bin.cabal.in:1.1
--- /dev/null   Sun Feb  6 05:36:16 2022
+++ pkgsrc/lang/ghc92/patches/patch-ghc_ghc-bin.cabal.in        Sun Feb  6 05:36:16 2022
@@ -0,0 +1,30 @@
+$NetBSD: patch-ghc_ghc-bin.cabal.in,v 1.1 2022/02/06 05:36:16 pho Exp $
+
+The stage-0 compiler isn't guaranteed to have an event-logging RTS. Not
+upstreamed yet.
+
+--- ghc/ghc-bin.cabal.in.orig  2022-01-21 03:29:30.605919955 +0000
++++ ghc/ghc-bin.cabal.in
+@@ -29,6 +29,11 @@ Flag threaded
+     Default: True
+     Manual: True
+ 
++Flag eventlog
++    Description: Link the ghc executable against the event-logging RTS
++    Default: True
++    Manual: True
++
+ Executable ghc
+     Default-Language: Haskell2010
+ 
+@@ -91,7 +96,9 @@ Executable ghc
+     if flag(threaded)
+       ghc-options: -threaded
+ 
+-    ghc-options: -eventlog
++    -- Same for GhcEventLoggingRts
++    if flag(eventlog)
++      ghc-options: -eventlog
+ 
+     Other-Extensions:
+         CPP
Index: pkgsrc/lang/ghc92/patches/patch-ghc_ghc.mk
diff -u /dev/null pkgsrc/lang/ghc92/patches/patch-ghc_ghc.mk:1.1
--- /dev/null   Sun Feb  6 05:36:16 2022
+++ pkgsrc/lang/ghc92/patches/patch-ghc_ghc.mk  Sun Feb  6 05:36:16 2022
@@ -0,0 +1,19 @@
+$NetBSD: patch-ghc_ghc.mk,v 1.1 2022/02/06 05:36:16 pho Exp $
+
+The stage-0 compiler isn't guaranteed to have an event-logging RTS. Not
+upstreamed yet.
+
+--- ghc/ghc.mk.orig    2022-01-21 03:38:06.464699891 +0000
++++ ghc/ghc.mk
+@@ -76,6 +76,11 @@ else
+ ghc_stage1_CONFIGURE_OPTS += -f-threaded
+ endif
+ 
++# Same for an event-logging RTS.
++ifeq "$(GhcEventLoggingRts)" "NO"
++ghc_stage1_CONFIGURE_OPTS += -f-eventlog
++endif
++
+ ifeq "$(GhcProfiled)" "YES"
+ ghc_stage2_PROGRAM_WAY = p
+ endif
Index: pkgsrc/lang/ghc92/patches/patch-libraries_Cabal_Cabal_src_Distribution_Simple_GHC.hs
diff -u /dev/null pkgsrc/lang/ghc92/patches/patch-libraries_Cabal_Cabal_src_Distribution_Simple_GHC.hs:1.1
--- /dev/null   Sun Feb  6 05:36:16 2022
+++ pkgsrc/lang/ghc92/patches/patch-libraries_Cabal_Cabal_src_Distribution_Simple_GHC.hs        Sun Feb  6 05:36:16 2022
@@ -0,0 +1,33 @@
+$NetBSD: patch-libraries_Cabal_Cabal_src_Distribution_Simple_GHC.hs,v 1.1 2022/02/06 05:36:16 pho Exp $
+
+Enable Cabal's rpath overriding functionality on all the platforms
+known to use ELF.
+
+When a Cabal package which defines both a library and an executable
+to be built, GHC by default embeds an rpath to the *build* directory
+into the executable. This may sound like a bug in GHC but is actually
+not, because GHC doesn't know the fact that the said library is going
+to be installed elsewhere. To overcome this issue, Cabal has a
+functionality to disable the default rpath handling of GHC and
+construct the correct set of rpaths... but only on certain platforms
+for some reason.
+
+Pull request: https://github.com/haskell/cabal/pull/7382
+
+--- libraries/Cabal/Cabal/src/Distribution/Simple/GHC.hs.orig  2022-01-21 02:23:32.884988700 +0000
++++ libraries/Cabal/Cabal/src/Distribution/Simple/GHC.hs
+@@ -1734,10 +1734,10 @@ getRPaths lbi clbi | supportRPaths hostO
+       case compid of
+         CompilerId GHC ver | ver >= mkVersion [7,10,2] -> True
+         _                                              -> False
+-    supportRPaths OpenBSD     = False
+-    supportRPaths NetBSD      = False
+-    supportRPaths DragonFly   = False
+-    supportRPaths Solaris     = False
++    supportRPaths OpenBSD     = True
++    supportRPaths NetBSD      = True
++    supportRPaths DragonFly   = True
++    supportRPaths Solaris     = True
+     supportRPaths AIX         = False
+     supportRPaths HPUX        = False
+     supportRPaths IRIX        = False
Index: pkgsrc/lang/ghc92/patches/patch-libraries_base_GHC_Event_KQueue.hsc
diff -u /dev/null pkgsrc/lang/ghc92/patches/patch-libraries_base_GHC_Event_KQueue.hsc:1.1
--- /dev/null   Sun Feb  6 05:36:16 2022
+++ pkgsrc/lang/ghc92/patches/patch-libraries_base_GHC_Event_KQueue.hsc Sun Feb  6 05:36:16 2022
@@ -0,0 +1,16 @@
+$NetBSD: patch-libraries_base_GHC_Event_KQueue.hsc,v 1.1 2022/02/06 05:36:16 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
Index: pkgsrc/lang/ghc92/patches/patch-libraries_base_System_CPUTime_Posix_Times.hsc
diff -u /dev/null pkgsrc/lang/ghc92/patches/patch-libraries_base_System_CPUTime_Posix_Times.hsc:1.1
--- /dev/null   Sun Feb  6 05:36:16 2022
+++ pkgsrc/lang/ghc92/patches/patch-libraries_base_System_CPUTime_Posix_Times.hsc       Sun Feb  6 05:36:16 2022
@@ -0,0 +1,16 @@
+$NetBSD: patch-libraries_base_System_CPUTime_Posix_Times.hsc,v 1.1 2022/02/06 05:36:16 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 =
Index: pkgsrc/lang/ghc92/patches/patch-libraries_base_System_Environment.hs
diff -u /dev/null pkgsrc/lang/ghc92/patches/patch-libraries_base_System_Environment.hs:1.1
--- /dev/null   Sun Feb  6 05:36:16 2022
+++ pkgsrc/lang/ghc92/patches/patch-libraries_base_System_Environment.hs        Sun Feb  6 05:36:16 2022
@@ -0,0 +1,23 @@
+$NetBSD: patch-libraries_base_System_Environment.hs,v 1.1 2022/02/06 05:36:16 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
Index: pkgsrc/lang/ghc92/patches/patch-libraries_base_configure
diff -u /dev/null pkgsrc/lang/ghc92/patches/patch-libraries_base_configure:1.1
--- /dev/null   Sun Feb  6 05:36:16 2022
+++ pkgsrc/lang/ghc92/patches/patch-libraries_base_configure    Sun Feb  6 05:36:16 2022
@@ -0,0 +1,18 @@
+$NetBSD: patch-libraries_base_configure,v 1.1 2022/02/06 05:36:16 pho Exp $
+
+Ensure libiconv can be found at runtime.
+
+XXX: I don't think this is needed because rpath flags are handled by
+Cabal. LDFLAGS is not used anyway. (pho@)
+
+--- libraries/base/configure.orig      2021-10-28 20:43:03.000000000 +0000
++++ libraries/base/configure
+@@ -4209,7 +4209,7 @@ fi
+ 
+ # Check whether --with-iconv-libraries was given.
+ if test "${with_iconv_libraries+set}" = set; then :
+-  withval=$with_iconv_libraries; ICONV_LIB_DIRS=$withval; LDFLAGS="-L$withval $LDFLAGS"
++  withval=$with_iconv_libraries; ICONV_LIB_DIRS=$withval; LDFLAGS="-L$withval ${COMPILER_RPATH_FLAG}$withval $LDFLAGS"
+ else
+   ICONV_LIB_DIRS=
+ fi
Index: pkgsrc/lang/ghc92/patches/patch-libraries_time_lib_Data_Time_Clock_Internal_CTimespec.hsc
diff -u /dev/null pkgsrc/lang/ghc92/patches/patch-libraries_time_lib_Data_Time_Clock_Internal_CTimespec.hsc:1.1
--- /dev/null   Sun Feb  6 05:36:16 2022
+++ pkgsrc/lang/ghc92/patches/patch-libraries_time_lib_Data_Time_Clock_Internal_CTimespec.hsc   Sun Feb  6 05:36:16 2022
@@ -0,0 +1,23 @@
+$NetBSD: patch-libraries_time_lib_Data_Time_Clock_Internal_CTimespec.hsc,v 1.1 2022/02/06 05:36:16 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.
Index: pkgsrc/lang/ghc92/patches/patch-libraries_time_lib_Data_Time_Clock_Internal_CTimeval.hs
diff -u /dev/null pkgsrc/lang/ghc92/patches/patch-libraries_time_lib_Data_Time_Clock_Internal_CTimeval.hs:1.1
--- /dev/null   Sun Feb  6 05:36:16 2022
+++ pkgsrc/lang/ghc92/patches/patch-libraries_time_lib_Data_Time_Clock_Internal_CTimeval.hs     Sun Feb  6 05:36:16 2022
@@ -0,0 +1,33 @@
+$NetBSD: patch-libraries_time_lib_Data_Time_Clock_Internal_CTimeval.hs,v 1.1 2022/02/06 05:36:16 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       2021-10-28 20:42:10.000000000 +0000
++++ libraries/time/lib/Data/Time/Clock/Internal/CTimeval.hs
+@@ -1,3 +1,4 @@
++{-# LANGUAGE CApiFFI #-}
+ {-# LANGUAGE Safe #-}
+ 
+ module Data.Time.Clock.Internal.CTimeval where
+@@ -21,7 +22,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
Index: pkgsrc/lang/ghc92/patches/patch-libraries_unix_System_Posix_Env.hsc
diff -u /dev/null pkgsrc/lang/ghc92/patches/patch-libraries_unix_System_Posix_Env.hsc:1.1
--- /dev/null   Sun Feb  6 05:36:16 2022
+++ pkgsrc/lang/ghc92/patches/patch-libraries_unix_System_Posix_Env.hsc Sun Feb  6 05:36:16 2022
@@ -0,0 +1,16 @@
+$NetBSD: patch-libraries_unix_System_Posix_Env.hsc,v 1.1 2022/02/06 05:36:16 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
Index: pkgsrc/lang/ghc92/patches/patch-libraries_unix_System_Posix_Env_ByteString.hsc
diff -u /dev/null pkgsrc/lang/ghc92/patches/patch-libraries_unix_System_Posix_Env_ByteString.hsc:1.1
--- /dev/null   Sun Feb  6 05:36:16 2022
+++ pkgsrc/lang/ghc92/patches/patch-libraries_unix_System_Posix_Env_ByteString.hsc      Sun Feb  6 05:36:16 2022
@@ -0,0 +1,16 @@
+$NetBSD: patch-libraries_unix_System_Posix_Env_ByteString.hsc,v 1.1 2022/02/06 05:36:16 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
Index: pkgsrc/lang/ghc92/patches/patch-libraries_unix_System_Posix_Files_Common.hsc
diff -u /dev/null pkgsrc/lang/ghc92/patches/patch-libraries_unix_System_Posix_Files_Common.hsc:1.1
--- /dev/null   Sun Feb  6 05:36:16 2022
+++ pkgsrc/lang/ghc92/patches/patch-libraries_unix_System_Posix_Files_Common.hsc        Sun Feb  6 05:36:16 2022
@@ -0,0 +1,33 @@
+$NetBSD: patch-libraries_unix_System_Posix_Files_Common.hsc,v 1.1 2022/02/06 05:36:16 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
+ 
Index: pkgsrc/lang/ghc92/patches/patch-libraries_unix_System_Posix_Signals.hsc
diff -u /dev/null pkgsrc/lang/ghc92/patches/patch-libraries_unix_System_Posix_Signals.hsc:1.1
--- /dev/null   Sun Feb  6 05:36:16 2022
+++ pkgsrc/lang/ghc92/patches/patch-libraries_unix_System_Posix_Signals.hsc     Sun Feb  6 05:36:16 2022
@@ -0,0 +1,22 @@
+$NetBSD: patch-libraries_unix_System_Posix_Signals.hsc,v 1.1 2022/02/06 05:36:16 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
Index: pkgsrc/lang/ghc92/patches/patch-libraries_unix_include_execvpe.h
diff -u /dev/null pkgsrc/lang/ghc92/patches/patch-libraries_unix_include_execvpe.h:1.1
--- /dev/null   Sun Feb  6 05:36:16 2022
+++ pkgsrc/lang/ghc92/patches/patch-libraries_unix_include_execvpe.h    Sun Feb  6 05:36:16 2022
@@ -0,0 +1,19 @@
+$NetBSD: patch-libraries_unix_include_execvpe.h,v 1.1 2022/02/06 05:36:16 pho Exp $
+
+Don't conflict with builtin execvpe(3).
+
+Already fixed in the upstream (unix-2.8.0.0).
+
+--- 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
Index: pkgsrc/lang/ghc92/patches/patch-llvm-targets
diff -u /dev/null pkgsrc/lang/ghc92/patches/patch-llvm-targets:1.1
--- /dev/null   Sun Feb  6 05:36:16 2022
+++ pkgsrc/lang/ghc92/patches/patch-llvm-targets        Sun Feb  6 05:36:16 2022
@@ -0,0 +1,17 @@
+$NetBSD: patch-llvm-targets,v 1.1 2022/02/06 05:36:16 pho Exp $
+
+Define the LLVM target for NetBSD/aarch64. This file is generated with
+utils/llvm-targets/gen-data-layout.sh
+
+https://gitlab.haskell.org/ghc/ghc/-/merge_requests/5805
+
+--- llvm-targets.orig  2020-12-21 18:11:39.000000000 +0000
++++ llvm-targets
+@@ -48,6 +48,7 @@
+ ,("amd64-portbld-freebsd", ("e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128", "x86-64", ""))
+ ,("x86_64-unknown-freebsd", ("e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128", "x86-64", ""))
+ ,("aarch64-unknown-freebsd", ("e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128", "generic", "+neon"))
++,("aarch64-unknown-netbsd", ("e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128", "generic", "+neon"))
+ ,("armv6-unknown-freebsd-gnueabihf", ("e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64", "arm1176jzf-s", "+strict-align"))
+ ,("armv7-unknown-freebsd-gnueabihf", ("e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64", "generic", "+strict-align"))
+ ,("arm-unknown-nto-qnx-eabi", ("e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64", "arm7tdmi", "+strict-align"))
Index: pkgsrc/lang/ghc92/patches/patch-m4_find__llvm__prog.m4
diff -u /dev/null pkgsrc/lang/ghc92/patches/patch-m4_find__llvm__prog.m4:1.1
--- /dev/null   Sun Feb  6 05:36:16 2022
+++ pkgsrc/lang/ghc92/patches/patch-m4_find__llvm__prog.m4      Sun Feb  6 05:36:16 2022
@@ -0,0 +1,15 @@
+$NetBSD: patch-m4_find__llvm__prog.m4,v 1.1 2022/02/06 05:36:16 pho Exp $
+
+Abolish the bash-ism. Not upstreamed yet.
+
+--- m4/find_llvm_prog.m4.orig  2022-01-21 02:27:51.508001986 +0000
++++ m4/find_llvm_prog.m4
+@@ -15,7 +15,7 @@ AC_DEFUN([FIND_LLVM_PROG],[
+     AC_CHECK_TOOLS([$1], [$PROG_VERSION_CANDIDATES $2], [])
+     AS_IF([test x"$$1" != x],[
+         PROG_VERSION=`$$1 --version | awk '/.*version [[0-9\.]]+/{for(i=1;i<=NF;i++){ if(\$i ~ /^[[0-9\.]]+$/){print \$i}}}'`
+-        AS_IF([test x"$PROG_VERSION" == x],
++        AS_IF([test x"$PROG_VERSION" = x],
+           [AC_MSG_RESULT(no)
+            $1=""
+            AC_MSG_NOTICE([We only support llvm $3 to $4 (no version found).])],
Index: pkgsrc/lang/ghc92/patches/patch-m4_fptools__set__c__ld__flags.m4
diff -u /dev/null pkgsrc/lang/ghc92/patches/patch-m4_fptools__set__c__ld__flags.m4:1.1
--- /dev/null   Sun Feb  6 05:36:16 2022
+++ pkgsrc/lang/ghc92/patches/patch-m4_fptools__set__c__ld__flags.m4    Sun Feb  6 05:36:16 2022
@@ -0,0 +1,18 @@
+$NetBSD: patch-m4_fptools__set__c__ld__flags.m4,v 1.1 2022/02/06 05:36:16 pho Exp $
+
+Mark the stack as non-executable on NetBSD/aarch64.
+https://gitlab.haskell.org/ghc/ghc/-/merge_requests/5805
+
+--- m4/fptools_set_c_ld_flags.m4.orig  2022-01-21 02:26:18.260679308 +0000
++++ m4/fptools_set_c_ld_flags.m4
+@@ -79,6 +79,10 @@ AC_DEFUN([FPTOOLS_SET_C_LD_FLAGS],
+         $3="$$3 -Wl,-z,noexecstack"
+         $4="$$4 -z noexecstack"
+         ;;
++    aarch64*netbsd*)
++        $3="$$3 -Wl,-z,noexecstack"
++        $4="$$4 -z noexecstack"
++        ;;
+ 
+     powerpc-ibm-aix*)
+         # We need `-D_THREAD_SAFE` to unlock the thread-local `errno`.
Index: pkgsrc/lang/ghc92/patches/patch-mk_config.mk.in
diff -u /dev/null pkgsrc/lang/ghc92/patches/patch-mk_config.mk.in:1.1
--- /dev/null   Sun Feb  6 05:36:16 2022
+++ pkgsrc/lang/ghc92/patches/patch-mk_config.mk.in     Sun Feb  6 05:36:16 2022
@@ -0,0 +1,17 @@
+$NetBSD: patch-mk_config.mk.in,v 1.1 2022/02/06 05:36:16 pho Exp $
+
+The stage-0 compiler isn't guaranteed to have an event-logging RTS. Not
+upstreamed yet.
+
+--- mk/config.mk.in.orig       2022-01-21 03:39:58.330264483 +0000
++++ mk/config.mk.in
+@@ -169,6 +169,9 @@ GhcWithSMP := $(strip $(if $(filter YESN
+ # Whether or not the bootstrapping GHC supplies a threaded RTS.
+ GhcThreadedRts = @GhcThreadedRts@
+ 
++# Whether or not the bootstrapping GHC supplies an event-logging RTS.
++GhcEventLoggingRts = @GhcEventLoggingRts@
++
+ # Whether to include GHCi in the compiler.  Depends on whether the RTS linker
+ # has support for this OS/ARCH combination.
+ 
Index: pkgsrc/lang/ghc92/patches/patch-rts_ProfHeap.c
diff -u /dev/null pkgsrc/lang/ghc92/patches/patch-rts_ProfHeap.c:1.1
--- /dev/null   Sun Feb  6 05:36:16 2022
+++ pkgsrc/lang/ghc92/patches/patch-rts_ProfHeap.c      Sun Feb  6 05:36:16 2022
@@ -0,0 +1,46 @@
+$NetBSD: patch-rts_ProfHeap.c,v 1.1 2022/02/06 05:36:16 pho Exp $
+
+NetBSD does not have uselocale(3).
+
+Sent to the upstream:
+https://gitlab.haskell.org/ghc/ghc/-/merge_requests/5677
+
+--- rts/ProfHeap.c.orig        2021-01-25 16:30:28.000000000 +0000
++++ rts/ProfHeap.c
+@@ -69,7 +69,7 @@ static locale_t prof_locale = 0, saved_l
+ STATIC_INLINE void
+ init_prof_locale( void )
+ {
+-#if !defined(mingw32_HOST_OS)
++#if !defined(mingw32_HOST_OS) && !defined(netbsd_HOST_OS)
+     if (! prof_locale) {
+         prof_locale = newlocale(LC_NUMERIC_MASK, "POSIX", 0);
+         if (! prof_locale) {
+@@ -83,7 +83,7 @@ init_prof_locale( void )
+ STATIC_INLINE void
+ free_prof_locale( void )
+ {
+-#if !defined(mingw32_HOST_OS)
++#if !defined(mingw32_HOST_OS) && !defined(netbsd_HOST_OS)
+     if (prof_locale) {
+         freelocale(prof_locale);
+         prof_locale = 0;
+@@ -98,6 +98,9 @@ set_prof_locale( void )
+     prof_locale_per_thread = _configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
+     saved_locale = setlocale(LC_NUMERIC, NULL);
+     setlocale(LC_NUMERIC, "C");
++#elif defined(netbsd_HOST_OS)
++    saved_locale = setlocale(LC_NUMERIC, NULL);
++    setlocale(LC_NUMERIC, "C");
+ #else
+     saved_locale = uselocale(prof_locale);
+ #endif
+@@ -109,6 +112,8 @@ restore_locale( void )
+ #if defined(mingw32_HOST_OS)
+     _configthreadlocale(prof_locale_per_thread);
+     setlocale(LC_NUMERIC, saved_locale);
++#elif defined(netbsd_HOST_OS)
++    setlocale(LC_NUMERIC, saved_locale);
+ #else
+     uselocale(saved_locale);
+ #endif
Index: pkgsrc/lang/ghc92/patches/patch-rts_ghc.mk
diff -u /dev/null pkgsrc/lang/ghc92/patches/patch-rts_ghc.mk:1.1
--- /dev/null   Sun Feb  6 05:36:16 2022
+++ pkgsrc/lang/ghc92/patches/patch-rts_ghc.mk  Sun Feb  6 05:36:16 2022
@@ -0,0 +1,14 @@
+$NetBSD: patch-rts_ghc.mk,v 1.1 2022/02/06 05:36:16 pho Exp $
+
+This is for Darwin. See the patch to rules/distdir-way-opts.mk.
+
+--- rts/ghc.mk.orig    2021-04-29 03:14:20.000000000 +0000
++++ rts/ghc.mk
+@@ -251,6 +251,7 @@ endif
+ $$(rts_$1_LIB) : $$(rts_$1_OBJS) $$(rts_$1_DTRACE_OBJS) rts/dist/libs.depend $$(rts_dist_FFI_SO)
+       "$$(RM)" $$(RM_OPTS) $$@
+       "$$(rts_dist_HC)" -this-unit-id rts -shared -dynamic -dynload deploy \
++        -dylib-install-name $$(ghclibdir)/rts/$$(rts_$1_LIB_FILE) \
+         -no-auto-link-packages $$(LIBFFI_LIBS) `cat rts/dist/libs.depend` $$(rts_$1_OBJS) \
+           $$(rts_dist_$1_GHC_LD_OPTS) \
+         $$(rts_$1_DTRACE_OBJS) -o $$@
Index: pkgsrc/lang/ghc92/patches/patch-rts_posix_GetTime.c
diff -u /dev/null pkgsrc/lang/ghc92/patches/patch-rts_posix_GetTime.c:1.1
--- /dev/null   Sun Feb  6 05:36:16 2022
+++ pkgsrc/lang/ghc92/patches/patch-rts_posix_GetTime.c Sun Feb  6 05:36:16 2022
@@ -0,0 +1,31 @@
+$NetBSD: patch-rts_posix_GetTime.c,v 1.1 2022/02/06 05:36:16 pho Exp $
+
+OmniOS defines CLOCK_THREAD_CPUTIME_ID but it isn't actually usable:
+clock_gettime(2) always returns EINVAL. Use Solaris-specific
+gethrvtime(3) instead.
+
+Sent to the upstream:
+https://gitlab.haskell.org/ghc/ghc/-/merge_requests/5678
+
+--- rts/posix/GetTime.c.orig   2021-04-29 21:06:04.382045075 +0000
++++ rts/posix/GetTime.c
+@@ -32,6 +32,10 @@
+ #include <mach/mach_port.h>
+ #endif
+ 
++#if defined(solaris2_HOST_OS)
++#include <sys/time.h>
++#endif
++
+ #if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_GETRUSAGE)
+ // we'll implement getProcessCPUTime() and getProcessElapsedTime()
+ // separately, using getrusage() and gettimeofday() respectively
+@@ -81,6 +85,8 @@ Time getCurrentThreadCPUTime(void)
+         sysErrorBelch("getThreadCPUTime");
+         stg_exit(EXIT_FAILURE);
+     }
++#elif defined(solaris2_HOST_OS)
++    return NSToTime(gethrvtime());
+ #elif defined(HAVE_CLOCK_GETTIME)        &&  \
+        defined(CLOCK_PROCESS_CPUTIME_ID) &&  \
+        defined(HAVE_SYSCONF)
Index: pkgsrc/lang/ghc92/patches/patch-rts_posix_OSThreads.c
diff -u /dev/null pkgsrc/lang/ghc92/patches/patch-rts_posix_OSThreads.c:1.1
--- /dev/null   Sun Feb  6 05:36:16 2022
+++ pkgsrc/lang/ghc92/patches/patch-rts_posix_OSThreads.c       Sun Feb  6 05:36:16 2022
@@ -0,0 +1,44 @@
+$NetBSD: patch-rts_posix_OSThreads.c,v 1.1 2022/02/06 05:36:16 pho Exp $
+
+Implementation of getNumberOfProcessors() for NetBSD
+
+Sent to the upstream:
+https://gitlab.haskell.org/ghc/ghc/-/merge_requests/5679
+
+--- rts/posix/OSThreads.c.orig 2021-09-15 15:27:32.000000000 +0000
++++ rts/posix/OSThreads.c
+@@ -25,6 +25,11 @@
+ #if defined(freebsd_HOST_OS) || defined(dragonfly_HOST_OS)
+ #define __BSD_VISIBLE   1
+ #endif
++#if defined(netbsd_HOST_OS)
++/* Inclusion of system headers usually requires _NETBSD_SOURCE on NetBSD,
++ * because of some specific types, like u_char, u_int, etc. */
++#define _NETBSD_SOURCE 1
++#endif
+ #if defined(darwin_HOST_OS)
+ #define _DARWIN_C_SOURCE 1
+ #endif
+@@ -51,7 +56,7 @@
+ #include <string.h>
+ #endif
+ 
+-#if defined(darwin_HOST_OS) || defined(freebsd_HOST_OS)
++#if defined(darwin_HOST_OS) || defined(freebsd_HOST_OS) || defined(netbsd_HOST_OS)
+ #include <sys/types.h>
+ #include <sys/sysctl.h>
+ #endif
+@@ -292,6 +297,13 @@ getNumberOfProcessors (void)
+             if(sysctlbyname("hw.ncpu",&nproc,&size,NULL,0) != 0)
+                 nproc = 1;
+         }
++#elif defined(netbsd_HOST_OS)
++        size_t size = sizeof(uint32_t);
++        if (sysctlbyname("hw.ncpuonline", &nproc, &size, NULL, 0) != 0) {
++            if (sysctlbyname("hw.ncpu", &nproc, &size, NULL, 0) != 0) {
++                nproc = 1;
++            }
++        }
+ #elif defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_ONLN)
+         // N.B. This is the number of physical processors.
+         nproc = sysconf(_SC_NPROCESSORS_ONLN);
Index: pkgsrc/lang/ghc92/patches/patch-rules_build-package-way.mk
diff -u /dev/null pkgsrc/lang/ghc92/patches/patch-rules_build-package-way.mk:1.1
--- /dev/null   Sun Feb  6 05:36:16 2022
+++ pkgsrc/lang/ghc92/patches/patch-rules_build-package-way.mk  Sun Feb  6 05:36:16 2022
@@ -0,0 +1,14 @@
+$NetBSD: patch-rules_build-package-way.mk,v 1.1 2022/02/06 05:36:16 pho Exp $
+
+This is for Darwin. See the patch to rules/distdir-way-opts.mk.
+
+--- rules/build-package-way.mk.orig    2021-04-28 17:51:42.000000000 +0000
++++ rules/build-package-way.mk
+@@ -64,6 +64,7 @@ else # ifneq "$$(TargetOS_CPP)" "mingw32
+ $$($1_$2_$3_LIB) : $$($1_$2_$3_ALL_OBJS) $$(ALL_RTS_LIBS) $$($1_$2_$3_DEPS_LIBS)
+       $$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) $$($1_$2_$3_GHC_LD_OPTS) $$($1_$2_$3_ALL_OBJS) \
+          -shared -dynamic -dynload deploy \
++       -dylib-install-name $$(ghclibdir)/$$($1_$2_COMPONENT_ID)/$$($1_$2_$3_LIB_FILE) \
+        $$(addprefix -l,$$($1_$2_EXTRA_LIBRARIES)) $$(addprefix -L,$$($1_$2_EXTRA_LIBDIRS)) \
+          -no-auto-link-packages \
+          -o $$@
Index: pkgsrc/lang/ghc92/patches/patch-rules_distdir-way-opts.mk
diff -u /dev/null pkgsrc/lang/ghc92/patches/patch-rules_distdir-way-opts.mk:1.1
--- /dev/null   Sun Feb  6 05:36:16 2022
+++ pkgsrc/lang/ghc92/patches/patch-rules_distdir-way-opts.mk   Sun Feb  6 05:36:16 2022
@@ -0,0 +1,27 @@
+$NetBSD: patch-rules_distdir-way-opts.mk,v 1.1 2022/02/06 05:36:16 pho Exp $
+
+Use correct RPATHs. On ELF we replace "$ORIGIN/../{PACKAGE_ID}" with
+the final installation path.
+
+On Darwin library paths work differently. If an executable (or a
+library) A depends on a library B, the installation path of B is first
+embedded in B, and then the path propagates to A at the time when A is
+linked. So we remove -rpath to libraries here, and do the other half
+in rules/build-package-way.mk and rts/ghc.mk.
+
+--- rules/distdir-way-opts.mk.orig     2020-07-08 16:43:04.000000000 +0000
++++ rules/distdir-way-opts.mk
+@@ -209,11 +209,10 @@ ifneq "$4" "0"
+ ifeq "$$(TargetElf)" "YES"
+ $1_$2_$3_GHC_LD_OPTS += \
+     -fno-use-rpaths \
+-    $$(foreach d,$$($1_$2_TRANSITIVE_DEP_COMPONENT_IDS),-optl-Wl$$(comma)-rpath -optl-Wl$$(comma)'$$$$ORIGIN/../$$d') -optl-Wl,-zorigin
++    $$(foreach d,$$($1_$2_TRANSITIVE_DEP_COMPONENT_IDS),-optl-Wl$$(comma)-rpath -optl-Wl$$(comma)$$(ghclibdir)/$$d)
+ else ifeq "$$(TargetOS_CPP)" "darwin"
+ $1_$2_$3_GHC_LD_OPTS += \
+-    -fno-use-rpaths \
+-    $$(foreach d,$$($1_$2_TRANSITIVE_DEP_COMPONENT_IDS),-optl-Wl$$(comma)-rpath -optl-Wl$$(comma)'@loader_path/../$$d')
++    -fno-use-rpaths
+ endif
+ endif
+ endif
Index: pkgsrc/lang/ghc92/patches/patch-utils_ghc-cabal_ghc.mk
diff -u /dev/null pkgsrc/lang/ghc92/patches/patch-utils_ghc-cabal_ghc.mk:1.1
--- /dev/null   Sun Feb  6 05:36:16 2022
+++ pkgsrc/lang/ghc92/patches/patch-utils_ghc-cabal_ghc.mk      Sun Feb  6 05:36:16 2022
@@ -0,0 +1,15 @@
+$NetBSD: patch-utils_ghc-cabal_ghc.mk,v 1.1 2022/02/06 05:36:16 pho Exp $
+
+Fix a bootstrapping issue. Already fixed in the upstream:
+https://gitlab.haskell.org/ghc/ghc/-/merge_requests/6882
+
+--- utils/ghc-cabal/ghc.mk.orig        2022-01-30 08:08:36.680388512 +0000
++++ utils/ghc-cabal/ghc.mk
+@@ -60,6 +60,7 @@ $(ghc-cabal_DIST_BINARY): $(CABAL_LEXER_
+              $(addprefix -optc, $(SRC_CC_OPTS) $(CONF_CC_OPTS_STAGE0)) \
+              $(addprefix -optl, $(SRC_LD_OPTS) $(CONF_GCC_LINKER_OPTS_STAGE0)) \
+                                -O0 \
++                               -XHaskell2010 \
+              -hide-all-packages \
+              -package-env - \
+              $(addprefix -package , $(CABAL_BUILD_DEPS)) \
Index: pkgsrc/lang/ghc92/patches/patch-utils_haddock_driver_Main.hs
diff -u /dev/null pkgsrc/lang/ghc92/patches/patch-utils_haddock_driver_Main.hs:1.1
--- /dev/null   Sun Feb  6 05:36:16 2022
+++ pkgsrc/lang/ghc92/patches/patch-utils_haddock_driver_Main.hs        Sun Feb  6 05:36:16 2022
@@ -0,0 +1,19 @@
+$NetBSD: patch-utils_haddock_driver_Main.hs,v 1.1 2022/02/06 05:36:16 pho Exp $
+
+Workaround for haddock dying when the locale isn't "*.UTF-8". Of course
+this isn't a real fix. Haddock is very fragile when it comes to locale
+setting, and fixing it properly would be seriously a lot of work.
+
+--- utils/haddock/driver/Main.hs.orig  2020-07-28 17:05:24.000000000 +0000
++++ utils/haddock/driver/Main.hs
+@@ -1,7 +1,9 @@
+ module Main where
+ 
+ import Documentation.Haddock (haddock)
++import GHC.IO.Encoding (setLocaleEncoding, utf8)
+ import GHC.ResponseFile (getArgsWithResponseFiles)
+ 
+ main :: IO ()
+-main = getArgsWithResponseFiles >>= haddock
++main = do setLocaleEncoding utf8
++          getArgsWithResponseFiles >>= haddock



Home | Main Index | Thread Index | Old Index