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