Add recipe for ghc 8.10

Finally we are up to date with the latest version of ghc!
This commit is contained in:
Adrien Destugues
2021-01-02 20:01:28 +01:00
parent b642e36f55
commit 7c0aa72549
3 changed files with 419 additions and 1 deletions

View File

@@ -0,0 +1,131 @@
SUMMARY="The Glasgow Haskell Compiler"
DESCRIPTION="
The Glorious Glasgow Haskell Compilation system (GHC) is a compiler for Haskell.
Haskell is \"the\" standard lazy functional programming language.
"
HOMEPAGE="https://www.haskell.org/ghc/"
COPYRIGHT="The Glasgow Haskell Team"
LICENSE="BSD (3-clause)
GNU LGPL v2.1"
REVISION="1"
SOURCE_URI="https://www.haskell.org/ghc/dist/$portVersion/ghc-$portVersion-src.tar.xz"
SOURCE_DIR="ghc-$portVersion"
CHECKSUM_SHA256="9c573a4621a78723950617c223559bdc325ea6a3409264aedf68f05510b0880b"
PATCHES="ghc-$portVersion.patchset"
ARCHITECTURES="!x86"
SECONDARY_ARCHITECTURES="x86"
GLOBAL_WRITABLE_FILES="
settings/ghc directory keep-old
"
PROVIDES="
ghc78$secondaryArchSuffix = $portVersion
cmd:ghc = $portVersion compat >= 8.10
cmd:ghc_$portVersion
cmd:ghc_pkg
cmd:ghc_pkg_$portVersion
cmd:ghci
cmd:ghci_$portVersion
cmd:haddock
cmd:haddock_ghc_$portVersion
cmd:hp2ps
cmd:hpc
cmd:hsc2hs
cmd:runghc
cmd:runghc_$portVersion
cmd:runhaskell
"
REQUIRES="
haiku$secondaryArchSuffix >= $haikuVersion
lib:libiconv$secondaryArchSuffix
lib:libncursesw$secondaryArchSuffix >= 6
lib:libz$secondaryArchSuffix
"
BUILD_REQUIRES="
haiku${secondaryArchSuffix}_devel >= $haikuVersion
haiku_devel >= $haikuVersion
devel:libgmp$secondaryArchSuffix
devel:libiconv$secondaryArchSuffix
devel:libncursesw$secondaryArchSuffix >= 6
devel:libz$secondaryArchSuffix
docbook_xml_dtd
docbook_xsl_stylesheets
"
BUILD_PREREQUIRES="
cmd:autoconf
cmd:awk
cmd:find
cmd:gcc$secondaryArchSuffix
cmd:ghc_8.6.5
cmd:ghc_pkg_8.6.5
cmd:git
cmd:grep
cmd:ld$secondaryArchSuffix
cmd:make
cmd:patch
cmd:perl
cmd:sed
cmd:sort
cmd:tar
cmd:xsltproc
"
BUILD()
{
# 2. Build GHC using the bootstrap compiler; we create a "dyn" only install
echo "Building GHC proper..."
cat > mk/build.mk <<-EOF
V = 0
GhcLibWays = v dyn
SRC_HC_OPTS = -O -H64m
GhcStage1HcOpts = -O -fasm
GhcStage2HcOpts = -O2 -fasm
GhcHcOpts = -Rghc-timing
GhcLibHcOpts = -O2
DYNAMIC_GHC_PROGRAMS = YES
DYNAMIC_TOO = YES
NoFibWays =
STRIP_CMD = :
EOF
# Workaround for haikuporter bug #207
mkdir -p /system/settings/ghc
cp -r /system/lib/x86/ghc-*/package.conf.d /system/settings/ghc/
export HOME=/boot/home
autoconf
# haikuporter's buildspec confuses GHC, so we omit it, and we can't
# have a gcc2 GHC, so just install directly into $prefix/bin
runConfigure --omit-buildspec --omit-dirs binDir configure --bindir=$prefix/bin GHC=/bin/ghc-8.6.5 CC=/bin/gcc-x86
make $jobArgs
}
INSTALL()
{
export HOME=/boot/home
export GHC_PACKAGE_PATH=$settingsDir/ghc/package.conf.d
ghc-pkg init $GHC_PACKAGE_PATH
unset GHC_PACKAGE_PATH
# 1. Install our new GHC
echo "Installing GHC!"
make install
# 2. Move package.conf.d to settings
sed -i -e '/^PKGCONF=/c\
PKGCONF='"$settingsDir"'/ghc/package.conf.d' $prefix/bin/ghc-pkg-$portVersion
unset GHC_PACKAGE_PATH
# move package.conf.d files to the right place...
mv $libDir/ghc-$portVersion/package.conf.d/*.conf $settingsDir/ghc/package.conf.d/
$prefix/bin/ghc-pkg recache
}

View File

@@ -12,7 +12,7 @@ REVISION="1"
SOURCE_URI="https://www.haskell.org/ghc/dist/$portVersion/ghc-$portVersion-src.tar.xz"
SOURCE_DIR="ghc-$portVersion"
CHECKSUM_SHA256="4d4aa1e96f4001b934ac6193ab09af5d6172f41f5a5d39d8e43393b9aafee361"
PATCHES="ghc-8.6.5.patchset"
PATCHES="ghc-$portVersion.patchset"
ARCHITECTURES="!x86"
SECONDARY_ARCHITECTURES="x86"

View File

@@ -0,0 +1,287 @@
From 64193eeed28f47ae055848f0824bd75dc8e0a822 Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Sat, 2 Jan 2021 17:20:24 +0100
Subject: Import patches from ghc 8.6.5.
diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index 03bb529..3632fd9 100644
--- a/compiler/main/DynFlags.hs
+++ b/compiler/main/DynFlags.hs
@@ -4632,6 +4632,7 @@ default_PIC :: Platform -> [GeneralFlag]
default_PIC platform =
case (platformOS platform, platformArch platform) of
(OSDarwin, ArchX86_64) -> [Opt_PIC]
+ (OSHaiku, _) -> [Opt_PIC]
(OSOpenBSD, ArchX86_64) -> [Opt_PIC] -- Due to PIE support in
-- OpenBSD since 5.3 release
-- (1 May 2013) we need to
diff --git a/configure.ac b/configure.ac
index f706506..4665ed4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -706,11 +706,11 @@ 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 utils/fs/fs.* utils/lndir/
+cp utils/fs/fs.* utils/unlit/
+cp utils/fs/fs.* rts/
+cp utils/fs/fs.h libraries/base/include/
+cp utils/fs/fs.c libraries/base/cbits/
AC_MSG_NOTICE([Routines in place. Packages can now be build normally.])
dnl --------------------------------------------------------------
@@ -1232,7 +1232,7 @@ dnl ** Use MMAP in the runtime linker?
dnl --------------------------------------------------------------
case ${TargetOS} in
- linux|linux-android|freebsd|dragonfly|netbsd|openbsd|kfreebsdgnu|gnu|solaris2)
+ linux|linux-android|freebsd|dragonfly|netbsd|openbsd|kfreebsdgnu|gnu|solaris2|haiku)
RtsLinkerUseMmap=1
;;
darwin|ios|watchos|tvos)
diff --git a/libraries/Cabal/Cabal/Distribution/Simple/GHC.hs b/libraries/Cabal/Cabal/Distribution/Simple/GHC.hs
index abad0b2..d4aae8e 100644
--- a/libraries/Cabal/Cabal/Distribution/Simple/GHC.hs
+++ b/libraries/Cabal/Cabal/Distribution/Simple/GHC.hs
@@ -1730,6 +1730,7 @@ getRPaths lbi clbi | supportRPaths hostOS = do
supportRPaths OpenBSD   = False
supportRPaths NetBSD   = False
supportRPaths DragonFly = False
+ supportRPaths Haiku = True
supportRPaths Solaris = False
supportRPaths AIX = False
supportRPaths HPUX = False
diff --git a/libraries/Cabal/Cabal/Distribution/Simple/InstallDirs.hs b/libraries/Cabal/Cabal/Distribution/Simple/InstallDirs.hs
index da405c6..bbb1f3c 100644
--- a/libraries/Cabal/Cabal/Distribution/Simple/InstallDirs.hs
+++ b/libraries/Cabal/Cabal/Distribution/Simple/InstallDirs.hs
@@ -193,6 +193,7 @@ defaultInstallDirs' False comp userInstall _hasLibs = do
else case buildOS of
Windows -> do windowsProgramFilesDir <- getWindowsProgramFilesDir
return (windowsProgramFilesDir </> "Haskell")
+ Haiku -> return "/boot/system/non-packaged"
_ -> return "/usr/local"
installLibDir <-
case buildOS of
@@ -212,17 +213,22 @@ defaultInstallDirs' False comp userInstall _hasLibs = do
flibdir = "$libdir",
libexecdir = case buildOS of
Windows -> "$prefix" </> "$libname"
+ Haiku -> "$libdir"
_other -> "$prefix" </> "libexec",
includedir = "$libdir" </> "$libsubdir" </> "include",
datadir = case buildOS of
Windows -> "$prefix"
_other -> "$prefix" </> "share",
datasubdir = "$abi" </> "$pkgid",
- docdir = "$datadir" </> "doc" </> "$abi" </> "$pkgid",
- mandir = "$datadir" </> "man",
+ docdir = case buildOS of
+ Haiku -> "$prefix" </> "documentation" </> "ghc"
+ _ -> "$datadir" </> "doc" </> "$abi" </> "$pkgid",
+ mandir = "$docdir" </> "man",
htmldir = "$docdir" </> "html",
haddockdir = "$htmldir",
- sysconfdir = "$prefix" </> "etc"
+ sysconfdir = case buildOS of
+ Haiku -> "boot" </> "home" </> "config" </> "settings"
+ _ -> "$prefix" </> "etc"
}
-- ---------------------------------------------------------------------------
diff --git a/libraries/Cabal/Cabal/Distribution/Simple/PreProcess.hs b/libraries/Cabal/Cabal/Distribution/Simple/PreProcess.hs
index e9dc66b..ed702b9 100644
--- a/libraries/Cabal/Cabal/Distribution/Simple/PreProcess.hs
+++ b/libraries/Cabal/Cabal/Distribution/Simple/PreProcess.hs
@@ -629,6 +629,7 @@ platformDefines lbi =
OpenBSD -> ["openbsd"]
NetBSD -> ["netbsd"]
DragonFly -> ["dragonfly"]
+ Haiku -> ["haiku"]
Solaris -> ["solaris2"]
AIX -> ["aix"]
HPUX -> ["hpux"]
diff --git a/libraries/Cabal/Cabal/Distribution/Simple/Utils.hs b/libraries/Cabal/Cabal/Distribution/Simple/Utils.hs
index 96c8406..ab8c175 100644
--- a/libraries/Cabal/Cabal/Distribution/Simple/Utils.hs
+++ b/libraries/Cabal/Cabal/Distribution/Simple/Utils.hs
@@ -1166,7 +1166,7 @@ createDirectoryIfMissingVerbose verbosity create_parents path0
-- the case that the dir did exist but another process deletes the
-- directory and creates a file in its place before we can check
-- that the directory did indeed exist.
- | isAlreadyExistsError e -> (do
+ | isAlreadyExistsError e || isPermissionError e -> (do
isDir <- doesDirectoryExist dir
unless isDir $ throwIO e
) `catchIO` ((\_ -> return ()) :: IOException -> IO ())
diff --git a/libraries/Cabal/Cabal/Distribution/System.hs b/libraries/Cabal/Cabal/Distribution/System.hs
index c480d24..5d1c07d 100644
--- a/libraries/Cabal/Cabal/Distribution/System.hs
+++ b/libraries/Cabal/Cabal/Distribution/System.hs
@@ -78,7 +78,7 @@ data ClassificationStrictness = Permissive | Compat | Strict
-- ------------------------------------------------------------
-- | These are the known OS names: Linux, Windows, OSX
--- ,FreeBSD, OpenBSD, NetBSD, DragonFly
+-- ,FreeBSD, OpenBSD, NetBSD, DragonFly, Haiku
-- ,Solaris, AIX, HPUX, IRIX
-- ,HaLVM ,Hurd ,IOS, Android,Ghcjs
--
@@ -91,7 +91,7 @@ data ClassificationStrictness = Permissive | Compat | Strict
--
data OS = Linux | Windows | OSX -- tier 1 desktop OSs
| FreeBSD | OpenBSD | NetBSD -- other free Unix OSs
- | DragonFly
+ | DragonFly | Haiku
| Solaris | AIX | HPUX | IRIX -- ageing Unix OSs
| HaLVM -- bare metal / VMs / hypervisors
| Hurd -- GNU's microkernel
@@ -106,7 +106,7 @@ instance NFData OS where rnf = genericRnf
knownOSs :: [OS]
knownOSs = [Linux, Windows, OSX
- ,FreeBSD, OpenBSD, NetBSD, DragonFly
+ ,FreeBSD, OpenBSD, NetBSD, DragonFly, Haiku
,Solaris, AIX, HPUX, IRIX
,HaLVM
,Hurd
@@ -118,6 +118,7 @@ osAliases Permissive Windows = ["mingw32", "win32", "cygwin32"]
osAliases Compat Windows = ["mingw32", "win32"]
osAliases _ OSX = ["darwin"]
osAliases _ Hurd = ["gnu"]
+osAliases _ Haiku = ["haiku"]
osAliases Permissive FreeBSD = ["kfreebsdgnu"]
osAliases Compat FreeBSD = ["kfreebsdgnu"]
osAliases Permissive Solaris = ["solaris2"]
diff --git a/libraries/Cabal/Cabal/Makefile b/libraries/Cabal/Cabal/Makefile
index 4a814fb..be42c92 100644
--- a/libraries/Cabal/Cabal/Makefile
+++ b/libraries/Cabal/Cabal/Makefile
@@ -4,7 +4,7 @@ VERSION=3.2.0.0
KIND=rc
#KIND=cabal-latest
-PREFIX=/usr/local
+PREFIX=/boot/system
HC=ghc
GHCFLAGS=-Wall -threaded
SSH_USER=$(USER)
diff --git a/libraries/Cabal/cabal-install/bootstrap.sh b/libraries/Cabal/cabal-install/bootstrap.sh
index 077d7f4..00aa5a2 100755
--- a/libraries/Cabal/cabal-install/bootstrap.sh
+++ b/libraries/Cabal/cabal-install/bootstrap.sh
@@ -122,7 +122,7 @@ while [ "$#" -gt 0 ]; do
shift;;
"--global")
SCOPE_OF_INSTALLATION="${1}"
- DEFAULT_PREFIX="/usr/local"
+ DEFAULT_PREFIX="/boot/system"
shift;;
"--sandbox")
shift
diff --git a/libraries/directory/System/Directory/Internal/Posix.hsc b/libraries/directory/System/Directory/Internal/Posix.hsc
index ba67480..bea9b74 100644
--- a/libraries/directory/System/Directory/Internal/Posix.hsc
+++ b/libraries/directory/System/Directory/Internal/Posix.hsc
@@ -305,7 +305,11 @@ getXdgDirectoryListFallback xdgDirs =
getAppUserDataDirectoryInternal :: FilePath -> IO FilePath
getAppUserDataDirectoryInternal appName =
+# if defined(haiku_HOST_OS)
+ (\ home -> home <> ("/config/settings/." ++ appName)) <$> getHomeDirectoryInternal
+# else
(\ home -> home <> ('/' : '.' : appName)) <$> getHomeDirectoryInternal
+# endif
getUserDocumentsDirectoryInternal :: IO FilePath
getUserDocumentsDirectoryInternal = getHomeDirectoryInternal
diff --git a/mk/config.mk.in b/mk/config.mk.in
index 57de094..07ae5e0 100644
--- a/mk/config.mk.in
+++ b/mk/config.mk.in
@@ -205,7 +205,7 @@ GhcThreadedRts = @GhcThreadedRts@
# Whether to include GHCi in the compiler. Depends on whether the RTS linker
# has support for this OS/ARCH combination.
-OsSupportsGHCi=$(strip $(patsubst $(TargetOS_CPP), YES, $(findstring $(TargetOS_CPP), mingw32 linux solaris2 freebsd dragonfly netbsd openbsd darwin kfreebsdgnu)))
+OsSupportsGHCi=$(strip $(patsubst $(TargetOS_CPP), YES, $(findstring $(TargetOS_CPP), mingw32 linux solaris2 freebsd dragonfly netbsd openbsd darwin kfreebsdgnu,haiku)))
ArchSupportsGHCi=$(strip $(patsubst $(TargetArch_CPP), YES, $(findstring $(TargetArch_CPP), i386 x86_64 powerpc powerpc64 powerpc64le sparc sparc64 arm aarch64)))
ifeq "$(OsSupportsGHCi)$(ArchSupportsGHCi)" "YESYES"
diff --git a/rts/LinkerInternals.h b/rts/LinkerInternals.h
index 26798f2..b528caf 100644
--- a/rts/LinkerInternals.h
+++ b/rts/LinkerInternals.h
@@ -367,7 +367,7 @@ void freeSegments(ObjectCode *oc);
|| defined(linux_android_HOST_OS) \
|| defined(freebsd_HOST_OS) || defined(kfreebsdgnu_HOST_OS) \
|| defined(dragonfly_HOST_OS) || defined(netbsd_HOST_OS) \
-|| defined(openbsd_HOST_OS) || defined(gnu_HOST_OS)
+|| defined(openbsd_HOST_OS) || defined(gnu_HOST_OS) || defined(haiku_HOST_OS)
# define OBJFORMAT_ELF
# include "linker/ElfTypes.h"
#elif defined(mingw32_HOST_OS)
diff --git a/rts/Task.h b/rts/Task.h
index 17bcbe2..784a380 100644
--- a/rts/Task.h
+++ b/rts/Task.h
@@ -321,7 +321,7 @@ typedef StgWord64 TaskId;
//
#if defined(THREADED_RTS)
INLINE_HEADER TaskId serialiseTaskId (OSThreadId taskID) {
-#if defined(freebsd_HOST_OS) || defined(darwin_HOST_OS)
+#if defined(freebsd_HOST_OS) || defined(darwin_HOST_OS) || defined(haiku_HOST_OS)
// Here OSThreadId is a pthread_t and pthread_t is a pointer, but within
// the process we can still use that pointer value as a unique id.
return (TaskId) (size_t) taskID;
diff --git a/rts/linker/Elf.c b/rts/linker/Elf.c
index be62800..ab4ddf8 100644
--- a/rts/linker/Elf.c
+++ b/rts/linker/Elf.c
@@ -4,7 +4,7 @@
|| defined(linux_android_HOST_OS) \
|| defined(freebsd_HOST_OS) || defined(kfreebsdgnu_HOST_OS) \
|| defined(dragonfly_HOST_OS) || defined(netbsd_HOST_OS) \
-|| defined(openbsd_HOST_OS) || defined(gnu_HOST_OS)
+|| defined(openbsd_HOST_OS) || defined(gnu_HOST_OS) || defined(haiku_HOST_OS)
// It is essential that this is included before any <elf.h> is included. <elf.h>
// defines R_XXX relocations, which would interfere with the COMPAT_R_XXX
diff --git a/rts/posix/OSMem.c b/rts/posix/OSMem.c
index 15f1b62..cfa3846 100644
--- a/rts/posix/OSMem.c
+++ b/rts/posix/OSMem.c
@@ -245,6 +245,10 @@ my_mmap (void *addr, W_ size, int operation)
// See #7500.
ret = linux_retry_mmap(operation, size, ret, addr, prot, flags);
}
+#elif defined(haiku_HOST_OS)
+ // Retry without address constraint
+ if (ret == (void *)-1 && errno == EFAULT)
+ ret = mmap(0, size, prot, MAP_ANON | MAP_PRIVATE, -1, 0);
# endif
if (ret == MAP_FAILED) {
return NULL;
diff --git a/rules/library-path.mk b/rules/library-path.mk
index 9a398ee..8c7801e 100644
--- a/rules/library-path.mk
+++ b/rules/library-path.mk
@@ -15,6 +15,8 @@ ifeq "$(TargetOS_CPP)" "mingw32"
prependLibraryPath = $(error Do not know how to prependLibraryPath on Windows)
else ifeq "$(TargetOS_CPP)" "darwin"
prependLibraryPath = export DYLD_LIBRARY_PATH="$1$${DYLD_LIBRARY_PATH:+:$$DYLD_LIBRARY_PATH}"
+else ifeq "$(TargetOS_CPP)" "haiku"
+prependLibraryPath = export LIBRARY_PATH="$1:$$LIBRARY_PATH"
else
prependLibraryPath = export LD_LIBRARY_PATH="$1$${LD_LIBRARY_PATH:+:$$LD_LIBRARY_PATH}"
endif
--
2.28.0