Gentoo Archives: gentoo-commits

From: Sergei Trofimovich <slyfox@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-lang/ghc/
Date: Thu, 24 Dec 2020 08:28:23
Message-Id: 1608798485.536c0a08f4b135da5bee8a8b50c2301e2b8fd299.slyfox@gentoo
1 commit: 536c0a08f4b135da5bee8a8b50c2301e2b8fd299
2 Author: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
3 AuthorDate: Thu Dec 24 08:28:05 2020 +0000
4 Commit: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
5 CommitDate: Thu Dec 24 08:28:05 2020 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=536c0a08
7
8 dev-lang/ghc: bump up to 8.10.3, no keywords yet
9
10 Package-Manager: Portage-3.0.12, Repoman-3.0.2
11 Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>
12
13 dev-lang/ghc/Manifest | 3 +
14 dev-lang/ghc/ghc-8.10.3.ebuild | 797 +++++++++++++++++++++++++++++++++++++++++
15 2 files changed, 800 insertions(+)
16
17 diff --git a/dev-lang/ghc/Manifest b/dev-lang/ghc/Manifest
18 index d00bed22b5b..77789f96fa7 100644
19 --- a/dev-lang/ghc/Manifest
20 +++ b/dev-lang/ghc/Manifest
21 @@ -7,6 +7,8 @@ DIST ghc-8.10.1-src.tar.xz 19781652 BLAKE2B 61ff73d3a895cfa0c836e25a684d7a31cf09
22 DIST ghc-8.10.1-testsuite.tar.xz 2091988 BLAKE2B 88796f0fb6ea2bdd749161c84ec88768f3bf87063d2224a083db24f69282e615227626fe3c7b41d4abec10883e22042abed6a231582bab4ea530feffd683ed0b SHA512 35147f98301c5bfb6c939e108de48b2a1133adc1028aaa720ce49d60faa06a4b486a9eded658295e3f203731b4dd53475b57e8213491c45b05959430030be269
23 DIST ghc-8.10.2-src.tar.xz 21880680 BLAKE2B 0c1b67c1576cfd1067d11838301f96041cabf66b94cfd546cfe6bef57babe940fc3814918ff9327e59fe73a8e230fa1d62d7816d7c6cae274dd8c53de6e81736 SHA512 6c3f1311feab3665419a301b17fcb09d303ec822f8eb8c4021edfacff00d9b52e71895bed0e58f11d8f7970415bd8c6f95ffde1294afe795e15607199b20cefc
24 DIST ghc-8.10.2-testsuite.tar.xz 2101788 BLAKE2B 0d4528223471dfd68cadcda47931d53508c9eafa415716ca5990ea519eb89bfa2bdd444280057be33467382dd3d178887262d54ef633aa8ce88ea91eb9d58ece SHA512 043faaf2f0dc34a868c481b284b94afd78aa1ec1a4056d1f3c97ca3f7dadb3e9cff0517a4cfb378fe5187389db7c9027763bf066328e7dcfd264b737f6d09e41
25 +DIST ghc-8.10.3-src.tar.xz 19872356 BLAKE2B 043f41a21becc826b3cd13ee81b138cf2edfa18484f98361dc85b12f784df85571522347d5fafe40a19ea8ddf12390cd766db8fc21cf4971e797bc61404304cc SHA512 6f3248e728d3677dfddf2f02609167c67a194750418f2a5e34ed68f1135960761c5a5768255bfc8b2ef5640395609424878375184d2dde8e2d69021a3baf9ec8
26 +DIST ghc-8.10.3-testsuite.tar.xz 2261376 BLAKE2B cd03d569c30637d531d9a13fa926a28f854a37d48ef0d4e2fde684664ae000f3c941b5113ccafd42fec019428bafb5344b1ddf8f84a71b21bca8831ed4784907 SHA512 4c9d20a27ed71eb7c73bd86c1049ea5adcc8a0b12040386b7d0dddb46b3cf704c52a3392e19ae4ff1c76b8868665c599391d47e47dba516fcadf8abbc30e28df
27 DIST ghc-8.2.1-src.tar.xz 10736016 BLAKE2B 60993cfc9569e83b0c383591ef30a7280e0138fbb7bd696ad62d87e68dcbccf31c0b8ba211b6647922b8595c7aec2c783648f12c67da53e0766b71c7d7c923fc SHA512 d9aa2aa7f9414db8f4e51d6c275694b46df515e68331a1a2b6018256333a2c63ebd877b75ee90407ecce5be672ec9afc6bebd62aadbf8ae06b94f1760d1736be
28 DIST ghc-8.2.2-src.tar.xz 10753272 BLAKE2B 6fd792390d3df20f84836466705c3f3c931ba2d594dcbe2b808ea0ae284460000b443df8aae74903eabf05ff9064d68a303086cf888ea68222eb1c60959c8f21 SHA512 6549416f470b599973d409fa45f59c25b07e6a94798cef1a19ad432547dc225338cf4dbc4a4793114b4a417798a3b59b122b92b020251074405c5302b7ffe799
29 DIST ghc-8.4.1-src.tar.xz 11301528 BLAKE2B 6dcf467d04cace856b68315c85b80f19b517dcbc8ae6e2a08c60afa141c9e0261e012738452c9ca208f9fc40c48bd1a0817e5e0fe9f4737383cd7b44ca65c8d9 SHA512 f8ae11f498bf2911fb92635534c6906c96f1fbe5072c7b7447bd3f69e408026b674564515af02a8aaddc57ee6905ce78d10005b12478a39c220580aaec13a9f7
30 @@ -49,6 +51,7 @@ DIST ghc-bin-8.10.1-i686-pc-linux-gnu.tbz2 123398571 BLAKE2B 3650f9dbaaa5af684ab
31 DIST ghc-bin-8.10.1-x86_64-pc-linux-gnu.tbz2 122227601 BLAKE2B 84340866c70044eb1444a70b0cbed6814808037b697db28f567d2b14bb791cbe7d9bf2a327cc47ae85ce3c4970ba039854b4a6df44eb85cdc18040c5a4d15f4f SHA512 81df9de95aec47d60ad8d699756ad323eb525c3a16536fac8c6717e1754272061bd8d7d70cd38f5c509a2fc323305333e4f898c9b6dc27645521bb29ee218bdb
32 DIST ghc-bin-8.10.2-i686-pc-linux-gnu.tbz2 123683156 BLAKE2B a486076ea6e67f124c850e037be0e63a873181c3fd746f437861f7367a968e0df6723afc934c966432274a55936c0fe48a9a43a48199840b37636843da4caccc SHA512 29cc1703bbdbfcbef8aa2a5a563b83b0663970f5902a1fc70230515a128ef47e27a3a6df2b47a01009c3976b4936cf8e64e5da4dfdda0c1bcf73ab7ea5ac0b6d
33 DIST ghc-bin-8.10.2-x86_64-pc-linux-gnu.tbz2 122818630 BLAKE2B 030a68e2aca0eb0a273e0d48a3e180d92b219b2d1826d1d58fa133d0a6cae1316b3ccceadb55a4fa5870f87c3df85df2998e7611b93dbc1fea592437748b2daf SHA512 23bf47ee45fae54a843de9e6991b67fccb79c14ad8d08eff9f38a68a3530496c8ce4bc8cae8a731bb690ddd6cd0bf36d6d5bf37eb68ddae8ce646a0bf3916d8f
34 +DIST ghc-bin-8.10.3-x86_64-pc-linux-gnu.tbz2 122993247 BLAKE2B e3395ebc7e87b4ae8f66dbbd9441c214c4d9535e55bfb14f78ebb92d30b1e100efc4893b3cdc65564d47bd53a21cb30106572b3fce13be022946171112c3218e SHA512 2ea4295bcaf6e3fd0db54ba67465e979cd85d3370c6c49f2381478ae9824ad89df53d7d93ccf06bdff5f4849f14306c9f50c13e6f6ba45f79e5b8c13ad63ae4f
35 DIST ghc-bin-8.2.1-i686-pc-linux-gnu.tbz2 96157437 BLAKE2B 2b9608845db8cea78db07209fa054b3b05085d5c3ac07cbe3de02a93c87fb0cff12b1820f08757221c59c8a0a9e7a5563c44266b181525d916825e5cf5bac34c SHA512 e891e76557fa61853e28829b8bedc4a6abb92954f90cc1ebcf22a13cc137556bbe9262e7398b7e1aedbabeb997916b008bf1561a52f16a569f3d58ea9404f41e
36 DIST ghc-bin-8.2.1-x86_64-pc-linux-gnu.tbz2 97490496 BLAKE2B 3666ea70cb8b3645db071040d2069fe244042c11954b34e5d92aaa90132d2316c0ee8c176cd4e674772bea3b99df150404f62bd8745c046cdaf102ecf0a0fa54 SHA512 52630a185d0eab56bce0469a612a54109895bfee041ec362ced59a9b35ba3b9c185e86bc7dbf0a5939081d3626baa19fbb3306e36d1857530248a7b9bfc100bb
37 DIST ghc-bin-8.2.2-i686-pc-linux-gnu.tbz2 96638908 BLAKE2B b470f838e77330969f162196b0f1035fa764f5d123687fbf67c14323280bfe55216af0e16f8b79c62f290905d96abc8bfafee650f8d27c81608853e78329b2c9 SHA512 15b1525890477539878385efc15ce5f1cf2f126cc785c42923be958cabe3298cebe73526a2370cf4c630124160a7ca0f0f9062aebbf035dce807a0374eaddd14
38
39 diff --git a/dev-lang/ghc/ghc-8.10.3.ebuild b/dev-lang/ghc/ghc-8.10.3.ebuild
40 new file mode 100644
41 index 00000000000..93c697bbc6d
42 --- /dev/null
43 +++ b/dev-lang/ghc/ghc-8.10.3.ebuild
44 @@ -0,0 +1,797 @@
45 +# Copyright 1999-2020 Gentoo Authors
46 +# Distributed under the terms of the GNU General Public License v2
47 +
48 +EAPI=7
49 +
50 +# to make make a crosscompiler use crossdev and symlink ghc tree into
51 +# cross overlay. result would look like 'cross-sparc-unknown-linux-gnu/ghc'
52 +export CBUILD=${CBUILD:-${CHOST}}
53 +export CTARGET=${CTARGET:-${CHOST}}
54 +if [[ ${CTARGET} = ${CHOST} ]] ; then
55 + if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then
56 + export CTARGET=${CATEGORY/cross-}
57 + fi
58 +fi
59 +
60 +inherit autotools bash-completion-r1 eutils flag-o-matic ghc-package
61 +inherit multilib multiprocessing pax-utils toolchain-funcs prefix
62 +inherit check-reqs
63 +DESCRIPTION="The Glasgow Haskell Compiler"
64 +HOMEPAGE="https://www.haskell.org/ghc/"
65 +
66 +# we don't have any binaries yet
67 +arch_binaries=""
68 +
69 +BIN_PV=${PV}
70 +# sorted!
71 +#arch_binaries="$arch_binaries alpha? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-alpha.tbz2 )"
72 +#arch_binaries="$arch_binaries arm? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-armv7a-hardfloat-linux-gnueabi.tbz2 )"
73 +#arch_binaries="$arch_binaries arm64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-aarch64-unknown-linux-gnu.tbz2 )"
74 +arch_binaries="$arch_binaries amd64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-x86_64-pc-linux-gnu.tbz2 )"
75 +#arch_binaries="$arch_binaries ia64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ia64-fixed-fiw.tbz2 )"
76 +#arch_binaries="$arch_binaries ppc? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ppc.tbz2 )"
77 +#arch_binaries="$arch_binaries ppc64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ppc64.tbz2 )"
78 +#arch_binaries="$arch_binaries ppc64? ( !big-endian? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-powerpc64le-unknown-linux-gnu.tbz2 ) )"
79 +#arch_binaries="$arch_binaries sparc? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-sparc.tbz2 )"
80 +#arch_binaries="$arch_binaries x86? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-i686-pc-linux-gnu.tbz2 )"
81 +
82 +# various ports:
83 +#arch_binaries="$arch_binaries x86-fbsd? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-x86-fbsd.tbz2 )"
84 +
85 +# 0 - yet
86 +yet_binary() {
87 + case "${ARCH}" in
88 + #alpha) return 0 ;;
89 + #arm64) return 0 ;;
90 + #arm) return 0 ;;
91 + amd64) return 0 ;;
92 + #ia64) return 0 ;;
93 + #ppc) return 0 ;;
94 + #ppc64)
95 + # use big-endian && return 0
96 + # return 0
97 + # ;;
98 + #sparc) return 0 ;;
99 + #x86) return 0 ;;
100 + *) return 1 ;;
101 + esac
102 +}
103 +
104 +GHC_PV=${PV}
105 +#GHC_PV=8.10.0.20200123 # uncomment only for -alpha, -beta, -rc ebuilds
106 +GHC_P=${PN}-${GHC_PV} # using ${P} is almost never correct
107 +
108 +SRC_URI="!binary? (
109 + https://downloads.haskell.org/ghc/${PV/_/-}/${GHC_P}-src.tar.xz
110 + test? ( https://downloads.haskell.org/ghc/${PV/_/-}/${GHC_P}-testsuite.tar.xz )
111 +)"
112 +S="${WORKDIR}"/${GHC_P}
113 +
114 +[[ -n $arch_binaries ]] && SRC_URI+=" !ghcbootstrap? ( $arch_binaries )"
115 +
116 +BUMP_LIBRARIES=(
117 + # "hackage-name hackage-version"
118 +)
119 +
120 +LICENSE="BSD"
121 +SLOT="0/${PV}"
122 +#KEYWORDS="~amd64 ~x86"
123 +IUSE="big-endian doc elfutils ghcbootstrap ghcmakebinary +gmp numa profile test"
124 +IUSE+=" binary"
125 +RESTRICT="!test? ( test )"
126 +
127 +RDEPEND="
128 + >=dev-lang/perl-5.6.1
129 + dev-libs/gmp:0=
130 + sys-libs/ncurses:0=[unicode]
131 + elfutils? ( dev-libs/elfutils )
132 + !ghcmakebinary? ( dev-libs/libffi:= )
133 + numa? ( sys-process/numactl )
134 +"
135 +
136 +# This set of dependencies is needed to run
137 +# prebuilt ghc. We specifically avoid ncurses
138 +# dependency with:
139 +# utils/ghc-pkg_HC_OPTS += -DBOOTSTRAPPING
140 +PREBUILT_BINARY_DEPENDS="
141 + !prefix? ( elibc_glibc? ( >=sys-libs/glibc-2.17 ) )
142 +"
143 +# This set of dependencies is needed to install
144 +# ghc[binary] in system. terminfo package is linked
145 +# against ncurses.
146 +PREBUILT_BINARY_RDEPENDS="${PREBUILT_BINARY_DEPENDS}
147 + sys-libs/ncurses:0/6
148 +"
149 +
150 +RDEPEND+="binary? ( ${PREBUILT_BINARY_RDEPENDS} )"
151 +
152 +DEPEND="${RDEPEND}
153 + doc? ( app-text/docbook-xml-dtd:4.2
154 + app-text/docbook-xml-dtd:4.5
155 + app-text/docbook-xsl-stylesheets
156 + dev-python/sphinx
157 + >=dev-libs/libxslt-1.1.2 )
158 + !ghcbootstrap? ( ${PREBUILT_BINARY_DEPENDS} )"
159 +
160 +# we build binaries without profiling support
161 +REQUIRED_USE="
162 + ?? ( ghcbootstrap binary )
163 + ?? ( profile binary )
164 +"
165 +
166 +# haskell libraries built with cabal in configure mode, #515354
167 +QA_CONFIGURE_OPTIONS+=" --with-compiler --with-gcc"
168 +
169 +is_crosscompile() {
170 + [[ ${CHOST} != ${CTARGET} ]]
171 +}
172 +
173 +is_native() {
174 + [[ ${CHOST} == ${CBUILD} ]] && [[ ${CHOST} == ${CTARGET} ]]
175 +}
176 +
177 +if ! is_crosscompile; then
178 + PDEPEND="!ghcbootstrap? ( >=app-admin/haskell-updater-1.2 )"
179 +fi
180 +
181 +# returns tool prefix for crosscompiler.
182 +# Example:
183 +# CTARGET=armv7a-unknown-linux-gnueabi
184 +# CHOST=x86_64-pc-linux-gnu
185 +# "armv7a-unknown-linux-gnueabi-"
186 +# CTARGET=${CHOST}
187 +# ""
188 +# Used in tools and library prefix:
189 +# "${ED}"/usr/bin/$(cross)haddock
190 +# "${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d"
191 +
192 +cross() {
193 + if is_crosscompile; then
194 + echo "${CTARGET}-"
195 + else
196 + echo ""
197 + fi
198 +}
199 +
200 +append-ghc-cflags() {
201 + local persistent compile assemble link
202 + local flag ghcflag
203 +
204 + for flag in $*; do
205 + case ${flag} in
206 + persistent) persistent="yes";;
207 + compile) compile="yes";;
208 + assemble) assemble="yes";;
209 + link) link="yes";;
210 + *)
211 + [[ ${compile} ]] && ghcflag="-optc${flag}" CFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" &&
212 + [[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}"
213 + [[ ${assemble} ]] && ghcflag="-opta${flag}" CFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" &&
214 + [[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}"
215 + [[ ${link} ]] && ghcflag="-optl${flag}" LDFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" &&
216 + [[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}"
217 + ;;
218 + esac
219 + done
220 +}
221 +
222 +# $1 - lib name (under libraries/)
223 +# $2 - lib version
224 +# example: bump_lib "transformers" "0.4.2.0"
225 +bump_lib() {
226 + local pn=$1 pv=$2
227 + local p=${pn}-${pv}
228 + local f
229 +
230 + einfo "Bumping ${pn} up to ${pv}"
231 +
232 + for f in ghc.mk GNUmakefile; do
233 + mv libraries/"${pn}"/$f "${WORKDIR}"/"${p}"/$f || die
234 + done
235 + mv libraries/"${pn}" "${WORKDIR}"/"${pn}".old || die
236 + mv "${WORKDIR}"/"${p}" libraries/"${pn}" || die
237 +}
238 +
239 +update_SRC_URI() {
240 + local p pn pv
241 + for p in "${BUMP_LIBRARIES[@]}"; do
242 + set -- $p
243 + pn=$1 pv=$2
244 +
245 + SRC_URI+=" https://hackage.haskell.org/package/${pn}-${pv}/${pn}-${pv}.tar.gz"
246 + done
247 +}
248 +
249 +update_SRC_URI
250 +
251 +bump_libs() {
252 + local p pn pv
253 + for p in "${BUMP_LIBRARIES[@]}"; do
254 + set -- $p
255 + pn=$1 pv=$2
256 +
257 + bump_lib "${pn}" "${pv}"
258 + done
259 +}
260 +
261 +ghc_setup_cflags() {
262 + # TODO: plumb CFLAGS and BUILD_CFLAGS to respective CONF_CC_OPTS_STAGE<N>
263 + if ! is_native; then
264 + export CFLAGS=${GHC_CFLAGS-"-O2 -pipe"}
265 + export LDFLAGS=${GHC_LDFLAGS-"-Wl,-O1"}
266 + einfo "Crosscompiling mode:"
267 + einfo " CHOST: ${CHOST}"
268 + einfo " CTARGET: ${CTARGET}"
269 + einfo " CFLAGS: ${CFLAGS}"
270 + einfo " LDFLAGS: ${LDFLAGS}"
271 + einfo " prefix: $(cross)"
272 + return
273 + fi
274 + # We need to be very careful with the CFLAGS we ask ghc to pass through to
275 + # gcc. There are plenty of flags which will make gcc produce output that
276 + # breaks ghc in various ways. The main ones we want to pass through are
277 + # -mcpu / -march flags. These are important for arches like alpha & sparc.
278 + # We also use these CFLAGS for building the C parts of ghc, ie the rts.
279 + strip-flags
280 + strip-unsupported-flags
281 +
282 + # Cmm can't parse line numbers #482086
283 + replace-flags -ggdb[3-9] -ggdb2
284 +
285 + GHC_FLAGS=""
286 + GHC_PERSISTENT_FLAGS=""
287 + for flag in ${CFLAGS}; do
288 + case ${flag} in
289 +
290 + # Ignore extra optimisation (ghc passes -O to gcc anyway)
291 + # -O2 and above break on too many systems
292 + -O*) ;;
293 +
294 + # Arch and ABI flags are what we're really after
295 + -m*) append-ghc-cflags compile assemble ${flag};;
296 +
297 + # Sometimes it's handy to see backtrace of RTS
298 + # to get an idea what happens there
299 + -g*) append-ghc-cflags compile ${flag};;
300 +
301 + # Ignore all other flags, including all -f* flags
302 + esac
303 + done
304 +
305 + for flag in ${LDFLAGS}; do
306 + append-ghc-cflags link ${flag}
307 + done
308 +
309 + # GHC uses ${CBUILD}-gcc, ${CHOST}-gcc and ${CTARGET}-gcc at a single build.
310 + # Skip any gentoo-specific tweaks for cross-case to avoid passing unsupported
311 + # options to gcc.
312 + if is_native; then
313 + # prevent from failing to build unregisterised ghc:
314 + # https://www.mail-archive.com/debian-bugs-dist@××××××××××××.org/msg171602.html
315 + use ppc64 && append-ghc-cflags persistent compile -mminimal-toc
316 + fi
317 +}
318 +
319 +# substitutes string $1 to $2 in files $3 $4 ...
320 +relocate_path() {
321 + local from=$1
322 + local to=$2
323 + shift 2
324 + local file=
325 + for file in "$@"
326 + do
327 + sed -i -e "s|$from|$to|g" \
328 + "$file" || die "path relocation failed for '$file'"
329 + done
330 +}
331 +
332 +# changes hardcoded ghc paths and updates package index
333 +# $1 - new absolute root path
334 +relocate_ghc() {
335 + local to=$1 ghc_v=${BIN_PV}
336 +
337 + # libdir for prebuilt binary and for current system may mismatch
338 + # It does for prefix installation for example: bug #476998
339 + local bin_ghc_prefix=${WORKDIR}/usr
340 + local bin_libpath=$(echo "${bin_ghc_prefix}"/lib*)
341 + local bin_libdir=${bin_libpath#${bin_ghc_prefix}/}
342 +
343 + # backup original script to use it later after relocation
344 + local gp_back="${T}/ghc-pkg-${ghc_v}-orig"
345 + cp "${WORKDIR}/usr/bin/ghc-pkg-${ghc_v}" "$gp_back" || die "unable to backup ghc-pkg wrapper"
346 +
347 + if [[ ${bin_libdir} != $(get_libdir) ]]; then
348 + einfo "Relocating '${bin_libdir}' to '$(get_libdir)' (bug #476998)"
349 + # moving the dir itself is not strictly needed
350 + # but then USE=binary would result in installing
351 + # in '${bin_libdir}'
352 + mv "${bin_ghc_prefix}/${bin_libdir}" "${bin_ghc_prefix}/$(get_libdir)" || die
353 +
354 + relocate_path "/usr/${bin_libdir}" "/usr/$(get_libdir)" \
355 + "${WORKDIR}/usr/bin/ghc-${ghc_v}" \
356 + "${WORKDIR}/usr/bin/ghci-${ghc_v}" \
357 + "${WORKDIR}/usr/bin/ghc-pkg-${ghc_v}" \
358 + "${WORKDIR}/usr/bin/hsc2hs" \
359 + "${WORKDIR}/usr/bin/runghc-${ghc_v}" \
360 + "$gp_back" \
361 + "${WORKDIR}/usr/$(get_libdir)/${PN}-${ghc_v}/package.conf.d/"*
362 + fi
363 +
364 + # Relocate from /usr to ${EPREFIX}/usr
365 + relocate_path "/usr" "${to}/usr" \
366 + "${WORKDIR}/usr/bin/ghc-${ghc_v}" \
367 + "${WORKDIR}/usr/bin/ghci-${ghc_v}" \
368 + "${WORKDIR}/usr/bin/ghc-pkg-${ghc_v}" \
369 + "${WORKDIR}/usr/bin/haddock-ghc-${ghc_v}" \
370 + "${WORKDIR}/usr/bin/hp2ps" \
371 + "${WORKDIR}/usr/bin/hpc" \
372 + "${WORKDIR}/usr/bin/hsc2hs" \
373 + "${WORKDIR}/usr/bin/runghc-${ghc_v}" \
374 + "${WORKDIR}/usr/$(get_libdir)/${PN}-${ghc_v}/package.conf.d/"*
375 +
376 + # this one we will use to regenerate cache
377 + # so it should point to current tree location
378 + relocate_path "/usr" "${WORKDIR}/usr" "$gp_back"
379 +
380 + if use prefix; then
381 + hprefixify "${bin_libpath}"/${PN}*/settings
382 + fi
383 +
384 + # regenerate the binary package cache
385 + "$gp_back" recache || die "failed to update cache after relocation"
386 + rm "$gp_back"
387 +}
388 +
389 +ghc-check-reqs() {
390 + # These are pessimistic values (slightly bigger than worst-case)
391 + # Worst case is UNREG USE=profile ia64. See bug #611866 for some
392 + # numbers on various arches.
393 + CHECKREQS_DISK_BUILD=8G
394 + CHECKREQS_DISK_USR=2G
395 + # USE=binary roughly takes
396 + use binary && CHECKREQS_DISK_BUILD=4G
397 +
398 + "$@"
399 +}
400 +
401 +pkg_pretend() {
402 + ghc-check-reqs check-reqs_pkg_pretend
403 +}
404 +
405 +pkg_setup() {
406 + ghc-check-reqs check-reqs_pkg_setup
407 +
408 + # quiet portage about prebuilt binaries
409 + use binary && QA_PREBUILT="*"
410 +
411 + [[ ${MERGE_TYPE} == binary ]] && return
412 +
413 + if use ghcbootstrap; then
414 + ewarn "You requested ghc bootstrapping, this is usually only used"
415 + ewarn "by Gentoo developers to make binary .tbz2 packages."
416 +
417 + [[ -z $(type -P ghc) ]] && \
418 + die "Could not find a ghc to bootstrap with."
419 + else
420 + if ! yet_binary; then
421 + eerror "Please try emerging with USE=ghcbootstrap and report build"
422 + eerror "sucess or failure to the haskell team (haskell@g.o)"
423 + die "No binary available for '${ARCH}' arch yet, USE=ghcbootstrap"
424 + fi
425 + fi
426 +}
427 +
428 +src_unpack() {
429 + # Create the ${S} dir if we're using the binary version
430 + use binary && mkdir "${S}"
431 +
432 + # the Solaris and Darwin binaries from ghc (maeder) need to be
433 + # unpacked separately, so prevent them from being unpacked
434 + local ONLYA=${A}
435 + case ${CHOST} in
436 + *-darwin* | *-solaris*) ONLYA=${GHC_P}-src.tar.xz ;;
437 + esac
438 + unpack ${ONLYA}
439 +}
440 +
441 +src_prepare() {
442 + ghc_setup_cflags
443 +
444 + if ! use ghcbootstrap && [[ ${CHOST} != *-darwin* && ${CHOST} != *-solaris* ]]; then
445 + # Modify the wrapper script from the binary tarball to use GHC_PERSISTENT_FLAGS.
446 + # See bug #313635.
447 + sed -i -e "s|\"\$topdir\"|\"\$topdir\" ${GHC_PERSISTENT_FLAGS}|" \
448 + "${WORKDIR}/usr/bin/ghc-${BIN_PV}"
449 +
450 + # allow hardened users use vanilla binary to bootstrap ghc
451 + # ghci uses mmap with rwx protection at it implements dynamic
452 + # linking on it's own (bug #299709)
453 + pax-mark -m "${WORKDIR}/usr/$(get_libdir)/${PN}-${BIN_PV}/bin/ghc"
454 + fi
455 +
456 + if use binary; then
457 + if use prefix; then
458 + relocate_ghc "${EPREFIX}"
459 + fi
460 +
461 + # Move unpacked files to the expected place
462 + mv "${WORKDIR}/usr" "${S}"
463 + eapply_user
464 + else
465 + if ! use ghcbootstrap; then
466 + case ${CHOST} in
467 + *-darwin* | *-solaris*)
468 + # UPDATE ME for ghc-7
469 + mkdir "${WORKDIR}"/ghc-bin-installer || die
470 + pushd "${WORKDIR}"/ghc-bin-installer > /dev/null || die
471 + use sparc-solaris && unpack ghc-6.10.4-sparc-sun-solaris2.tar.bz2
472 + use x86-solaris && unpack ghc-7.0.3-i386-unknown-solaris2.tar.bz2
473 + use x86-macos && unpack ghc-7.4.1-i386-apple-darwin.tar.bz2
474 + use x64-macos && unpack ghc-7.4.1-x86_64-apple-darwin.tar.bz2
475 + popd > /dev/null
476 +
477 + pushd "${WORKDIR}"/ghc-bin-installer/ghc-[67].?*.? > /dev/null || die
478 + # fix the binaries so they run, on Solaris we need an
479 + # LD_LIBRARY_PATH which has our prefix libdirs, on
480 + # Darwin we need to replace the frameworks with our libs
481 + # from the prefix fix before installation, because some
482 + # of the tools are actually used during configure/make
483 + if [[ ${CHOST} == *-solaris* ]] ; then
484 + export LD_LIBRARY_PATH="${EPREFIX}/$(get_libdir):${EPREFIX}/usr/$(get_libdir):${LD_LIBRARY_PATH}"
485 + elif [[ ${CHOST} == *-darwin* ]] ; then
486 + local readline_framework=GNUreadline.framework/GNUreadline
487 + local gmp_framework=/opt/local/lib/libgmp.10.dylib
488 + local ncurses_file=/opt/local/lib/libncurses.5.dylib
489 + for binary in $(scanmacho -BRE MH_EXECUTE -F '%F' .) ; do
490 + install_name_tool -change \
491 + ${readline_framework} \
492 + "${EPREFIX}"/lib/libreadline.dylib \
493 + ${binary} || die
494 + install_name_tool -change \
495 + ${gmp_framework} \
496 + "${EPREFIX}"/usr/lib/libgmp.dylib \
497 + ${binary} || die
498 + install_name_tool -change \
499 + ${ncurses_file} \
500 + "${EPREFIX}"/usr/lib/libncurses.dylib \
501 + ${binary} || die
502 + done
503 + # we don't do frameworks!
504 + sed -i \
505 + -e 's/\(frameworks = \)\["GMP"\]/\1[]/g' \
506 + -e 's/\(extraLibraries = \)\["m"\]/\1["m","gmp"]/g' \
507 + rts/package.conf.in || die
508 + fi
509 +
510 + # it is autoconf, but we really don't want to give it too
511 + # many arguments, in fact we do the make in-place anyway
512 + ./configure --prefix="${WORKDIR}"/usr || die
513 + make install || die
514 + popd > /dev/null
515 + ;;
516 + *)
517 + relocate_ghc "${WORKDIR}"
518 + ;;
519 + esac
520 + fi
521 +
522 + sed -i -e "s|\"\$topdir\"|\"\$topdir\" ${GHC_PERSISTENT_FLAGS}|" \
523 + "${S}/ghc/ghc.wrapper"
524 +
525 + cd "${S}" # otherwise eapply will break
526 +
527 + eapply "${FILESDIR}"/${PN}-7.0.4-CHOST-prefix.patch
528 + eapply "${FILESDIR}"/${PN}-8.2.1-darwin.patch
529 + eapply "${FILESDIR}"/${PN}-7.8.3-prim-lm.patch
530 + eapply "${FILESDIR}"/${PN}-8.8.1-revert-CPP.patch
531 + eapply "${FILESDIR}"/${PN}-8.10.1-allow-cross-bootstrap.patch
532 +
533 + # a bunch of crosscompiler patches
534 + # needs newer version:
535 + #eapply "${FILESDIR}"/${PN}-8.2.1_rc1-hp2ps-cross.patch
536 +
537 + # mingw32 target
538 + pushd "${S}/libraries/Win32"
539 + eapply "${FILESDIR}"/${PN}-8.2.1_rc1-win32-cross-2-hack.patch # bad workaround
540 + popd
541 +
542 + bump_libs
543 +
544 + eapply_user
545 + # as we have changed the build system
546 + eautoreconf
547 + fi
548 +}
549 +
550 +src_configure() {
551 + if ! use binary; then
552 + # initialize build.mk
553 + echo '# Gentoo changes' > mk/build.mk
554 +
555 + # Put docs into the right place, ie /usr/share/doc/ghc-${GHC_PV}
556 + echo "docdir = ${EPREFIX}/usr/share/doc/$(cross)${P}" >> mk/build.mk
557 + echo "htmldir = ${EPREFIX}/usr/share/doc/$(cross)${P}" >> mk/build.mk
558 +
559 + # We also need to use the GHC_FLAGS flags when building ghc itself
560 + echo "SRC_HC_OPTS+=${HCFLAGS} ${GHC_FLAGS}" >> mk/build.mk
561 + echo "SRC_CC_OPTS+=${CFLAGS}" >> mk/build.mk
562 + echo "SRC_LD_OPTS+=${LDFLAGS}" >> mk/build.mk
563 + # Speed up initial Cabal bootstrap
564 + echo "utils/ghc-cabal_dist_EXTRA_HC_OPTS+=$(ghc-make-args)" >> mk/build.mk
565 +
566 + # We can't depend on haddock except when bootstrapping when we
567 + # must build docs and include them into the binary .tbz2 package
568 + # app-text/dblatex is not in portage, can not build PDF or PS
569 + echo "BUILD_SPHINX_PDF = NO" >> mk/build.mk
570 + echo "BUILD_SPHINX_HTML = $(usex doc YES NO)" >> mk/build.mk
571 + echo "BUILD_MAN = $(usex doc YES NO)" >> mk/build.mk
572 +
573 + # this controls presence on 'xhtml' and 'haddock' in final install
574 + echo "HADDOCK_DOCS = YES" >> mk/build.mk
575 +
576 + # not used outside of ghc's test
577 + if [[ -n ${GHC_BUILD_DPH} ]]; then
578 + echo "BUILD_DPH = YES" >> mk/build.mk
579 + else
580 + echo "BUILD_DPH = NO" >> mk/build.mk
581 + fi
582 +
583 + # Any non-native build has to skip as it needs
584 + # target haddock binary to be runnabine.
585 + if ! is_native; then
586 + # disable docs generation as it requires running stage2
587 + echo "HADDOCK_DOCS=NO" >> mk/build.mk
588 + echo "BUILD_SPHINX_HTML=NO" >> mk/build.mk
589 + echo "BUILD_SPHINX_PDF=NO" >> mk/build.mk
590 + fi
591 +
592 + if is_crosscompile; then
593 + # Install ghc-stage1 crosscompiler instead of
594 + # ghc-stage2 cross-built compiler.
595 + echo "Stage1Only=YES" >> mk/build.mk
596 + fi
597 +
598 + # allows overriding build flavours for libraries:
599 + # v - vanilla (static libs)
600 + # p - profiled
601 + # dyn - shared libraries
602 + # example: GHC_LIBRARY_WAYS="v dyn"
603 + if [[ -n ${GHC_LIBRARY_WAYS} ]]; then
604 + echo "GhcLibWays=${GHC_LIBRARY_WAYS}" >> mk/build.mk
605 + fi
606 + echo "BUILD_PROF_LIBS = $(usex profile YES NO)" >> mk/build.mk
607 +
608 + # Get ghc from the unpacked binary .tbz2
609 + # except when bootstrapping we just pick ghc up off the path
610 + if ! use ghcbootstrap; then
611 + export PATH="${WORKDIR}/usr/bin:${PATH}"
612 + fi
613 +
614 + echo "INTEGER_LIBRARY = $(usex gmp integer-gmp integer-simple)" >> mk/build.mk
615 +
616 + # don't strip anything. Very useful when stage2 SIGSEGVs on you
617 + echo "STRIP_CMD = :" >> mk/build.mk
618 +
619 + local econf_args=()
620 +
621 + # GHC embeds toolchain it was built by and uses it later.
622 + # Don't allow things like ccache or versioned binary slip.
623 + # We use stable thing across gcc upgrades.
624 + # User can use EXTRA_ECONF=CC=... to override this default.
625 + econf_args+=(
626 + AR=${CTARGET}-ar
627 + CC=${CTARGET}-gcc
628 + # these should be inferred by GHC but ghc defaults
629 + # to using bundled tools on windows.
630 + Windres=${CTARGET}-windres
631 + DllWrap=${CTARGET}-dllwrap
632 + # we set the linker explicitly below
633 + --disable-ld-override
634 + )
635 + case ${CTARGET} in
636 + arm*)
637 + # ld.bfd-2.28 does not work for ghc. Force ld.gold
638 + # instead. This should be removed once gentoo gets
639 + # a fix for R_ARM_COPY bug: https://sourceware.org/PR16177
640 + econf_args+=(LD=${CTARGET}-ld.gold)
641 + ;;
642 + sparc*)
643 + # ld.gold-2.28 does not work for ghc. Force ld.bfd
644 + # instead. This should be removed once gentoo gets
645 + # a fix for missing --no-relax support bug:
646 + # https://sourceware.org/ml/binutils/2017-07/msg00183.html
647 + econf_args+=(LD=${CTARGET}-ld.bfd)
648 + ;;
649 + *)
650 + econf_args+=(LD=${CTARGET}-ld)
651 + esac
652 +
653 + if [[ ${CBUILD} != ${CHOST} ]]; then
654 + # GHC bug: ghc claims not to support cross-building.
655 + # It does, but does not distinct --host= value
656 + # for stage1 and stage2 compiler.
657 + econf_args+=(--host=${CBUILD})
658 + fi
659 +
660 + if use ghcmakebinary; then
661 + # When building booting libary we are trying to
662 + # bundle or restrict most of external depends
663 + # with unstable ABI:
664 + # - embed libffi (default GHC behaviour)
665 + # - disable ncurses support for ghci (via haskeline)
666 + # https://bugs.gentoo.org/557478
667 + # - disable ncurses support for ghc-pkg
668 + echo "libraries/haskeline_CONFIGURE_OPTS += --flag=-terminfo" >> mk/build.mk
669 + echo "utils/ghc-pkg_HC_OPTS += -DBOOTSTRAPPING" >> mk/build.mk
670 + elif is_native; then
671 + # using ${GTARGET}'s libffi is not supported yet:
672 + # GHC embeds full path for ffi includes without /usr/${CTARGET} account.
673 + econf_args+=(--with-system-libffi)
674 + econf_args+=(--with-ffi-includes=$($(tc-getPKG_CONFIG) libffi --cflags-only-I | sed -e 's@^-I@@'))
675 + fi
676 +
677 + einfo "Final mk/build.mk:"
678 + cat mk/build.mk || die
679 +
680 + econf ${econf_args[@]} \
681 + --enable-bootstrap-with-devel-snapshot \
682 + $(use_enable elfutils dwarf-unwind) \
683 + $(use_enable numa)
684 +
685 + if [[ ${PV} == *9999* ]]; then
686 + GHC_PV="$(grep 'S\[\"PACKAGE_VERSION\"\]' config.status | sed -e 's@^.*=\"\(.*\)\"@\1@')"
687 + GHC_P=${PN}-${GHC_PV}
688 + fi
689 + fi # ! use binary
690 +}
691 +
692 +src_compile() {
693 + if ! use binary; then
694 + # Stage1Only crosscompiler does not build stage2
695 + if ! is_crosscompile; then
696 + # 1. build/pax-mark compiler binary first
697 + emake ghc/stage2/build/tmp/ghc-stage2
698 + # 2. pax-mark (bug #516430)
699 + pax-mark -m ghc/stage2/build/tmp/ghc-stage2
700 + # 2. build/pax-mark haddock using ghc-stage2
701 + if is_native; then
702 + # non-native build does not build haddock
703 + # due to HADDOCK_DOCS=NO, but it could.
704 + emake utils/haddock/dist/build/tmp/haddock
705 + pax-mark -m utils/haddock/dist/build/tmp/haddock
706 + fi
707 + fi
708 + # 3. and then all the rest
709 + emake all
710 + fi # ! use binary
711 +}
712 +
713 +src_test() {
714 + # TODO: deal with:
715 + # - sandbox (pollutes environment)
716 + # - extra packages (to extend testsuite coverage)
717 + # bits are taken from 'validate'
718 + local make_test_target='test' # can be fulltest
719 + # not 'emake' as testsuite uses '$MAKE' without jobserver available
720 + make $make_test_target stage=2 THREADS=$(makeopts_jobs)
721 +}
722 +
723 +src_install() {
724 + if use binary; then
725 + use prefix && mkdir -p "${ED}"
726 + mv "${S}/usr" "${ED}"
727 + else
728 + [[ -f VERSION ]] || emake VERSION
729 +
730 + # -j1 due to a rare race in install script:
731 + # make --no-print-directory -f ghc.mk phase=final install
732 + # /usr/lib/portage/python3.4/ebuild-helpers/xattr/install -c -m 755 \
733 + # -d "/tmp/portage-tmpdir/portage/cross-armv7a-unknown-linux-gnueabi/ghc-9999/image/usr/lib64/armv7a-unknown-linux-gnueabi-ghc-8.3.20170404/include"
734 + # /usr/lib/portage/python3.4/ebuild-helpers/xattr/install -c -m 644 utils/hsc2hs/template-hsc.h \
735 + # "/tmp/portage-tmpdir/portage/cross-armv7a-unknown-linux-gnueabi/ghc-9999/image/usr/lib64/armv7a-unknown-linux-gnueabi-ghc-8.3.20170404"
736 + # /usr/bin/install: cannot create regular file \
737 + # '/tmp/portage-tmpdir/portage/cross-armv7a-unknown-linux-gnueabi/ghc-9999/image/usr/lib64/armv7a-unknown-linux-gnueabi-ghc-8.3.20170404': No such file or directory
738 + emake -j1 install DESTDIR="${D}"
739 +
740 + # Skip for cross-targets as they all share target location:
741 + # /usr/share/doc/ghc-9999/
742 + if ! is_crosscompile; then
743 + dodoc "distrib/README" "LICENSE" "VERSION"
744 + fi
745 +
746 + # rename ghc-shipped files to avoid collision
747 + # of external packages. Motivating example:
748 + # user had installed:
749 + # dev-lang/ghc-7.8.4-r0 (with transformers-0.3.0.0)
750 + # dev-haskell/transformers-0.4.2.0
751 + # then user tried to update to
752 + # dev-lang/ghc-7.8.4-r1 (with transformers-0.4.2.0)
753 + # this will lead to single .conf file collision.
754 + local shipped_conf renamed_conf
755 + local package_confdir="${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d"
756 + for shipped_conf in "${package_confdir}"/*.conf; do
757 + # rename 'pkg-ver-id.conf' to 'pkg-ver-id-gentoo-${PF}.conf'
758 + renamed_conf=${shipped_conf%.conf}-gentoo-${PF}.conf
759 + mv "${shipped_conf}" "${renamed_conf}" || die
760 + done
761 +
762 + # remove link, but leave 'haddock-${GHC_P}'
763 + rm -f "${ED}"/usr/bin/$(cross)haddock
764 +
765 + if ! is_crosscompile; then
766 + newbashcomp "${FILESDIR}"/ghc-bash-completion ghc-pkg
767 + newbashcomp utils/completion/ghc.bash ghc
768 + fi
769 + fi
770 +
771 + # path to the package.cache
772 + local package_confdir="${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d"
773 + PKGCACHE="${package_confdir}"/package.cache
774 + # copy the package.conf.d, including timestamp, save it so we can help
775 + # users that have a broken package.conf.d
776 + cp -pR "${package_confdir}"{,.initial} || die "failed to backup intial package.conf.d"
777 +
778 + # copy the package.conf, including timestamp, save it so we later can put it
779 + # back before uninstalling, or when upgrading.
780 + cp -p "${PKGCACHE}"{,.shipped} \
781 + || die "failed to copy package.conf.d/package.cache"
782 +
783 + if is_crosscompile; then
784 + # When we build a cross-compiler the layout is the following:
785 + # usr/lib/${CTARGET}-ghc-${VER}/ contains target libraries
786 + # but
787 + # usr/lib/${CTARGET}-ghc-${VER}/bin/ directory
788 + # containst host binaries (modulo bugs).
789 +
790 + # Portage's stripping mechanism does not skip stripping
791 + # foreign binaries. This frequently causes binaries to be
792 + # broken.
793 + #
794 + # Thus below we disable stripping of target libraries and allow
795 + # stripping hosts executables.
796 + dostrip -x "/usr/$(get_libdir)/$(cross)${GHC_P}"
797 + dostrip "/usr/$(get_libdir)/$(cross)${GHC_P}/bin"
798 + fi
799 +}
800 +
801 +pkg_preinst() {
802 + # have we got an earlier version of ghc installed?
803 + if has_version "<${CATEGORY}/${PF}"; then
804 + haskell_updater_warn="1"
805 + fi
806 +}
807 +
808 +pkg_postinst() {
809 + ghc-reregister
810 +
811 + # path to the package.cache
812 + PKGCACHE="${EROOT}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d/package.cache"
813 +
814 + # give the cache a new timestamp, it must be as recent as
815 + # the package.conf.d directory.
816 + touch "${PKGCACHE}"
817 +
818 + if [[ "${haskell_updater_warn}" == "1" ]]; then
819 + ewarn
820 + ewarn "\e[1;31m************************************************************************\e[0m"
821 + ewarn
822 + ewarn "You have just upgraded from an older version of GHC."
823 + ewarn "You may have to run"
824 + ewarn " 'haskell-updater'"
825 + ewarn "to rebuild all ghc-based Haskell libraries."
826 + ewarn
827 + ewarn "\e[1;31m************************************************************************\e[0m"
828 + ewarn
829 + fi
830 +}
831 +
832 +pkg_prerm() {
833 + PKGCACHE="${EROOT}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d/package.cache"
834 + rm -rf "${PKGCACHE}"
835 +
836 + cp -p "${PKGCACHE}"{.shipped,}
837 +}
838 +
839 +pkg_postrm() {
840 + ghc-package_pkg_postrm
841 +}