From 9f20171a0cee23743325d2a7e345bda548b05535 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Tue, 29 Dec 2020 21:03:27 +0100 Subject: [PATCH] Add disabled recipe for ghc 8.6. Help is needed to rebase one part of the patch (I don't know enough about Haskell to do it myself) --- dev-lang/ghc/ghc8.6-8.6.5.recipe | 152 +++++++++++++++++ dev-lang/ghc/patches/ghc-8.6.5.patchset | 208 ++++++++++++++++++++++++ 2 files changed, 360 insertions(+) create mode 100644 dev-lang/ghc/ghc8.6-8.6.5.recipe create mode 100644 dev-lang/ghc/patches/ghc-8.6.5.patchset diff --git a/dev-lang/ghc/ghc8.6-8.6.5.recipe b/dev-lang/ghc/ghc8.6-8.6.5.recipe new file mode 100644 index 000000000..86d6080da --- /dev/null +++ b/dev-lang/ghc/ghc8.6-8.6.5.recipe @@ -0,0 +1,152 @@ +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="4d4aa1e96f4001b934ac6193ab09af5d6172f41f5a5d39d8e43393b9aafee361" +PATCHES="ghc-8.6.5.patchset" + +# Disabled because this patch from 8.2.2 has not been applied: +# +#--- a/libraries/directory/System/Directory.hs +#+++ b/libraries/directory/System/Directory.hs +#@@ -1872,6 +1872,9 @@ getAppUserDataDirectory appName = do +# #if defined(mingw32_HOST_OS) +# s <- Win32.sHGetFolderPath nullPtr Win32.cSIDL_APPDATA nullPtr 0 +# return (s++'\\':appName) +#+#elif defined(haiku_HOST_OS) +#+ path <- getEnv "HOME" +#+ return (path ++ "/config/settings/" ++ appName) +# #else +# path <- getEnv "HOME" +# return (path++'/':'.':appName) +# +# Anyone with some Haskell knowledge is welcome to provide an update of this +# patch to the code in Haskell 8.2 (it has been refactored, the patch does not +# apply directly) +# +# Without this patch, Haskell apps would put their settings at the wrong place, +# including Cabal, which is annoying and will result in some confusion. +ARCHITECTURES="!x86" +SECONDARY_ARCHITECTURES="!x86" + +GLOBAL_WRITABLE_FILES=" + settings/ghc directory keep-old + " + +PROVIDES=" + ghc78$secondaryArchSuffix = $portVersion + cmd:ghc = $portVersion compat >= 8.6 + 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.2.2 + cmd:ghc_pkg_8.2.2 + 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.2.2 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.6.5.patchset b/dev-lang/ghc/patches/ghc-8.6.5.patchset new file mode 100644 index 000000000..0e4c2909c --- /dev/null +++ b/dev-lang/ghc/patches/ghc-8.6.5.patchset @@ -0,0 +1,208 @@ +From 42a9f63ce53434e9e3cab7a34f51c76500b394e3 Mon Sep 17 00:00:00 2001 +From: Adrien Destugues +Date: Tue, 29 Dec 2020 20:55:22 +0100 +Subject: Import patch from ghc 8.2. + + +diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs +index 92e3455..d735a14 100644 +--- a/compiler/main/DriverPipeline.hs ++++ b/compiler/main/DriverPipeline.hs +@@ -2163,6 +2163,9 @@ joinObjectFiles dflags o_files output_fn = do + then [SysTools.Option "-no-pie"] + else []) + ++ ++ (if osInfo == OSHaiku ++ then [SysTools.Option "-r"] ++ else []) + ++ (if any (cc ==) [Clang, AppleClang, AppleClang51] + then [] + else [SysTools.Option "-nodefaultlibs"]) +diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs +index 5391326..3ba7947 100644 +--- a/compiler/main/DynFlags.hs ++++ b/compiler/main/DynFlags.hs +@@ -4325,6 +4325,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 bbdf747..28068d5 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -678,11 +678,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 -v utils/fs/fs.* utils/lndir/ +-ln -f -v utils/fs/fs.* utils/unlit/ +-ln -f -v utils/fs/fs.* rts/ +-ln -f -v utils/fs/fs.h libraries/base/include/ +-ln -f -v 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 -------------------------------------------------------------- +@@ -1217,7 +1217,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/InstallDirs.hs b/libraries/Cabal/Cabal/Distribution/Simple/InstallDirs.hs +index e63ea73..3ec304b 100644 +--- a/libraries/Cabal/Cabal/Distribution/Simple/InstallDirs.hs ++++ b/libraries/Cabal/Cabal/Distribution/Simple/InstallDirs.hs +@@ -190,6 +190,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 +@@ -209,17 +210,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 4933028..4a05d47 100644 +--- a/libraries/Cabal/Cabal/Distribution/Simple/PreProcess.hs ++++ b/libraries/Cabal/Cabal/Distribution/Simple/PreProcess.hs +@@ -622,6 +622,7 @@ platformDefines lbi = + OpenBSD -> ["openbsd"] + NetBSD -> ["netbsd"] + DragonFly -> ["dragonfly"] ++ Haiku -> ["haiku"] + Solaris -> ["solaris2"] + AIX -> ["aix"] + HPUX -> ["hpux"] +diff --git a/libraries/Cabal/Cabal/Distribution/System.hs b/libraries/Cabal/Cabal/Distribution/System.hs +index ea1ae0d..2572522 100644 +--- a/libraries/Cabal/Cabal/Distribution/System.hs ++++ b/libraries/Cabal/Cabal/Distribution/System.hs +@@ -80,7 +80,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 + -- +@@ -93,7 +93,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 +@@ -108,7 +108,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 +@@ -120,6 +120,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/rts/LinkerInternals.h b/rts/LinkerInternals.h +index b48fc75..fa9c1fd 100644 +--- a/rts/LinkerInternals.h ++++ b/rts/LinkerInternals.h +@@ -337,7 +337,7 @@ char *cstring_from_section_name( + || 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/linker/Elf.c b/rts/linker/Elf.c +index ede0482..73f6c44 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 5058f03..47a436c 100644 +--- a/rts/posix/OSMem.c ++++ b/rts/posix/OSMem.c +@@ -245,6 +245,10 @@ my_mmap (void *addr, W_ size, int operation) + // See Trac #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 dbfd4be..49e04ae 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 +