diff options
author | Sergei Trofimovich <slyfox@gentoo.org> | 2017-01-16 09:45:51 +0000 |
---|---|---|
committer | Sergei Trofimovich <slyfox@gentoo.org> | 2017-01-16 09:50:00 +0000 |
commit | ef416f3d1295dfc8fb4a0638a3c5f0cab4f9bab2 (patch) | |
tree | 3d1badf2e0dca0f46173cb7bf791fe8904100757 /dev-lang | |
parent | media-video/subliminal: amd64 stable wrt bug #605776 (diff) | |
download | gentoo-ef416f3d1295dfc8fb4a0638a3c5f0cab4f9bab2.tar.gz gentoo-ef416f3d1295dfc8fb4a0638a3c5f0cab4f9bab2.tar.bz2 gentoo-ef416f3d1295dfc8fb4a0638a3c5f0cab4f9bab2.zip |
dev-lang/ghc: bump up to 8.0.2, no KEYWORDS or binaries yet
Package-Manager: Portage-2.3.3, Repoman-2.3.1
Diffstat (limited to 'dev-lang')
-rw-r--r-- | dev-lang/ghc/Manifest | 1 | ||||
-rw-r--r-- | dev-lang/ghc/files/ghc-8.0.1-limit-jN.patch | 50 | ||||
-rw-r--r-- | dev-lang/ghc/files/ghc-8.0.1-par-g0-on-A32.patch | 65 | ||||
-rw-r--r-- | dev-lang/ghc/files/ghc-8.0.1-ww-args-limit.patch | 127 | ||||
-rw-r--r-- | dev-lang/ghc/files/ghc-8.0.1_rc1-cgen-constify.patch | 34 | ||||
-rw-r--r-- | dev-lang/ghc/files/ghc-8.0.2_rc2-old-sphinx.patch | 12 | ||||
-rw-r--r-- | dev-lang/ghc/ghc-8.0.2.ebuild | 653 |
7 files changed, 942 insertions, 0 deletions
diff --git a/dev-lang/ghc/Manifest b/dev-lang/ghc/Manifest index d15ace8f8f07..8fd1e4ecec7b 100644 --- a/dev-lang/ghc/Manifest +++ b/dev-lang/ghc/Manifest @@ -2,6 +2,7 @@ DIST binary-0.7.6.1.tar.gz 47086 SHA256 8f85cafc15be660757878a665d024ce595d4422f DIST ghc-7.10.3-src.tar.bz2 13281867 SHA256 3e29a56a74ed6a74d3ee2a6db9389f2462837da46ca6dce9d2965f9c152f0c15 SHA512 97a8282d8a75399c78d85d6faab7ac253a993dc69f1840358572f1878b8fd1a527c28801e5823c8200b5690e268e4a0c00941945ada13790852c75a83b612c17 WHIRLPOOL 04af6ea2738a1cc9e266efbb0e1b41b70d4cd915b48ca1265fade62b1c56cd51056fd1a82fc14cebc19a0c16782609a991c1a181ebe59574f1a10b4f26ad830d DIST ghc-7.8.4-ia64-CLOSUREs-regenerated.patch.gz 13268 SHA256 3bdff22e654aee6f942d43edf1bf6cf70404c0152c4fcf89276f10d2c4c5b4b9 SHA512 a655713e06324b56f0041edf70837487e296d28e6f3ee35fe116b9938765aaf3469d25e92645e0940655ed3607dff27d3826fe0f995c84e81b51bfc956816e7d WHIRLPOOL d2cb53bdc6debc0278d554168ea3ab22b0fd8314adac81444637278a92d21b766280fedfb4b7d1b4540c7381c7962dec6b13a799ab2fee4d456fe2875d5c6a5b DIST ghc-7.8.4-src.tar.bz2 10600755 SHA256 59e3bd514a1820cc1c03e1808282205c0b8518369acae12645ceaf839e6f114b SHA512 079a53891d8ebd8d9b88da96170e60981608a619f8282e4b7948f35244e99bd87277649ac7fcebc227a61a4d21960db8d5e5b9e92f2c69c82d8d68d7fd0a41d3 WHIRLPOOL a9be7641adbd237ed6e0f644c312e655e98be9566097aee5e2c0022e8756d5b2236e42dd86d76c638a001b5ca3f67307e89ec0cd003a92cd112a5d6d3e3d8467 +DIST ghc-8.0.2-src.tar.xz 10687760 SHA256 11625453e1d0686b3fa6739988f70ecac836cadc30b9f0c8b49ef9091d6118b1 SHA512 58ea3853cd93b556ecdc4abd0be079b2621171b8491f59004ea4e036a4cba4470aaafe6591b942e0a50a64bdc47540e01fe6900212a1ef7087850112d9bfc5ef WHIRLPOOL 5ffd94f797c32c87d9d818acbb1a41f2c140d6f1da169854aab6eece7a41499b55fc573f9a4fbcccf09dcfc92e460d8c91be5efd8650837e8bfba009b04261b1 DIST ghc-bin-7.10.3-alpha.tbz2 183558856 SHA256 780ac45b9b38fb40f08eeb7dae741649ac19dce2271df4bc764cac9be6c5c225 SHA512 08709fe9b4036ab41715c9a637a2a160104e3ab9e0ed9efaaf73428e3cfe19619e50c42b72c60bbbd27be2b9c2ea68f63d72c1a27d4519756e7c0d909f724230 WHIRLPOOL f488ecc945c6100ba86b9ae25eb6a472693556be0205a6c8634f2c235e779fe17b391ced7fec5d89c0c6c3d21583fe9f9b80bf628f3307890becf3f3ffb57a96 DIST ghc-bin-7.10.3-amd64.tbz2 112040431 SHA256 c3c71aff288f7de2785d1c3d54f0fd636144eb3dcb590bdda087b0775203e517 SHA512 e1554b3944edbe8e16537de5a29132dc6a22d780d9a700cdc9b76387b94191164398d6f2242bf8199527802572e2bb02545569d4f0930a0ee0dbfdeb25978558 WHIRLPOOL c2497a9565abf7d37e7928f508f7bf7241dd529aa252da708517f9f067e3d016341b7a73cac34888b99c9b84a8d01fd9e8d76f2b332d53e0d708b078f20ee807 DIST ghc-bin-7.10.3-ia64.tbz2 238680956 SHA256 0da9b5966f0920341f4cf041b814817e1ed06060e8a491481ab19a68153767db SHA512 3694011aec8a6dc37889418b318993cb82f9b46a5175dd837713f396c8f59a19a920e0b0669fe3b4ec37d5bd8837c115264c0a8fc97c5a4ce06a3bdd52fcfce5 WHIRLPOOL 9e059a953607b6477ea7c27bf55175d838c6aa3c57fcf92f13fa6112e9e728037073047be300a5a757395d759d30545546cb46816ec879a2d31c3c0a78868e42 diff --git a/dev-lang/ghc/files/ghc-8.0.1-limit-jN.patch b/dev-lang/ghc/files/ghc-8.0.1-limit-jN.patch new file mode 100644 index 000000000000..dc5410da3020 --- /dev/null +++ b/dev-lang/ghc/files/ghc-8.0.1-limit-jN.patch @@ -0,0 +1,50 @@ +commit 501e05bb1b8974fc8b6c9eee86c87c367e87a211 +Author: Sergei Trofimovich <slyfox@gentoo.org> +Date: Tue Aug 30 12:10:47 2016 +0100 + + GhcMake: limit Capability count to CPU count in parallel mode + + In Trac #9221 one of problems using high --jobs=<N> + is amount of mutator (or GC) threads we crate. + + We use userspace spinning-and-yielding (see ACQUIRE_SPIN_LOCK) + to acess work stealing queues. In case of + N-worker-threads > N-CPUs fraction of time when + thread holding spin lock gets descheduled by kernel + increases. That causes other threads to waste CPU time + before giving up CPU. + + Signed-off-by: Sergei Trofimovich <siarheit@google.com> + + Test Plan: + ghc --make -j8 and -j80 have comparable sys time + on a 8-core system. + + Reviewers: austin, gintas, bgamari, simonmar + + Reviewed By: bgamari, simonmar + + Subscribers: thomie + + Differential Revision: https://phabricator.haskell.org/D2482 + + GHC Trac Issues: #9221 + +diff --git a/compiler/main/GhcMake.hs b/compiler/main/GhcMake.hs +index 9dc43cd..905df63 100644 +--- a/compiler/main/GhcMake.hs ++++ b/compiler/main/GhcMake.hs +@@ -761,7 +761,12 @@ parUpsweep n_jobs old_hpt stable_mods cleanup sccs = do + + let updNumCapabilities = liftIO $ do + n_capabilities <- getNumCapabilities +- unless (n_capabilities /= 1) $ setNumCapabilities n_jobs ++ n_cpus <- getNumProcessors ++ -- Setting number of capabilities more than ++ -- CPU count usually leads to high userspace ++ -- lock contention. Trac #9221 ++ let n_caps = min n_jobs n_cpus ++ unless (n_capabilities /= 1) $ setNumCapabilities n_caps + return n_capabilities + -- Reset the number of capabilities once the upsweep ends. + let resetNumCapabilities orig_n = liftIO $ setNumCapabilities orig_n diff --git a/dev-lang/ghc/files/ghc-8.0.1-par-g0-on-A32.patch b/dev-lang/ghc/files/ghc-8.0.1-par-g0-on-A32.patch new file mode 100644 index 000000000000..b46e57301782 --- /dev/null +++ b/dev-lang/ghc/files/ghc-8.0.1-par-g0-on-A32.patch @@ -0,0 +1,65 @@ +commit bdfc5375f219d6def81effda4e57cb56d01fc917 +Author: Sergei Trofimovich <slyfox@gentoo.org> +Date: Tue Aug 30 12:10:54 2016 +0100 + + rts: enable parallel GC scan of large (32M+) allocation area + + Parallel GC does not scan large allocation area (-A) + effectively as it does not do work stealing from nursery + by default. + + That leads to large imbalance when only one of threads + overflows allocation area: most of GC threads finish + quickly (as there is not much to collect) and sit idle + waiting while single GC thread finishes scan of single + allocation area for that thread. + + The patch enables work stealing for (equivalent of -qb0) + allocation area of -A32M or higher. + + Tested on a highlighting-kate package from Trac #9221 + + On 8-core machine the difference is around 5% faster + of wall-clock time. On 24-core VM the speedup is 20%. + + Signed-off-by: Sergei Trofimovich <siarheit@google.com> + + Test Plan: measured wall time and GC parallelism on highlighting-kate build + + Reviewers: austin, bgamari, erikd, simonmar + + Reviewed By: bgamari, simonmar + + Subscribers: thomie + + Differential Revision: https://phabricator.haskell.org/D2483 + + GHC Trac Issues: #9221 + +diff --git a/rts/RtsFlags.c b/rts/RtsFlags.c +index fda33f0..7a719b9 100644 +--- a/rts/RtsFlags.c ++++ b/rts/RtsFlags.c +@@ -237,1 +237,1 @@ void initRtsFlagsDefaults(void) +- RtsFlags.ParFlags.parGcLoadBalancingGen = 1; ++ RtsFlags.ParFlags.parGcLoadBalancingGen = ~0u; /* auto, based on -A */ +@@ -1398,2 +1390,19 @@ static void normaliseRtsOpts (void) + } + ++#ifdef THREADED_RTS ++ if (RtsFlags.ParFlags.parGcLoadBalancingGen == ~0u) { ++ StgWord alloc_area_bytes ++ = RtsFlags.GcFlags.minAllocAreaSize * BLOCK_SIZE; ++ ++ // If allocation area is larger that CPU cache ++ // we can finish scanning quicker doing work-stealing ++ // scan. Trac #9221 ++ // 32M looks big enough not to fit into L2 cache ++ // of popular modern CPUs. ++ if (alloc_area_bytes >= 32 * 1024 * 1024) { ++ RtsFlags.ParFlags.parGcLoadBalancingGen = 0; ++ } else { ++ RtsFlags.ParFlags.parGcLoadBalancingGen = 1; ++ } ++ } ++#endif diff --git a/dev-lang/ghc/files/ghc-8.0.1-ww-args-limit.patch b/dev-lang/ghc/files/ghc-8.0.1-ww-args-limit.patch new file mode 100644 index 000000000000..4752f4482678 --- /dev/null +++ b/dev-lang/ghc/files/ghc-8.0.1-ww-args-limit.patch @@ -0,0 +1,127 @@ +commit 5efbf0d243984444cf352ad6f0d147e226c64498 +Author: Sergei Trofimovich <slyfox@gentoo.org> +Date: Thu Sep 1 17:34:58 2016 +0100 + + restore -fmax-worker-args handling (Trac #11565) + + maxWorkerArgs handling was accidentally lost 3 years ago + in a major update of demand analysis + commit 0831a12ea2fc73c33652eeec1adc79fa19700578 + + Old regression is noticeable as: + - code bloat (requires stack reshuffling) + - compilation slowdown (more code to optimise/generate) + - and increased heap usage (DynFlags unboxing/reboxing?) + + On a simple compile benchmark this change causes heap + allocation drop from 70G don to 67G (ghc perf build). + + Signed-off-by: Sergei Trofimovich <siarheit@google.com> + + Reviewers: simonpj, ezyang, goldfire, austin, bgamari + + Reviewed By: simonpj, ezyang + + Subscribers: thomie + + Differential Revision: https://phabricator.haskell.org/D2503 + + GHC Trac Issues: #11565 + +diff --git a/compiler/specialise/SpecConstr.hs b/compiler/specialise/SpecConstr.hs +index 10d5614..7166f57 100644 +--- a/compiler/specialise/SpecConstr.hs ++++ b/compiler/specialise/SpecConstr.hs +@@ -29,7 +29,7 @@ import CoreFVs ( exprsFreeVarsList ) + import CoreMonad + import Literal ( litIsLifted ) + import HscTypes ( ModGuts(..) ) +-import WwLib ( mkWorkerArgs ) ++import WwLib ( isWorkerSmallEnough, mkWorkerArgs ) + import DataCon + import Coercion hiding( substCo ) + import Rules +@@ -1533,10 +1533,14 @@ specialise env bind_calls (RI { ri_fn = fn, ri_lam_bndrs = arg_bndrs + + | Just all_calls <- lookupVarEnv bind_calls fn + = -- pprTrace "specialise entry {" (ppr fn <+> ppr (length all_calls)) $ +- do { (boring_call, pats) <- callsToPats env specs arg_occs all_calls +- ++ do { (boring_call, all_pats) <- callsToPats env specs arg_occs all_calls + -- Bale out if too many specialisations +- ; let n_pats = length pats ++ ; let pats = filter (is_small_enough . fst) all_pats ++ is_small_enough vars = isWorkerSmallEnough (sc_dflags env) vars ++ -- We are about to construct w/w pair in 'spec_one'. ++ -- Omit specialisation leading to high arity workers. ++ -- See Note [Limit w/w arity] ++ n_pats = length pats + spec_count' = n_pats + spec_count + ; case sc_count env of + Just max | not (sc_force env) && spec_count' > max +diff --git a/compiler/stranal/WwLib.hs b/compiler/stranal/WwLib.hs +index 09bc204..d9460d9 100644 +--- a/compiler/stranal/WwLib.hs ++++ b/compiler/stranal/WwLib.hs +@@ -8,6 +8,7 @@ + + module WwLib ( mkWwBodies, mkWWstr, mkWorkerArgs + , deepSplitProductType_maybe, findTypeShape ++ , isWorkerSmallEnough + ) where + + #include "HsVersions.h" +@@ -144,7 +145,8 @@ mkWwBodies dflags fam_envs fun_ty demands res_info one_shots + wrapper_body = wrap_fn_args . wrap_fn_cpr . wrap_fn_str . applyToVars work_call_args . Var + worker_body = mkLams work_lam_args. work_fn_str . work_fn_cpr . work_fn_args + +- ; if useful1 && not (only_one_void_argument) || useful2 ++ ; if isWorkerSmallEnough dflags work_args ++ && (useful1 && not only_one_void_argument || useful2) + then return (Just (worker_args_dmds, wrapper_body, worker_body)) + else return Nothing + } +@@ -165,6 +167,12 @@ mkWwBodies dflags fam_envs fun_ty demands res_info one_shots + | otherwise + = False + ++-- See Note [Limit w/w arity] ++isWorkerSmallEnough :: DynFlags -> [Var] -> Bool ++isWorkerSmallEnough dflags vars = count isId vars <= maxWorkerArgs dflags ++ -- We count only Free variables (isId) to skip Type, Kind ++ -- variables which have no runtime representation. ++ + {- + Note [Always do CPR w/w] + ~~~~~~~~~~~~~~~~~~~~~~~~ +@@ -178,6 +186,30 @@ a disaster, because then the enclosing function might say it has the CPR + property, but now doesn't and there a cascade of disaster. A good example + is Trac #5920. + ++Note [Limit w/w arity] ++~~~~~~~~~~~~~~~~~~~~~~~~ ++Guard against high worker arity as it generates a lot of stack traffic. ++A simplified example is Trac #11565#comment:6 ++ ++Current strategy is very simple: don't perform w/w transformation at all ++if the result produces a wrapper with arity higher than -fmax-worker-args=. ++ ++It is a bit all or nothing, consider ++ ++ f (x,y) (a,b,c,d,e ... , z) = rhs ++ ++Currently we will remove all w/w ness entirely. But actually we could ++w/w on the (x,y) pair... it's the huge product that is the problem. ++ ++Could we instead refrain from w/w on an arg-by-arg basis? Yes, that'd ++solve f. But we can get a lot of args from deeply-nested products: ++ ++ g (a, (b, (c, (d, ...)))) = rhs ++ ++This is harder to spot on an arg-by-arg basis. Previously mkWwStr was ++given some "fuel" saying how many arguments it could add; when we ran ++out of fuel it would stop w/wing. ++Still not very clever because it had a left-right bias. + + ************************************************************************ + * * diff --git a/dev-lang/ghc/files/ghc-8.0.1_rc1-cgen-constify.patch b/dev-lang/ghc/files/ghc-8.0.1_rc1-cgen-constify.patch new file mode 100644 index 000000000000..877a5827e4ea --- /dev/null +++ b/dev-lang/ghc/files/ghc-8.0.1_rc1-cgen-constify.patch @@ -0,0 +1,34 @@ +commit b0cf3ab7a69b878a4335d21a347b56e4b0ca0b7b +Author: Sergei Trofimovich <slyfox@gentoo.org> +Date: Mon Apr 14 19:06:24 2014 +0300 + + compiler/cmm/PprC.hs: constify local string literals + + Consider one-line module + module B (v) where v = "hello" + in -fvia-C mode it generates code like + static char gibberish_str[] = "hello"; + + It uselessly eats data section (precious resource on ia64!). + The patch switches genrator to emit: + static const char gibberish_str[] = "hello"; + + Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> + +diff --git a/compiler/cmm/PprC.hs b/compiler/cmm/PprC.hs +index 2398981..fdb578d 100644 +--- a/compiler/cmm/PprC.hs ++++ b/compiler/cmm/PprC.hs +@@ -112,6 +112,12 @@ pprTop (CmmProc infos clbl _ graph) = + + -- We only handle (a) arrays of word-sized things and (b) strings. + ++pprTop (CmmData (Section ReadOnlyData _) (Statics lbl [CmmString str])) = ++ hcat [ ++ pprLocalness lbl, ptext (sLit "const char "), ppr lbl, ++ ptext (sLit "[] = "), pprStringInCStyle str, semi ++ ] ++ + pprTop (CmmData _section (Statics lbl [CmmString str])) = + hcat [ + pprLocalness lbl, ptext (sLit "char "), ppr lbl, diff --git a/dev-lang/ghc/files/ghc-8.0.2_rc2-old-sphinx.patch b/dev-lang/ghc/files/ghc-8.0.2_rc2-old-sphinx.patch new file mode 100644 index 000000000000..a4d49d3ef808 --- /dev/null +++ b/dev-lang/ghc/files/ghc-8.0.2_rc2-old-sphinx.patch @@ -0,0 +1,12 @@ +diff --git a/docs/users_guide/profiling.rst b/docs/users_guide/profiling.rst +index 4d0bb3a..f980f72 100644 +--- a/docs/users_guide/profiling.rst ++++ b/docs/users_guide/profiling.rst +@@ -435,7 +435,2 @@ To generate a heap profile from your program: + +-For example, here is a heap profile produced for the ``sphere`` program +-from GHC's ``nofib`` benchmark suite, +- +-.. image:: images/prof_scc.* +- + You might also want to take a look at diff --git a/dev-lang/ghc/ghc-8.0.2.ebuild b/dev-lang/ghc/ghc-8.0.2.ebuild new file mode 100644 index 000000000000..2cba08eca272 --- /dev/null +++ b/dev-lang/ghc/ghc-8.0.2.ebuild @@ -0,0 +1,653 @@ +# Copyright 1999-2017 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +EAPI=5 + +# to make make a crosscompiler use crossdev and symlink ghc tree into +# cross overlay. result would look like 'cross-sparc-unknown-linux-gnu/ghc' +# +# 'CTARGET' definition and 'is_crosscompile' are taken from 'toolchain.eclass' +export CTARGET=${CTARGET:-${CHOST}} +if [[ ${CTARGET} = ${CHOST} ]] ; then + if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then + export CTARGET=${CATEGORY/cross-} + fi +fi + +inherit autotools bash-completion-r1 eutils flag-o-matic ghc-package +inherit multilib pax-utils toolchain-funcs versionator prefix + +DESCRIPTION="The Glasgow Haskell Compiler" +HOMEPAGE="http://www.haskell.org/ghc/" + +# we don't have any binaries yet +arch_binaries="" + +# sorted! +#arch_binaries="$arch_binaries alpha? ( http://code.haskell.org/~slyfox/ghc-alpha/ghc-bin-${PV}-alpha.tbz2 )" +#arch_binaries="$arch_binaries arm? ( http://code.haskell.org/~slyfox/ghc-arm/ghc-bin-${PV}-arm.tbz2 )" +#arch_binaries="$arch_binaries amd64? ( http://code.haskell.org/~slyfox/ghc-amd64/ghc-bin-${PV}-amd64.tbz2 )" +#arch_binaries="$arch_binaries ia64? ( http://code.haskell.org/~slyfox/ghc-ia64/ghc-bin-${PV}-ia64-fixed-fiw.tbz2 )" +#arch_binaries="$arch_binaries ppc? ( http://code.haskell.org/~slyfox/ghc-ppc/ghc-bin-${PV}-ppc.tbz2 )" +#arch_binaries="$arch_binaries ppc64? ( http://code.haskell.org/~slyfox/ghc-ppc64/ghc-bin-${PV}-ppc64.tbz2 )" +#arch_binaries="$arch_binaries sparc? ( http://code.haskell.org/~slyfox/ghc-sparc/ghc-bin-${PV}-sparc.tbz2 )" +#arch_binaries="$arch_binaries x86? ( http://code.haskell.org/~slyfox/ghc-x86/ghc-bin-${PV}-x86.tbz2 )" + +# various ports: +#arch_binaries="$arch_binaries x86-fbsd? ( http://code.haskell.org/~slyfox/ghc-x86-fbsd/ghc-bin-${PV}-x86-fbsd.tbz2 )" + +# 0 - yet +yet_binary() { + case "${ARCH}" in + #alpha) return 0 ;; + #arm) + # ewarn "ARM binary is built on armv5tel-eabi toolchain. Use with caution." + # return 0 + #;; + #amd64) return 0 ;; + #ia64) return 0 ;; + #ppc) return 0 ;; + #ppc64) return 0 ;; + #sparc) return 0 ;; + #x86) return 0 ;; + *) return 1 ;; + esac +} + +GHC_PV=${PV} +#GHC_PV=8.0.1.20161213 # uncomment only for -rc ebuilds +GHC_P=${PN}-${GHC_PV} # using ${P} is almost never correct + +SRC_URI="!binary? ( http://downloads.haskell.org/~ghc/${PV/_rc/-rc}/${GHC_P}-src.tar.xz )" +S="${WORKDIR}"/${GHC_P} + +[[ -n $arch_binaries ]] && SRC_URI+=" !ghcbootstrap? ( $arch_binaries )" + +BUMP_LIBRARIES=( + # "hackage-name hackage-version" +) + +LICENSE="BSD" +SLOT="0/${PV}" +#KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux" +IUSE="doc ghcbootstrap ghcmakebinary +gmp +profile" +IUSE+=" binary" + +RDEPEND=" + >=dev-lang/perl-5.6.1 + dev-libs/gmp:0= + sys-libs/ncurses:=[unicode] + !ghcmakebinary? ( virtual/libffi:= ) +" +# gentoo binaries are built against ncurses-6 +RDEPEND+=" + binary? ( + || ( + sys-libs/ncurses:0/6 + sys-libs/ncurses:5/6 + ) + ) +" + +DEPEND="${RDEPEND} + doc? ( app-text/docbook-xml-dtd:4.2 + app-text/docbook-xml-dtd:4.5 + app-text/docbook-xsl-stylesheets + dev-python/sphinx + >=dev-libs/libxslt-1.1.2 ) +" + +PDEPEND="!ghcbootstrap? ( =app-admin/haskell-updater-1.2* )" + +REQUIRED_USE="?? ( ghcbootstrap binary )" + +# haskell libraries built with cabal in configure mode, #515354 +QA_CONFIGURE_OPTIONS+=" --with-compiler --with-gcc" + +is_crosscompile() { + [[ ${CHOST} != ${CTARGET} ]] +} + +# returns tool prefix for crosscompiler. +# Example: +# CTARGET=armv7a-unknown-linux-gnueabi +# CHOST=x86_64-pc-linux-gnu +# "armv7a-unknown-linux-gnueabi-" +# CTARGET=${CHOST} +# "" +# Used in tools and library prefix: +# "${ED}"/usr/bin/$(cross)haddock +# "${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d" + +cross() { + if is_crosscompile; then + echo "${CTARGET}-" + else + echo "" + fi +} + +append-ghc-cflags() { + local persistent compile assemble link + local flag ghcflag + + for flag in $*; do + case ${flag} in + persistent) persistent="yes";; + compile) compile="yes";; + assemble) assemble="yes";; + link) link="yes";; + *) + [[ ${compile} ]] && ghcflag="-optc${flag}" CFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" && + [[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}" + [[ ${assemble} ]] && ghcflag="-opta${flag}" CFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" && + [[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}" + [[ ${link} ]] && ghcflag="-optl${flag}" LDFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" && + [[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}" + ;; + esac + done +} + +# $1 - lib name (under libraries/) +# $2 - lib version +# example: bump_lib "transformers" "0.4.2.0" +bump_lib() { + local pn=$1 pv=$2 + local p=${pn}-${pv} + local f + + einfo "Bumping ${pn} up to ${pv}" + + for f in ghc.mk GNUmakefile; do + mv libraries/"${pn}"/$f "${WORKDIR}"/"${p}"/$f || die + done + mv libraries/"${pn}" "${WORKDIR}"/"${pn}".old || die + mv "${WORKDIR}"/"${p}" libraries/"${pn}" || die +} + +update_SRC_URI() { + local p pn pv + for p in "${BUMP_LIBRARIES[@]}"; do + set -- $p + pn=$1 pv=$2 + + SRC_URI+=" mirror://hackage/package/${pn}/${pn}-${pv}.tar.gz" + done +} + +update_SRC_URI + +bump_libs() { + local p pn pv + for p in "${BUMP_LIBRARIES[@]}"; do + set -- $p + pn=$1 pv=$2 + + bump_lib "${pn}" "${pv}" + done +} + +ghc_setup_cflags() { + if is_crosscompile; then + export CFLAGS=${GHC_CFLAGS-"-O2 -pipe"} + export LDFLAGS=${GHC_LDFLAGS-"-Wl,-O1"} + einfo "Crosscompiling mode:" + einfo " CHOST: ${CHOST}" + einfo " CTARGET: ${CTARGET}" + einfo " CFLAGS: ${CFLAGS}" + einfo " LDFLAGS: ${LDFLAGS}" + einfo " prefix: $(cross)" + return + fi + # We need to be very careful with the CFLAGS we ask ghc to pass through to + # gcc. There are plenty of flags which will make gcc produce output that + # breaks ghc in various ways. The main ones we want to pass through are + # -mcpu / -march flags. These are important for arches like alpha & sparc. + # We also use these CFLAGS for building the C parts of ghc, ie the rts. + strip-flags + strip-unsupported-flags + + # Cmm can't parse line numbers #482086 + replace-flags -ggdb[3-9] -ggdb2 + + GHC_FLAGS="" + GHC_PERSISTENT_FLAGS="" + for flag in ${CFLAGS}; do + case ${flag} in + + # Ignore extra optimisation (ghc passes -O to gcc anyway) + # -O2 and above break on too many systems + -O*) ;; + + # Arch and ABI flags are what we're really after + -m*) append-ghc-cflags compile assemble ${flag};; + + # Sometimes it's handy to see backtrace of RTS + # to get an idea what happens there + -g*) append-ghc-cflags compile ${flag};; + + # Ignore all other flags, including all -f* flags + esac + done + + for flag in ${LDFLAGS}; do + append-ghc-cflags link ${flag} + done + + # hardened-gcc needs to be disabled, because the mangler doesn't accept + # its output. + gcc-specs-pie && append-ghc-cflags persistent compile link -nopie + gcc-specs-ssp && append-ghc-cflags persistent compile -fno-stack-protector + + # prevent from failind building unregisterised ghc: + # http://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg171602.html + use ppc64 && append-ghc-cflags persistent compile -mminimal-toc +} + +# substitutes string $1 to $2 in files $3 $4 ... +relocate_path() { + local from=$1 + local to=$2 + shift 2 + local file= + for file in "$@" + do + sed -i -e "s|$from|$to|g" \ + "$file" || die "path relocation failed for '$file'" + done +} + +# changes hardcoded ghc paths and updates package index +# $1 - new absolute root path +relocate_ghc() { + local to=$1 + + # libdir for prebuilt binary and for current system may mismatch + # It does for prefix installation for example: bug #476998 + local bin_ghc_prefix=${WORKDIR}/usr + local bin_libpath=$(echo "${bin_ghc_prefix}"/lib*) + local bin_libdir=${bin_libpath#${bin_ghc_prefix}/} + + # backup original script to use it later after relocation + local gp_back="${T}/ghc-pkg-${GHC_PV}-orig" + cp "${WORKDIR}/usr/bin/$(cross)ghc-pkg-${GHC_PV}" "$gp_back" || die "unable to backup ghc-pkg wrapper" + + if [[ ${bin_libdir} != $(get_libdir) ]]; then + einfo "Relocating '${bin_libdir}' to '$(get_libdir)' (bug #476998)" + # moving the dir itself is not strictly needed + # but then USE=binary would result in installing + # in '${bin_libdir}' + mv "${bin_ghc_prefix}/${bin_libdir}" "${bin_ghc_prefix}/$(get_libdir)" || die + + relocate_path "/usr/${bin_libdir}" "/usr/$(get_libdir)" \ + "${WORKDIR}/usr/bin/$(cross)ghc-${GHC_PV}" \ + "${WORKDIR}/usr/bin/$(cross)ghci-${GHC_PV}" \ + "${WORKDIR}/usr/bin/$(cross)ghc-pkg-${GHC_PV}" \ + "${WORKDIR}/usr/bin/$(cross)hsc2hs" \ + "${WORKDIR}/usr/bin/$(cross)runghc-${GHC_PV}" \ + "$gp_back" \ + "${WORKDIR}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d/"* + fi + + # Relocate from /usr to ${EPREFIX}/usr + relocate_path "/usr" "${to}/usr" \ + "${WORKDIR}/usr/bin/$(cross)ghc-${GHC_PV}" \ + "${WORKDIR}/usr/bin/$(cross)ghci-${GHC_PV}" \ + "${WORKDIR}/usr/bin/$(cross)ghc-pkg-${GHC_PV}" \ + "${WORKDIR}/usr/bin/$(cross)hsc2hs" \ + "${WORKDIR}/usr/bin/$(cross)runghc-${GHC_PV}" \ + "${WORKDIR}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d/"* + + # this one we will use to regenerate cache + # so it should point to current tree location + relocate_path "/usr" "${WORKDIR}/usr" "$gp_back" + + if use prefix; then + # and insert LD_LIBRARY_PATH entry to EPREFIX dir tree + # TODO: add the same for darwin's CHOST and it's DYLD_ + local new_ldpath='LD_LIBRARY_PATH="'${EPREFIX}/$(get_libdir):${EPREFIX}/usr/$(get_libdir)'${LD_LIBRARY_PATH:+:}${LD_LIBRARY_PATH}"\nexport LD_LIBRARY_PATH' + sed -i -e '2i'"$new_ldpath" \ + "${WORKDIR}/usr/bin/$(cross)ghc-${GHC_PV}" \ + "${WORKDIR}/usr/bin/$(cross)ghci-${GHC_PV}" \ + "${WORKDIR}/usr/bin/$(cross)ghc-pkg-${GHC_PV}" \ + "${WORKDIR}/usr/bin/$(cross)hsc2hs" \ + "${WORKDIR}/usr/bin/$(cross)runghc-${GHC_PV}" \ + "$gp_back" \ + || die "Adding LD_LIBRARY_PATH for wrappers failed" + hprefixify "${bin_libpath}"/${PN}*/settings + fi + + # regenerate the binary package cache + "$gp_back" recache || die "failed to update cache after relocation" + rm "$gp_back" +} + +pkg_setup() { + # quiet portage about prebuilt binaries + use binary && QA_PREBUILT="*" + + [[ ${MERGE_TYPE} == binary ]] && return + + if use ghcbootstrap; then + ewarn "You requested ghc bootstrapping, this is usually only used" + ewarn "by Gentoo developers to make binary .tbz2 packages." + + [[ -z $(type -P ghc) ]] && \ + die "Could not find a ghc to bootstrap with." + else + if ! yet_binary; then + eerror "Please try emerging with USE=ghcbootstrap and report build" + eerror "sucess or failure to the haskell team (haskell@gentoo.org)" + die "No binary available for '${ARCH}' arch yet, USE=ghcbootstrap" + fi + fi +} + +src_unpack() { + # Create the ${S} dir if we're using the binary version + use binary && mkdir "${S}" + + # the Solaris and Darwin binaries from ghc (maeder) need to be + # unpacked separately, so prevent them from being unpacked + local ONLYA=${A} + case ${CHOST} in + *-darwin* | *-solaris*) ONLYA=${GHC_P}-src.tar.bz2 ;; + esac + unpack ${ONLYA} +} + +src_prepare() { + ghc_setup_cflags + + if ! use ghcbootstrap && [[ ${CHOST} != *-darwin* && ${CHOST} != *-solaris* ]]; then + # Modify the wrapper script from the binary tarball to use GHC_PERSISTENT_FLAGS. + # See bug #313635. + sed -i -e "s|\"\$topdir\"|\"\$topdir\" ${GHC_PERSISTENT_FLAGS}|" \ + "${WORKDIR}/usr/bin/$(cross)ghc-${GHC_PV}" + + # allow hardened users use vanilla binary to bootstrap ghc + # ghci uses mmap with rwx protection at it implements dynamic + # linking on it's own (bug #299709) + pax-mark -m "${WORKDIR}/usr/$(get_libdir)/$(cross)${GHC_P}/bin/ghc" + fi + + if use binary; then + if use prefix; then + relocate_ghc "${EPREFIX}" + fi + + # Move unpacked files to the expected place + mv "${WORKDIR}/usr" "${S}" + else + if ! use ghcbootstrap; then + case ${CHOST} in + *-darwin* | *-solaris*) + # UPDATE ME for ghc-7 + mkdir "${WORKDIR}"/ghc-bin-installer || die + pushd "${WORKDIR}"/ghc-bin-installer > /dev/null || die + use sparc-solaris && unpack ghc-6.10.4-sparc-sun-solaris2.tar.bz2 + use x86-solaris && unpack ghc-7.0.3-i386-unknown-solaris2.tar.bz2 + use x86-macos && unpack ghc-7.4.1-i386-apple-darwin.tar.bz2 + use x64-macos && unpack ghc-7.4.1-x86_64-apple-darwin.tar.bz2 + popd > /dev/null + + pushd "${WORKDIR}"/ghc-bin-installer/ghc-[67].?*.? > /dev/null || die + # fix the binaries so they run, on Solaris we need an + # LD_LIBRARY_PATH which has our prefix libdirs, on + # Darwin we need to replace the frameworks with our libs + # from the prefix fix before installation, because some + # of the tools are actually used during configure/make + if [[ ${CHOST} == *-solaris* ]] ; then + export LD_LIBRARY_PATH="${EPREFIX}/$(get_libdir):${EPREFIX}/usr/$(get_libdir):${LD_LIBRARY_PATH}" + elif [[ ${CHOST} == *-darwin* ]] ; then + local readline_framework=GNUreadline.framework/GNUreadline + local gmp_framework=/opt/local/lib/libgmp.10.dylib + local ncurses_file=/opt/local/lib/libncurses.5.dylib + for binary in $(scanmacho -BRE MH_EXECUTE -F '%F' .) ; do + install_name_tool -change \ + ${readline_framework} \ + "${EPREFIX}"/lib/libreadline.dylib \ + ${binary} || die + install_name_tool -change \ + ${gmp_framework} \ + "${EPREFIX}"/usr/lib/libgmp.dylib \ + ${binary} || die + install_name_tool -change \ + ${ncurses_file} \ + "${EPREFIX}"/usr/lib/libncurses.dylib \ + ${binary} || die + done + # we don't do frameworks! + sed -i \ + -e 's/\(frameworks = \)\["GMP"\]/\1[]/g' \ + -e 's/\(extraLibraries = \)\["m"\]/\1["m","gmp"]/g' \ + rts/package.conf.in || die + fi + + # it is autoconf, but we really don't want to give it too + # much arguments, in fact we do the make in-place anyway + ./configure --prefix="${WORKDIR}"/usr || die + make install || die + popd > /dev/null + ;; + *) + relocate_ghc "${WORKDIR}" + ;; + esac + fi + + sed -i -e "s|\"\$topdir\"|\"\$topdir\" ${GHC_PERSISTENT_FLAGS}|" \ + "${S}/ghc/ghc.wrapper" + + cd "${S}" # otherwise epatch will break + + epatch "${FILESDIR}"/${PN}-7.0.4-CHOST-prefix.patch + + epatch "${FILESDIR}"/${PN}-8.0.1_rc1-cgen-constify.patch + epatch "${FILESDIR}"/${PN}-7.8.3-prim-lm.patch + + epatch "${FILESDIR}"/${PN}-8.0.1-limit-jN.patch + epatch "${FILESDIR}"/${PN}-8.0.1-ww-args-limit.patch + epatch "${FILESDIR}"/${PN}-8.0.1-par-g0-on-A32.patch + epatch "${FILESDIR}"/${PN}-8.0.2_rc2-old-sphinx.patch + + if use prefix; then + # Make configure find docbook-xsl-stylesheets from Prefix + sed -e '/^FP_DIR_DOCBOOK_XSL/s:\[.*\]:['"${EPREFIX}"'/usr/share/sgml/docbook/xsl-stylesheets/]:' \ + -i utils/haddock/doc/configure.ac || die + fi + + bump_libs + + # as we have changed the build system + eautoreconf + fi +} + +src_configure() { + if ! use binary; then + # initialize build.mk + echo '# Gentoo changes' > mk/build.mk + + # Put docs into the right place, ie /usr/share/doc/ghc-${GHC_PV} + echo "docdir = ${EPREFIX}/usr/share/doc/${P}" >> mk/build.mk + echo "htmldir = ${EPREFIX}/usr/share/doc/${P}" >> mk/build.mk + + # We also need to use the GHC_FLAGS flags when building ghc itself + echo "SRC_HC_OPTS+=${HCFLAGS} ${GHC_FLAGS}" >> mk/build.mk + echo "SRC_CC_OPTS+=${CFLAGS}" >> mk/build.mk + echo "SRC_LD_OPTS+=${LDFLAGS}" >> mk/build.mk + # Speed up initial Cabal bootstrap + echo "utils/ghc-cabal_dist_EXTRA_HC_OPTS+=$(ghc-make-args)" >> mk/build.mk + + # We can't depend on haddock except when bootstrapping when we + # must build docs and include them into the binary .tbz2 package + # app-text/dblatex is not in portage, can not build PDF or PS + echo "BUILD_SPHINX_PDF = NO" >> mk/build.mk + echo "BUILD_SPHINX_HTML = $(usex doc YES NO)" >> mk/build.mk + + # this controls presence on 'xhtml' and 'haddock' in final install + echo "HADDOCK_DOCS = YES" >> mk/build.mk + + # allows overriding build flavours for libraries: + # v - vanilla (static libs) + # p - profiled + # dyn - shared libraries + # example: GHC_LIBRARY_WAYS="v dyn" + if [[ -n ${GHC_LIBRARY_WAYS} ]]; then + echo "GhcLibWays=${GHC_LIBRARY_WAYS}" >> mk/build.mk + fi + echo "BUILD_PROF_LIBS = $(usex profile YES NO)" >> mk/build.mk + + # Get ghc from the unpacked binary .tbz2 + # except when bootstrapping we just pick ghc up off the path + if ! use ghcbootstrap; then + export PATH="${WORKDIR}/usr/bin:${PATH}" + fi + + echo "INTEGER_LIBRARY = $(usex gmp integer-gmp integer-simple)" >> mk/build.mk + + # don't strip anything. Very useful when stage2 SIGSEGVs on you + echo "STRIP_CMD = :" >> mk/build.mk + + local econf_args=() + + # GHC embeds 'gcc' it was built by and uses it later. + # Don't allow things like ccache or versioned binary slip. + # We use stable thing across gcc upgrades. + is_crosscompile || econf_args+=(--with-gcc=${CHOST}-gcc) + + if use ghcmakebinary; then + # When building booting libary we are trying to + # bundle or restrict most of external depends + # with unstable ABI: + # - embed libffi (default GHC behaviour) + # - disable ncurses support for ghci (via haskeline) + # https://bugs.gentoo.org/557478 + # - disable ncurses support for ghc-pkg + echo "libraries/haskeline_CONFIGURE_OPTS += --flag=-terminfo" >> mk/build.mk + echo "utils/ghc-pkg_HC_OPTS += -DBOOTSTRAPPING" >> mk/build.mk + else + econf_args+=(--with-system-libffi) + econf_args+=(--with-ffi-includes=$(pkg-config libffi --cflags-only-I | sed -e 's@^-I@@')) + fi + + elog "Final mk/build.mk:" + cat mk/build.mk || die + + econf ${econf_args[@]} --enable-bootstrap-with-devel-snapshot + + if [[ ${PV} == *9999* ]]; then + GHC_PV="$(grep 'S\[\"PACKAGE_VERSION\"\]' config.status | sed -e 's@^.*=\"\(.*\)\"@\1@')" + GHC_P=${PN}-${GHC_PV} + fi + fi # ! use binary +} + +src_compile() { + if ! use binary; then + # 1. build/pax-mark compiler binary first + emake ghc/stage2/build/tmp/ghc-stage2 + pax-mark -m ghc/stage2/build/tmp/ghc-stage2 + # 2. build/pax-mark haddock using ghc-stage2 + emake utils/haddock/dist/build/tmp/haddock + pax-mark -m utils/haddock/dist/build/tmp/haddock + # 3. and then all the rest + emake all + fi # ! use binary +} + +src_install() { + if use binary; then + use prefix && mkdir -p "${ED}" + mv "${S}/usr" "${ED}" + else + + emake install DESTDIR="${D}" + dodoc "distrib/README" "ANNOUNCE" "LICENSE" "VERSION" + + # rename ghc-shipped files to avoid collision + # of external packages. Motivating example: + # user had installed: + # dev-lang/ghc-7.8.4-r0 (with transformers-0.3.0.0) + # dev-haskell/transformers-0.4.2.0 + # then user tried to update to + # dev-lang/ghc-7.8.4-r1 (with transformers-0.4.2.0) + # this will lead to single .conf file collision. + local shipped_conf renamed_conf + local package_confdir="${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d" + for shipped_conf in "${package_confdir}"/*.conf; do + # rename 'pkg-ver-id.conf' to 'pkg-ver-id-gentoo-${PF}.conf' + renamed_conf=${shipped_conf%.conf}-gentoo-${PF}.conf + mv "${shipped_conf}" "${renamed_conf}" || die + done + + # remove link, but leave 'haddock-${GHC_P}' + rm -f "${ED}"/usr/bin/$(cross)haddock + + if [[ ! -f "${S}/VERSION" ]]; then + echo "${GHC_PV}" > "${S}/VERSION" \ + || die "Could not create file ${S}/VERSION" + fi + if ! is_crosscompile; then + newbashcomp "${FILESDIR}"/ghc-bash-completion ghc-pkg + newbashcomp utils/completion/ghc.bash ghc + fi + fi + + # path to the package.cache + local package_confdir="${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d" + PKGCACHE="${package_confdir}"/package.cache + # copy the package.conf.d, including timestamp, save it so we can help + # users that have a broken package.conf.d + cp -pR "${package_confdir}"{,.initial} || die "failed to backup intial package.conf.d" + + # copy the package.conf, including timestamp, save it so we later can put it + # back before uninstalling, or when upgrading. + cp -p "${PKGCACHE}"{,.shipped} \ + || die "failed to copy package.conf.d/package.cache" +} + +pkg_preinst() { + # have we got an earlier version of ghc installed? + if has_version "<${CATEGORY}/${PF}"; then + haskell_updater_warn="1" + fi +} + +pkg_postinst() { + ghc-reregister + + # path to the package.cache + PKGCACHE="${EROOT}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d/package.cache" + + # give the cache a new timestamp, it must be as recent as + # the package.conf.d directory. + touch "${PKGCACHE}" + + if [[ "${haskell_updater_warn}" == "1" ]]; then + ewarn + ewarn "\e[1;31m************************************************************************\e[0m" + ewarn + ewarn "You have just upgraded from an older version of GHC." + ewarn "You may have to run" + ewarn " 'haskell-updater'" + ewarn "to rebuild all ghc-based Haskell libraries." + ewarn + ewarn "\e[1;31m************************************************************************\e[0m" + ewarn + fi +} + +pkg_prerm() { + PKGCACHE="${EROOT}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d/package.cache" + rm -rf "${PKGCACHE}" + + cp -p "${PKGCACHE}"{.shipped,} +} + +pkg_postrm() { + ghc-package_pkg_postrm +} |