diff --git a/dev-lang/ghc/ghc8.10-8.10.5.recipe b/dev-lang/ghc/ghc8.10-8.10.5.recipe new file mode 100644 index 000000000..f31d5e449 --- /dev/null +++ b/dev-lang/ghc/ghc8.10-8.10.5.recipe @@ -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="f10941f16e4fbd98580ab5241b9271bb0851304560c4d5ca127e3b0e20e3076f" +PATCHES="ghc-$portVersion.patchset" + +ARCHITECTURES="!x86" +SECONDARY_ARCHITECTURES="!x86" + +GLOBAL_WRITABLE_FILES=" + settings/ghc directory keep-old + " + +PROVIDES=" + ghc8.10$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 +} diff --git a/dev-lang/ghc/patches/ghc-8.10.5.patchset b/dev-lang/ghc/patches/ghc-8.10.5.patchset new file mode 100644 index 000000000..87988fee1 --- /dev/null +++ b/dev-lang/ghc/patches/ghc-8.10.5.patchset @@ -0,0 +1,280 @@ +From e6b43d72b14469dcbd2160e07e538358fc8a2279 Mon Sep 17 00:00:00 2001 +From: Adrien Destugues +Date: Sat, 7 Aug 2021 20:55:40 +0200 +Subject: Port the patches from ghc 8.10.2 + + +diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs +index a811698..c5e3f31 100644 +--- a/compiler/main/DynFlags.hs ++++ b/compiler/main/DynFlags.hs +@@ -4660,6 +4660,7 @@ default_PIC platform = + -- be built with -fPIC. + -- See #15275, #18892 + (OSDarwin, ArchAArch64) -> [Opt_PIC] ++ (OSHaiku, _) -> [Opt_PIC] + (OSLinux, ArchAArch64) -> [Opt_PIC, Opt_ExternalDynamicRefs] + (OSLinux, ArchARM {}) -> [Opt_PIC, Opt_ExternalDynamicRefs] + (OSOpenBSD, ArchX86_64) -> [Opt_PIC] -- Due to PIE support in +diff --git a/configure.ac b/configure.ac +index 4458644..8dd711a 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -727,11 +727,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 -------------------------------------------------------------- +@@ -1302,7 +1302,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 48a1709..342d48e 100644 +--- a/libraries/Cabal/Cabal/Distribution/Simple/GHC.hs ++++ b/libraries/Cabal/Cabal/Distribution/Simple/GHC.hs +@@ -1738,6 +1738,7 @@ getRPaths lbi clbi | supportRPaths hostOS = do + supportRPaths Android = False + supportRPaths Ghcjs = False + supportRPaths Hurd = False ++ supportRPaths Haiku = True + supportRPaths (OtherOS _) = False + -- Do _not_ add a default case so that we get a warning here when a new OS + -- is added. +diff --git a/libraries/Cabal/Cabal/Distribution/Simple/InstallDirs.hs b/libraries/Cabal/Cabal/Distribution/Simple/InstallDirs.hs +index da405c6..7f2d1e8 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,23 @@ 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 ccc35f5..2dc82fb 100644 +--- a/libraries/Cabal/Cabal/Distribution/Simple/Utils.hs ++++ b/libraries/Cabal/Cabal/Distribution/Simple/Utils.hs +@@ -1167,7 +1167,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 89fcb5d..0fb8427 100644 +--- a/libraries/Cabal/Cabal/Distribution/System.hs ++++ b/libraries/Cabal/Cabal/Distribution/System.hs +@@ -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 4769282..a4c3da1 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..504895e 100644 +--- a/libraries/directory/System/Directory/Internal/Posix.hsc ++++ b/libraries/directory/System/Directory/Internal/Posix.hsc +@@ -305,7 +305,12 @@ 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 92d552f..f73bf46 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 946aac1..f9ca948 100644 +--- a/rts/LinkerInternals.h ++++ b/rts/LinkerInternals.h +@@ -379,7 +379,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 cf12ca2..54b3e8c 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 2d043f3..108e316 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 is included. + // 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 6b1a6d3..f69fa05 100644 +--- a/rts/posix/OSMem.c ++++ b/rts/posix/OSMem.c +@@ -246,6 +246,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.30.2 +