1 |
commit: 08a41d2dff99645af6ac5a7bb4774f5f193b6f20 |
2 |
Author: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Jul 23 11:15:24 2017 +0000 |
4 |
Commit: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Jul 23 11:15:34 2017 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=08a41d2d |
7 |
|
8 |
dev-lang/ghc: bump up to 8.2.1 with x86 and amd64 binaries, no KEYWORDS yet |
9 |
|
10 |
Package-Manager: Portage-2.3.6, Repoman-2.3.3 |
11 |
|
12 |
dev-lang/ghc/Manifest | 3 + |
13 |
.../ghc/files/ghc-8.2.1_rc1-cgen-constify.patch | 378 ++++++++++ |
14 |
dev-lang/ghc/files/ghc-8.2.1_rc1-ghci-cross.patch | 60 ++ |
15 |
dev-lang/ghc/files/ghc-8.2.1_rc1-hp2ps-cross.patch | 104 +++ |
16 |
.../ghc/files/ghc-8.2.1_rc1-stage2-cross.patch | 81 +++ |
17 |
.../ghc/files/ghc-8.2.1_rc1-staged-cross.patch | 43 ++ |
18 |
.../ghc/files/ghc-8.2.1_rc1-unphased-cross.patch | 30 + |
19 |
.../ghc/files/ghc-8.2.1_rc1-win32-cross-1.patch | 124 ++++ |
20 |
.../files/ghc-8.2.1_rc1-win32-cross-2-hack.patch | 144 ++++ |
21 |
dev-lang/ghc/files/ghc-8.2.1_rc2-O2-unreg.patch | 35 + |
22 |
dev-lang/ghc/files/ghc-8.2.1_rc3-any-vendor.patch | 44 ++ |
23 |
.../ghc/files/ghc-8.2.1_rc3-stginit-data.patch | 27 + |
24 |
dev-lang/ghc/ghc-8.2.1.ebuild | 770 +++++++++++++++++++++ |
25 |
13 files changed, 1843 insertions(+) |
26 |
|
27 |
diff --git a/dev-lang/ghc/Manifest b/dev-lang/ghc/Manifest |
28 |
index bbffd086951..1e20c41e682 100644 |
29 |
--- a/dev-lang/ghc/Manifest |
30 |
+++ b/dev-lang/ghc/Manifest |
31 |
@@ -3,6 +3,7 @@ DIST ghc-7.10.3-src.tar.bz2 13281867 SHA256 3e29a56a74ed6a74d3ee2a6db9389f246283 |
32 |
DIST ghc-7.8.4-ia64-CLOSUREs-regenerated.patch.gz 13268 SHA256 3bdff22e654aee6f942d43edf1bf6cf70404c0152c4fcf89276f10d2c4c5b4b9 SHA512 a655713e06324b56f0041edf70837487e296d28e6f3ee35fe116b9938765aaf3469d25e92645e0940655ed3607dff27d3826fe0f995c84e81b51bfc956816e7d WHIRLPOOL d2cb53bdc6debc0278d554168ea3ab22b0fd8314adac81444637278a92d21b766280fedfb4b7d1b4540c7381c7962dec6b13a799ab2fee4d456fe2875d5c6a5b |
33 |
DIST ghc-7.8.4-src.tar.bz2 10600755 SHA256 59e3bd514a1820cc1c03e1808282205c0b8518369acae12645ceaf839e6f114b SHA512 079a53891d8ebd8d9b88da96170e60981608a619f8282e4b7948f35244e99bd87277649ac7fcebc227a61a4d21960db8d5e5b9e92f2c69c82d8d68d7fd0a41d3 WHIRLPOOL a9be7641adbd237ed6e0f644c312e655e98be9566097aee5e2c0022e8756d5b2236e42dd86d76c638a001b5ca3f67307e89ec0cd003a92cd112a5d6d3e3d8467 |
34 |
DIST ghc-8.0.2-src.tar.xz 10687760 SHA256 11625453e1d0686b3fa6739988f70ecac836cadc30b9f0c8b49ef9091d6118b1 SHA512 58ea3853cd93b556ecdc4abd0be079b2621171b8491f59004ea4e036a4cba4470aaafe6591b942e0a50a64bdc47540e01fe6900212a1ef7087850112d9bfc5ef WHIRLPOOL 5ffd94f797c32c87d9d818acbb1a41f2c140d6f1da169854aab6eece7a41499b55fc573f9a4fbcccf09dcfc92e460d8c91be5efd8650837e8bfba009b04261b1 |
35 |
+DIST ghc-8.2.1-src.tar.xz 10736016 SHA256 cfc2d496708dacea3ea7dde4c6a4b921b97a7f550ee2acea44cfa535840593f0 SHA512 d9aa2aa7f9414db8f4e51d6c275694b46df515e68331a1a2b6018256333a2c63ebd877b75ee90407ecce5be672ec9afc6bebd62aadbf8ae06b94f1760d1736be WHIRLPOOL ecbdf8e3f330ef329fab21865c5f063763a2320e03063aeb8777f6c4769a86b33504c0548df9c6ce859028277851e6e7482b7c3b62986c6186745f894e7567d9 |
36 |
DIST ghc-bin-7.10.3-alpha.tbz2 183558856 SHA256 780ac45b9b38fb40f08eeb7dae741649ac19dce2271df4bc764cac9be6c5c225 SHA512 08709fe9b4036ab41715c9a637a2a160104e3ab9e0ed9efaaf73428e3cfe19619e50c42b72c60bbbd27be2b9c2ea68f63d72c1a27d4519756e7c0d909f724230 WHIRLPOOL f488ecc945c6100ba86b9ae25eb6a472693556be0205a6c8634f2c235e779fe17b391ced7fec5d89c0c6c3d21583fe9f9b80bf628f3307890becf3f3ffb57a96 |
37 |
DIST ghc-bin-7.10.3-amd64.tbz2 112040431 SHA256 c3c71aff288f7de2785d1c3d54f0fd636144eb3dcb590bdda087b0775203e517 SHA512 e1554b3944edbe8e16537de5a29132dc6a22d780d9a700cdc9b76387b94191164398d6f2242bf8199527802572e2bb02545569d4f0930a0ee0dbfdeb25978558 WHIRLPOOL c2497a9565abf7d37e7928f508f7bf7241dd529aa252da708517f9f067e3d016341b7a73cac34888b99c9b84a8d01fd9e8d76f2b332d53e0d708b078f20ee807 |
38 |
DIST ghc-bin-7.10.3-ia64.tbz2 238680956 SHA256 0da9b5966f0920341f4cf041b814817e1ed06060e8a491481ab19a68153767db SHA512 3694011aec8a6dc37889418b318993cb82f9b46a5175dd837713f396c8f59a19a920e0b0669fe3b4ec37d5bd8837c115264c0a8fc97c5a4ce06a3bdd52fcfce5 WHIRLPOOL 9e059a953607b6477ea7c27bf55175d838c6aa3c57fcf92f13fa6112e9e728037073047be300a5a757395d759d30545546cb46816ec879a2d31c3c0a78868e42 |
39 |
@@ -24,5 +25,7 @@ DIST ghc-bin-8.0.2-ia64.tbz2 250237654 SHA256 f3e74db697900d031c4d405310c3bf3f40 |
40 |
DIST ghc-bin-8.0.2-ppc.tbz2 144760090 SHA256 a261dd97df396296d1a94c311c757040f74284b812634d97734557915d0a44ca SHA512 bc6bf8998064ffc1692c3bb83c44d1787760a3f4a1e6b79dedaefda5fe32b9052049a60f0ddd3c0b0bd24a722fb35e310e0189b3511721ff89d4d02b3d7c14bb WHIRLPOOL b070acb230dccc2faed66002f4384c8c9b17ce58655b5861766582558a66236136b1d02ab6226c7de5c74960c7d2d37c3c0069e38dfa980730043f623df4baa6 |
41 |
DIST ghc-bin-8.0.2-ppc64.tbz2 117432068 SHA256 f2eb278c4d40d92233767d48149ec96a6c6097159ec846a984152c99a559803a SHA512 0eaff0557b68649a15bbeb2019f46fa9e9e7b8a916aa210ab56888090a5b887d20d818e7987177bc6a8e7fde503de560026e6bb55fe39679b8b1ee13c6b7c4f9 WHIRLPOOL 8a4ba955183cb7c94ecb59f62eab18a4ee75aa422d3c6e7172d347112b8445dccf86c718fcd84d3271dcb1f35fee0451fece184840403a02f7ed8bb39785075e |
42 |
DIST ghc-bin-8.0.2-x86.tbz2 133372061 SHA256 5e56bff6831a9c151d5d6f82db49b21d33bea05f05cdf74fca5adc423d546711 SHA512 020ce0e597e2907550c080f1bb0f863dbf83d5d45df2b3f44173506475bc4ef5423c5a060fdacd87614c3ec398ad94c2dcab9cff0376a54a2c54c2eb1e2f657d WHIRLPOOL 221eae08caff5c2157fae7df901c94d6d1393be3ab0526bb9d8a80d4304af4c4a420fcc2fe62926bf01c3bb02f161f1eb61c7eb47d3c6801cfacb25c1a33e983 |
43 |
+DIST ghc-bin-8.2.1-i686-pc-linux-gnu.tbz2 96157437 SHA256 2a05584fd51a4e9040a3611a0687d814b62b28c5ccd4102b00cf8bbfecadeec9 SHA512 e891e76557fa61853e28829b8bedc4a6abb92954f90cc1ebcf22a13cc137556bbe9262e7398b7e1aedbabeb997916b008bf1561a52f16a569f3d58ea9404f41e WHIRLPOOL c955dbc501b6c3effe08a91ba8b6584e74b224427c56232744c4ddedad72039e2cdb2f3ea1193e6ae2e7fd8a46a947cf7a835399c81f5dd5568c3ce1ad8a5adc |
44 |
+DIST ghc-bin-8.2.1-x86_64-pc-linux-gnu.tbz2 97490496 SHA256 b67f4f7518a4e2ec5cfc0434dde0365cbfe37c4c7e164e9e8e38199bb6f083cd SHA512 52630a185d0eab56bce0469a612a54109895bfee041ec362ced59a9b35ba3b9c185e86bc7dbf0a5939081d3626baa19fbb3306e36d1857530248a7b9bfc100bb WHIRLPOOL 7998e0c351bd6943bd351909f5e9af0146a3e08f04141fc54807ebea994e4bbcec44247c885865eaa5af8786dfb514eed4fffc35ffaabe81f2d7f8a856ed10d9 |
45 |
DIST hoopl-3.10.2.0.tar.gz 241940 SHA256 6740814c774e51815e8260ae1b4ac8af6ab69f02e112904450f689c4792f1121 SHA512 083baa8a5eb53247aff8d5b9b2144e0f63adb9400934297bbd80bfcec607dd90a34def4301045a60472ef10b0fb90ab84692fc08f786e7f806c28afdab1ef66a WHIRLPOOL 761e7440d2bc32b594ab55ea967c5b075bb638b2fdba6606beaf9c31a90e20031e914146828004b3d11203668210a6994be9fabc3b0ebb428d516b57cae9ee68 |
46 |
DIST transformers-0.4.3.0.tar.gz 28632 SHA256 b3d0a797e815ca50d411e20c02f781efe7751308007d880af7f0b5c4365c3a9d SHA512 c3ec0893ebba4fbd6087c3202e919552c4a9bff3350b5c0589e7ebb18751a515d98b8cac15b0a3252906ea72b5a0eb09b7fe88c8da88b09d6ce4fbf0f50b2780 WHIRLPOOL 89591781926b1d025056dedcfc5de61705056c1e3a8eba72f2e89789e78d2ed4d8909f84d6560dfc66bc0b360f98cb3dc3835f3a05c2325f747498373c88aa4b |
47 |
|
48 |
diff --git a/dev-lang/ghc/files/ghc-8.2.1_rc1-cgen-constify.patch b/dev-lang/ghc/files/ghc-8.2.1_rc1-cgen-constify.patch |
49 |
new file mode 100644 |
50 |
index 00000000000..2e1ef932b45 |
51 |
--- /dev/null |
52 |
+++ b/dev-lang/ghc/files/ghc-8.2.1_rc1-cgen-constify.patch |
53 |
@@ -0,0 +1,378 @@ |
54 |
+From 7e00046772e053c63ac93630a60b0f396e32a2d7 Mon Sep 17 00:00:00 2001 |
55 |
+From: Sergei Trofimovich <slyfox@g.o> |
56 |
+Date: Sun, 16 Apr 2017 10:43:38 +0100 |
57 |
+Subject: [PATCH] compiler/cmm/PprC.hs: constify labels in .rodata |
58 |
+ |
59 |
+Summary: |
60 |
+Consider one-line module |
61 |
+ module B (v) where v = "hello" |
62 |
+in -fvia-C mode it generates code like |
63 |
+ static char gibberish_str[] = "hello"; |
64 |
+ |
65 |
+It resides in data section (precious resource on ia64!). |
66 |
+The patch switches genrator to emit: |
67 |
+ static const char gibberish_str[] = "hello"; |
68 |
+ |
69 |
+Other types if symbols that gained 'const' qualifier are: |
70 |
+ |
71 |
+- info tables (from haskell and CMM) |
72 |
+- static reference tables (from haskell and CMM) |
73 |
+ |
74 |
+Cleanups along the way: |
75 |
+ |
76 |
+- fixed info tables defined in .cmm to reside in .rodata |
77 |
+- split out closure declaration into 'IC_' / 'EC_' |
78 |
+- added label declaration (based on label type) right before |
79 |
+ each label definition (based on section type) so that C |
80 |
+ compiler could check if declaration and definition matches |
81 |
+ at definition site. |
82 |
+ |
83 |
+Signed-off-by: Sergei Trofimovich <slyfox@g.o> |
84 |
+ |
85 |
+Test Plan: ran testsuite on unregisterised x86_64 compiler |
86 |
+ |
87 |
+Reviewers: simonmar, ezyang, austin, bgamari, erikd |
88 |
+ |
89 |
+Subscribers: rwbarton, thomie |
90 |
+ |
91 |
+GHC Trac Issues: #8996 |
92 |
+ |
93 |
+Differential Revision: https://phabricator.haskell.org/D3481 |
94 |
+--- |
95 |
+ compiler/cmm/CLabel.hs | 24 ++++++++++++++ |
96 |
+ compiler/cmm/Cmm.hs | 13 ++++++++ |
97 |
+ compiler/cmm/CmmInfo.hs | 2 +- |
98 |
+ compiler/cmm/PprC.hs | 62 +++++++++++++++++++++++------------- |
99 |
+ compiler/llvmGen/LlvmCodeGen/Data.hs | 12 ------- |
100 |
+ includes/Stg.h | 22 +++++++++---- |
101 |
+ includes/rts/storage/InfoTables.h | 2 +- |
102 |
+ includes/stg/MiscClosures.h | 14 ++++---- |
103 |
+ 8 files changed, 102 insertions(+), 49 deletions(-) |
104 |
+ |
105 |
+diff --git a/compiler/cmm/CLabel.hs b/compiler/cmm/CLabel.hs |
106 |
+index 3ba4f7647a..62c8037e9c 100644 |
107 |
+--- a/compiler/cmm/CLabel.hs |
108 |
++++ b/compiler/cmm/CLabel.hs |
109 |
+@@ -89,6 +89,8 @@ module CLabel ( |
110 |
+ foreignLabelStdcallInfo, |
111 |
+ isBytesLabel, |
112 |
+ isForeignLabel, |
113 |
++ isSomeRODataLabel, |
114 |
++ isStaticClosureLabel, |
115 |
+ mkCCLabel, mkCCSLabel, |
116 |
+ |
117 |
+ DynamicLinkerLabelInfo(..), |
118 |
+@@ -575,6 +577,28 @@ isForeignLabel :: CLabel -> Bool |
119 |
+ isForeignLabel (ForeignLabel _ _ _ _) = True |
120 |
+ isForeignLabel _lbl = False |
121 |
+ |
122 |
++-- | Whether label is a static closure label (can come from haskell or cmm) |
123 |
++isStaticClosureLabel :: CLabel -> Bool |
124 |
++-- Closure defined in haskell (.hs) |
125 |
++isStaticClosureLabel (IdLabel _ _ Closure) = True |
126 |
++-- Closure defined in cmm |
127 |
++isStaticClosureLabel (CmmLabel _ _ CmmClosure) = True |
128 |
++isStaticClosureLabel _lbl = False |
129 |
++ |
130 |
++-- | Whether label is a .rodata label |
131 |
++isSomeRODataLabel :: CLabel -> Bool |
132 |
++-- info table defined in haskell (.hs) |
133 |
++isSomeRODataLabel (IdLabel _ _ ClosureTable) = True |
134 |
++isSomeRODataLabel (IdLabel _ _ ConInfoTable) = True |
135 |
++isSomeRODataLabel (IdLabel _ _ InfoTable) = True |
136 |
++isSomeRODataLabel (IdLabel _ _ LocalInfoTable) = True |
137 |
++-- static reference tables defined in haskell (.hs) |
138 |
++isSomeRODataLabel (IdLabel _ _ SRT) = True |
139 |
++isSomeRODataLabel (SRTLabel _) = True |
140 |
++-- info table defined in cmm (.cmm) |
141 |
++isSomeRODataLabel (CmmLabel _ _ CmmInfo) = True |
142 |
++isSomeRODataLabel _lbl = False |
143 |
++ |
144 |
+ -- | Get the label size field from a ForeignLabel |
145 |
+ foreignLabelStdcallInfo :: CLabel -> Maybe Int |
146 |
+ foreignLabelStdcallInfo (ForeignLabel _ info _ _) = info |
147 |
+diff --git a/compiler/cmm/Cmm.hs b/compiler/cmm/Cmm.hs |
148 |
+index d2ee531686..bab20f3fdd 100644 |
149 |
+--- a/compiler/cmm/Cmm.hs |
150 |
++++ b/compiler/cmm/Cmm.hs |
151 |
+@@ -9,6 +9,7 @@ module Cmm ( |
152 |
+ CmmBlock, |
153 |
+ RawCmmDecl, RawCmmGroup, |
154 |
+ Section(..), SectionType(..), CmmStatics(..), CmmStatic(..), |
155 |
++ isSecConstant, |
156 |
+ |
157 |
+ -- ** Blocks containing lists |
158 |
+ GenBasicBlock(..), blockId, |
159 |
+@@ -167,6 +168,18 @@ data SectionType |
160 |
+ | OtherSection String |
161 |
+ deriving (Show) |
162 |
+ |
163 |
++-- | Should a data in this section be considered constant |
164 |
++isSecConstant :: Section -> Bool |
165 |
++isSecConstant (Section t _) = case t of |
166 |
++ Text -> True |
167 |
++ ReadOnlyData -> True |
168 |
++ RelocatableReadOnlyData -> True |
169 |
++ ReadOnlyData16 -> True |
170 |
++ CString -> True |
171 |
++ Data -> False |
172 |
++ UninitialisedData -> False |
173 |
++ (OtherSection _) -> False |
174 |
++ |
175 |
+ data Section = Section SectionType CLabel |
176 |
+ |
177 |
+ data CmmStatic |
178 |
+diff --git a/compiler/cmm/CmmInfo.hs b/compiler/cmm/CmmInfo.hs |
179 |
+index b5e800a977..35e3a1888d 100644 |
180 |
+--- a/compiler/cmm/CmmInfo.hs |
181 |
++++ b/compiler/cmm/CmmInfo.hs |
182 |
+@@ -133,7 +133,7 @@ mkInfoTable dflags proc@(CmmProc infos entry_lbl live blocks) |
183 |
+ -- |
184 |
+ return (top_decls ++ |
185 |
+ [CmmProc mapEmpty entry_lbl live blocks, |
186 |
+- mkDataLits (Section Data info_lbl) info_lbl |
187 |
++ mkRODataLits info_lbl |
188 |
+ (CmmLabel entry_lbl : rel_std_info ++ rel_extra_bits)]) |
189 |
+ |
190 |
+ -- |
191 |
+diff --git a/compiler/cmm/PprC.hs b/compiler/cmm/PprC.hs |
192 |
+index 56de94079f..21ed6f6516 100644 |
193 |
+--- a/compiler/cmm/PprC.hs |
194 |
++++ b/compiler/cmm/PprC.hs |
195 |
+@@ -83,12 +83,13 @@ pprC tops = vcat $ intersperse blankLine $ map pprTop tops |
196 |
+ -- top level procs |
197 |
+ -- |
198 |
+ pprTop :: RawCmmDecl -> SDoc |
199 |
+-pprTop (CmmProc infos clbl _ graph) = |
200 |
++pprTop (CmmProc infos clbl _in_live_regs graph) = |
201 |
+ |
202 |
+ (case mapLookup (g_entry graph) infos of |
203 |
+ Nothing -> empty |
204 |
+- Just (Statics info_clbl info_dat) -> pprDataExterns info_dat $$ |
205 |
+- pprWordArray info_clbl info_dat) $$ |
206 |
++ Just (Statics info_clbl info_dat) -> |
207 |
++ pprDataExterns info_dat $$ |
208 |
++ pprWordArray info_is_in_rodata info_clbl info_dat) $$ |
209 |
+ (vcat [ |
210 |
+ blankLine, |
211 |
+ extern_decls, |
212 |
+@@ -99,6 +100,8 @@ pprTop (CmmProc infos clbl _ graph) = |
213 |
+ rbrace ] |
214 |
+ ) |
215 |
+ where |
216 |
++ -- info tables are always in .rodata |
217 |
++ info_is_in_rodata = True |
218 |
+ blocks = toBlockListEntryFirst graph |
219 |
+ (temp_decls, extern_decls) = pprTempAndExternDecls blocks |
220 |
+ |
221 |
+@@ -107,21 +110,23 @@ pprTop (CmmProc infos clbl _ graph) = |
222 |
+ |
223 |
+ -- We only handle (a) arrays of word-sized things and (b) strings. |
224 |
+ |
225 |
+-pprTop (CmmData _section (Statics lbl [CmmString str])) = |
226 |
++pprTop (CmmData section (Statics lbl [CmmString str])) = |
227 |
++ pprExternDecl lbl $$ |
228 |
+ hcat [ |
229 |
+- pprLocalness lbl, text "char ", ppr lbl, |
230 |
++ pprLocalness lbl, pprConstness (isSecConstant section), text "char ", ppr lbl, |
231 |
+ text "[] = ", pprStringInCStyle str, semi |
232 |
+ ] |
233 |
+ |
234 |
+-pprTop (CmmData _section (Statics lbl [CmmUninitialised size])) = |
235 |
++pprTop (CmmData section (Statics lbl [CmmUninitialised size])) = |
236 |
++ pprExternDecl lbl $$ |
237 |
+ hcat [ |
238 |
+- pprLocalness lbl, text "char ", ppr lbl, |
239 |
++ pprLocalness lbl, pprConstness (isSecConstant section), text "char ", ppr lbl, |
240 |
+ brackets (int size), semi |
241 |
+ ] |
242 |
+ |
243 |
+-pprTop (CmmData _section (Statics lbl lits)) = |
244 |
++pprTop (CmmData section (Statics lbl lits)) = |
245 |
+ pprDataExterns lits $$ |
246 |
+- pprWordArray lbl lits |
247 |
++ pprWordArray (isSecConstant section) lbl lits |
248 |
+ |
249 |
+ -- -------------------------------------------------------------------------- |
250 |
+ -- BasicBlocks are self-contained entities: they always end in a jump. |
251 |
+@@ -141,10 +146,12 @@ pprBBlock block = |
252 |
+ -- Info tables. Just arrays of words. |
253 |
+ -- See codeGen/ClosureInfo, and nativeGen/PprMach |
254 |
+ |
255 |
+-pprWordArray :: CLabel -> [CmmStatic] -> SDoc |
256 |
+-pprWordArray lbl ds |
257 |
++pprWordArray :: Bool -> CLabel -> [CmmStatic] -> SDoc |
258 |
++pprWordArray is_ro lbl ds |
259 |
+ = sdocWithDynFlags $ \dflags -> |
260 |
+- hcat [ pprLocalness lbl, text "StgWord" |
261 |
++ -- TODO: align closures only |
262 |
++ pprExternDecl lbl $$ |
263 |
++ hcat [ pprLocalness lbl, pprConstness is_ro, text "StgWord" |
264 |
+ , space, ppr lbl, text "[]" |
265 |
+ -- See Note [StgWord alignment] |
266 |
+ , pprAlignment (wordWidth dflags) |
267 |
+@@ -180,6 +187,10 @@ pprLocalness :: CLabel -> SDoc |
268 |
+ pprLocalness lbl | not $ externallyVisibleCLabel lbl = text "static " |
269 |
+ | otherwise = empty |
270 |
+ |
271 |
++pprConstness :: Bool -> SDoc |
272 |
++pprConstness is_ro | is_ro = text "const " |
273 |
++ | otherwise = empty |
274 |
++ |
275 |
+ -- -------------------------------------------------------------------------- |
276 |
+ -- Statements. |
277 |
+ -- |
278 |
+@@ -984,31 +995,38 @@ is_cishCC JavaScriptCallConv = False |
279 |
+ pprTempAndExternDecls :: [CmmBlock] -> (SDoc{-temps-}, SDoc{-externs-}) |
280 |
+ pprTempAndExternDecls stmts |
281 |
+ = (pprUFM (getUniqSet temps) (vcat . map pprTempDecl), |
282 |
+- vcat (map (pprExternDecl False{-ToDo-}) (Map.keys lbls))) |
283 |
++ vcat (map pprExternDecl (Map.keys lbls))) |
284 |
+ where (temps, lbls) = runTE (mapM_ te_BB stmts) |
285 |
+ |
286 |
+ pprDataExterns :: [CmmStatic] -> SDoc |
287 |
+ pprDataExterns statics |
288 |
+- = vcat (map (pprExternDecl False{-ToDo-}) (Map.keys lbls)) |
289 |
++ = vcat (map pprExternDecl (Map.keys lbls)) |
290 |
+ where (_, lbls) = runTE (mapM_ te_Static statics) |
291 |
+ |
292 |
+ pprTempDecl :: LocalReg -> SDoc |
293 |
+ pprTempDecl l@(LocalReg _ rep) |
294 |
+ = hcat [ machRepCType rep, space, pprLocalReg l, semi ] |
295 |
+ |
296 |
+-pprExternDecl :: Bool -> CLabel -> SDoc |
297 |
+-pprExternDecl _in_srt lbl |
298 |
++pprExternDecl :: CLabel -> SDoc |
299 |
++pprExternDecl lbl |
300 |
+ -- do not print anything for "known external" things |
301 |
+ | not (needsCDecl lbl) = empty |
302 |
+ | Just sz <- foreignLabelStdcallInfo lbl = stdcall_decl sz |
303 |
+ | otherwise = |
304 |
+- hcat [ visibility, label_type lbl, |
305 |
+- lparen, ppr lbl, text ");" ] |
306 |
++ hcat [ visibility, label_type lbl , lparen, ppr lbl, text ");" |
307 |
++ -- occasionally useful to see label type |
308 |
++ -- , text "/* ", pprDebugCLabel lbl, text " */" |
309 |
++ ] |
310 |
+ where |
311 |
+- label_type lbl | isBytesLabel lbl = text "B_" |
312 |
+- | isForeignLabel lbl && isCFunctionLabel lbl = text "FF_" |
313 |
+- | isCFunctionLabel lbl = text "F_" |
314 |
+- | otherwise = text "I_" |
315 |
++ label_type lbl | isBytesLabel lbl = text "B_" |
316 |
++ | isForeignLabel lbl && isCFunctionLabel lbl |
317 |
++ = text "FF_" |
318 |
++ | isCFunctionLabel lbl = text "F_" |
319 |
++ | isStaticClosureLabel lbl = text "C_" |
320 |
++ -- generic .rodata labels |
321 |
++ | isSomeRODataLabel lbl = text "RO_" |
322 |
++ -- generic .data labels (common case) |
323 |
++ | otherwise = text "RW_" |
324 |
+ |
325 |
+ visibility |
326 |
+ | externallyVisibleCLabel lbl = char 'E' |
327 |
+diff --git a/compiler/llvmGen/LlvmCodeGen/Data.hs b/compiler/llvmGen/LlvmCodeGen/Data.hs |
328 |
+index 9bb5a75bda..adb86d312d 100644 |
329 |
+--- a/compiler/llvmGen/LlvmCodeGen/Data.hs |
330 |
++++ b/compiler/llvmGen/LlvmCodeGen/Data.hs |
331 |
+@@ -56,18 +56,6 @@ genLlvmData (sec, Statics lbl xs) = do |
332 |
+ |
333 |
+ return ([globDef], [tyAlias]) |
334 |
+ |
335 |
+--- | Should a data in this section be considered constant |
336 |
+-isSecConstant :: Section -> Bool |
337 |
+-isSecConstant (Section t _) = case t of |
338 |
+- Text -> True |
339 |
+- ReadOnlyData -> True |
340 |
+- RelocatableReadOnlyData -> True |
341 |
+- ReadOnlyData16 -> True |
342 |
+- CString -> True |
343 |
+- Data -> False |
344 |
+- UninitialisedData -> False |
345 |
+- (OtherSection _) -> False |
346 |
+- |
347 |
+ -- | Format the section type part of a Cmm Section |
348 |
+ llvmSectionType :: Platform -> SectionType -> FastString |
349 |
+ llvmSectionType p t = case t of |
350 |
+diff --git a/includes/Stg.h b/includes/Stg.h |
351 |
+index 619984d8e5..b1b3190307 100644 |
352 |
+--- a/includes/Stg.h |
353 |
++++ b/includes/Stg.h |
354 |
+@@ -223,13 +223,23 @@ typedef StgInt I_; |
355 |
+ typedef StgWord StgWordArray[]; |
356 |
+ typedef StgFunPtr F_; |
357 |
+ |
358 |
+-#define EB_(X) extern char X[] |
359 |
+-#define IB_(X) static char X[] |
360 |
+-#define EI_(X) extern StgWordArray (X) GNU_ATTRIBUTE(aligned (8)) |
361 |
+-#define II_(X) static StgWordArray (X) GNU_ATTRIBUTE(aligned (8)) |
362 |
++/* byte arrays (and strings): */ |
363 |
++#define EB_(X) extern const char X[] |
364 |
++#define IB_(X) static const char X[] |
365 |
++/* static (non-heap) closures (requires alignment for pointer tagging): */ |
366 |
++#define EC_(X) extern StgWordArray (X) GNU_ATTRIBUTE(aligned (8)) |
367 |
++#define IC_(X) static StgWordArray (X) GNU_ATTRIBUTE(aligned (8)) |
368 |
++/* writable data (does not require alignment): */ |
369 |
++#define ERW_(X) extern StgWordArray (X) |
370 |
++#define IRW_(X) static StgWordArray (X) |
371 |
++/* read-only data (does not require alignment): */ |
372 |
++#define ERO_(X) extern const StgWordArray (X) |
373 |
++#define IRO_(X) static const StgWordArray (X) |
374 |
++/* stg-native functions: */ |
375 |
+ #define IF_(f) static StgFunPtr GNUC3_ATTRIBUTE(used) f(void) |
376 |
+-#define FN_(f) StgFunPtr f(void) |
377 |
+-#define EF_(f) StgFunPtr f(void) /* External Cmm functions */ |
378 |
++#define FN_(f) StgFunPtr f(void) |
379 |
++#define EF_(f) StgFunPtr f(void) /* External Cmm functions */ |
380 |
++/* foreign functions: */ |
381 |
+ #define EFF_(f) void f() /* See Note [External function prototypes] */ |
382 |
+ |
383 |
+ /* Note [External function prototypes] See Trac #8965, #11395 |
384 |
+diff --git a/includes/rts/storage/InfoTables.h b/includes/rts/storage/InfoTables.h |
385 |
+index 307aac371c..163f1d1c87 100644 |
386 |
+--- a/includes/rts/storage/InfoTables.h |
387 |
++++ b/includes/rts/storage/InfoTables.h |
388 |
+@@ -266,7 +266,7 @@ typedef struct { |
389 |
+ } StgFunInfoTable; |
390 |
+ |
391 |
+ // canned bitmap for each arg type, indexed by constants in FunTypes.h |
392 |
+-extern StgWord stg_arg_bitmaps[]; |
393 |
++extern const StgWord stg_arg_bitmaps[]; |
394 |
+ |
395 |
+ /* ----------------------------------------------------------------------------- |
396 |
+ Return info tables |
397 |
+diff --git a/includes/stg/MiscClosures.h b/includes/stg/MiscClosures.h |
398 |
+index 9d907ab3ba..b604f1c42b 100644 |
399 |
+--- a/includes/stg/MiscClosures.h |
400 |
++++ b/includes/stg/MiscClosures.h |
401 |
+@@ -21,10 +21,10 @@ |
402 |
+ #define STGMISCCLOSURES_H |
403 |
+ |
404 |
+ #if IN_STG_CODE |
405 |
+-# define RTS_RET_INFO(i) extern W_(i)[] |
406 |
+-# define RTS_FUN_INFO(i) extern W_(i)[] |
407 |
+-# define RTS_THUNK_INFO(i) extern W_(i)[] |
408 |
+-# define RTS_INFO(i) extern W_(i)[] |
409 |
++# define RTS_RET_INFO(i) extern const W_(i)[] |
410 |
++# define RTS_FUN_INFO(i) extern const W_(i)[] |
411 |
++# define RTS_THUNK_INFO(i) extern const W_(i)[] |
412 |
++# define RTS_INFO(i) extern const W_(i)[] |
413 |
+ # define RTS_CLOSURE(i) extern W_(i)[] |
414 |
+ # define RTS_FUN_DECL(f) extern DLL_IMPORT_RTS StgFunPtr f(void) |
415 |
+ #else |
416 |
+@@ -489,9 +489,9 @@ extern StgWord RTS_VAR(sched_mutex); |
417 |
+ |
418 |
+ // Apply.cmm |
419 |
+ // canned bitmap for each arg type |
420 |
+-extern StgWord stg_arg_bitmaps[]; |
421 |
+-extern StgWord stg_ap_stack_entries[]; |
422 |
+-extern StgWord stg_stack_save_entries[]; |
423 |
++extern const StgWord stg_arg_bitmaps[]; |
424 |
++extern const StgWord stg_ap_stack_entries[]; |
425 |
++extern const StgWord stg_stack_save_entries[]; |
426 |
+ |
427 |
+ // Storage.c |
428 |
+ extern unsigned int RTS_VAR(g0); |
429 |
+-- |
430 |
+2.12.2 |
431 |
+ |
432 |
|
433 |
diff --git a/dev-lang/ghc/files/ghc-8.2.1_rc1-ghci-cross.patch b/dev-lang/ghc/files/ghc-8.2.1_rc1-ghci-cross.patch |
434 |
new file mode 100644 |
435 |
index 00000000000..dbba18e85c7 |
436 |
--- /dev/null |
437 |
+++ b/dev-lang/ghc/files/ghc-8.2.1_rc1-ghci-cross.patch |
438 |
@@ -0,0 +1,60 @@ |
439 |
+commit 732b3dbbff194eb8650c75afd79d892801afa0dc |
440 |
+Author: Sergei Trofimovich <slyfox@g.o> |
441 |
+Date: Thu Apr 6 22:48:13 2017 +0100 |
442 |
+ |
443 |
+ add $(CrossCompilePrefix) to 'runghc' and 'ghci' |
444 |
+ |
445 |
+ When Stage1Only=YES install mode is used one of rare tools |
446 |
+ that lack $(CrossCompilePrefix) prefix are 'runghc' and 'ghci'. |
447 |
+ |
448 |
+ This causes file collisions when multiple GHC crosscompilers |
449 |
+ are installed in system. |
450 |
+ |
451 |
+ Signed-off-by: Sergei Trofimovich <slyfox@g.o> |
452 |
+ |
453 |
+diff --git a/driver/ghci/ghc.mk b/driver/ghci/ghc.mk |
454 |
+index 41d1f15c17..0f31884080 100644 |
455 |
+--- a/driver/ghci/ghc.mk |
456 |
++++ b/driver/ghci/ghc.mk |
457 |
+@@ -16,16 +16,16 @@ ifneq "$(Windows_Host)" "YES" |
458 |
+ install: install_driver_ghci |
459 |
+ |
460 |
+ .PHONY: install_driver_ghci |
461 |
+-install_driver_ghci: WRAPPER=$(DESTDIR)$(bindir)/ghci-$(ProjectVersion) |
462 |
++install_driver_ghci: WRAPPER=$(DESTDIR)$(bindir)/$(CrossCompilePrefix)ghci-$(ProjectVersion) |
463 |
+ install_driver_ghci: |
464 |
+ $(INSTALL_DIR) "$(DESTDIR)$(bindir)" |
465 |
+ $(call removeFiles, "$(WRAPPER)") |
466 |
+ $(CREATE_SCRIPT) "$(WRAPPER)" |
467 |
+ echo '#!$(SHELL)' >> "$(WRAPPER)" |
468 |
+- echo 'exec "$(bindir)/ghc-$(ProjectVersion)" --interactive "$$@"' >> "$(WRAPPER)" |
469 |
++ echo 'exec "$(bindir)/$(CrossCompilePrefix)ghc-$(ProjectVersion)" --interactive "$$@"' >> "$(WRAPPER)" |
470 |
+ $(EXECUTABLE_FILE) "$(WRAPPER)" |
471 |
+- $(call removeFiles,"$(DESTDIR)$(bindir)/ghci") |
472 |
+- $(LN_S) ghci-$(ProjectVersion) "$(DESTDIR)$(bindir)/ghci" |
473 |
++ $(call removeFiles,"$(DESTDIR)$(bindir)/$(CrossCompilePrefix)ghci") |
474 |
++ $(LN_S) $(CrossCompilePrefix)ghci-$(ProjectVersion) "$(DESTDIR)$(bindir)/$(CrossCompilePrefix)ghci" |
475 |
+ |
476 |
+ else # Windows_Host... |
477 |
+ |
478 |
+diff --git a/utils/runghc/ghc.mk b/utils/runghc/ghc.mk |
479 |
+index 9169ca21bd..50b11a612e 100644 |
480 |
+--- a/utils/runghc/ghc.mk |
481 |
++++ b/utils/runghc/ghc.mk |
482 |
+@@ -34,11 +34,11 @@ install: install_runhaskell |
483 |
+ .PHONY: install_runhaskell |
484 |
+ ifeq "$(Windows_Host)" "YES" |
485 |
+ install_runhaskell: install_bins |
486 |
+- "$(CP)" $(DESTDIR)$(bindir)/runghc$(exeext1) $(DESTDIR)$(bindir)/runhaskell$(exeext1) |
487 |
++ "$(CP)" $(DESTDIR)$(bindir)/$(CrossCompilePrefix)runghc$(exeext1) $(DESTDIR)$(bindir)/$(CrossCompilePrefix)runhaskell$(exeext1) |
488 |
+ else |
489 |
+ install_runhaskell: |
490 |
+- $(call removeFiles,"$(DESTDIR)$(bindir)/runhaskell") |
491 |
+- $(LN_S) runghc "$(DESTDIR)$(bindir)/runhaskell" |
492 |
+- $(call removeFiles,"$(DESTDIR)$(bindir)/runghc") |
493 |
+- $(LN_S) runghc-$(ProjectVersion) "$(DESTDIR)$(bindir)/runghc" |
494 |
++ $(call removeFiles,"$(DESTDIR)$(bindir)/$(CrossCompilePrefix)runhaskell") |
495 |
++ $(LN_S) $(CrossCompilePrefix)runghc "$(DESTDIR)$(bindir)/$(CrossCompilePrefix)runhaskell" |
496 |
++ $(call removeFiles,"$(DESTDIR)$(bindir)/$(CrossCompilePrefix)runghc") |
497 |
++ $(LN_S) $(CrossCompilePrefix)runghc-$(ProjectVersion) "$(DESTDIR)$(bindir)/$(CrossCompilePrefix)runghc" |
498 |
+ endif |
499 |
|
500 |
diff --git a/dev-lang/ghc/files/ghc-8.2.1_rc1-hp2ps-cross.patch b/dev-lang/ghc/files/ghc-8.2.1_rc1-hp2ps-cross.patch |
501 |
new file mode 100644 |
502 |
index 00000000000..26382b3cf44 |
503 |
--- /dev/null |
504 |
+++ b/dev-lang/ghc/files/ghc-8.2.1_rc1-hp2ps-cross.patch |
505 |
@@ -0,0 +1,104 @@ |
506 |
+commit ff84d052850b637b03bbb98cf05202e44886257d |
507 |
+Author: Sergei Trofimovich <slyfox@g.o> |
508 |
+Date: Sat Apr 8 10:02:34 2017 +0100 |
509 |
+ |
510 |
+ cross-build 'unlit' and 'hp2ps' for stage2 install |
511 |
+ |
512 |
+ In navive build case it does not matter much if we build |
513 |
+ 'unlit' and 'hp2ps' tools with ghc-stage0 or ghc-stage1: |
514 |
+ both GHCs are native compilers and both tools are written |
515 |
+ in C (have no haskell code). |
516 |
+ |
517 |
+ But in cross-case the difference is substantial: |
518 |
+ In Stag1Only=YES case we need to install native tools built |
519 |
+ by ghc-stage0/${host}-cc. |
520 |
+ In Stag1Only=NO case we need to install cross-built tools |
521 |
+ built by ghc-stage1/${target}-cc. |
522 |
+ |
523 |
+ Before this change GHC did not have a rule to build cross-built |
524 |
+ 'unlit' and 'hp2ps'. |
525 |
+ |
526 |
+ The change adds cross-built 'unlit' and 'hp2ps' as 'dist-install' |
527 |
+ targets. |
528 |
+ |
529 |
+ 'inplace/lib/bin/unlit.bin' target is unchanged and still contains |
530 |
+ native binary. |
531 |
+ |
532 |
+ As a result this change allows cross-building and packaging whole |
533 |
+ GHC for target platform! |
534 |
+ |
535 |
+ Signed-off-by: Sergei Trofimovich <slyfox@g.o> |
536 |
+ |
537 |
+diff --git a/utils/hp2ps/ghc.mk b/utils/hp2ps/ghc.mk |
538 |
+index f6e01ec6c1..21ce87dcfa 100644 |
539 |
+--- a/utils/hp2ps/ghc.mk |
540 |
++++ b/utils/hp2ps/ghc.mk |
541 |
+@@ -10,6 +10,7 @@ |
542 |
+ # |
543 |
+ # ----------------------------------------------------------------------------- |
544 |
+ |
545 |
++# stage0 |
546 |
+ utils/hp2ps_dist_C_SRCS = AreaBelow.c Curves.c Error.c Main.c \ |
547 |
+ Reorder.c TopTwenty.c AuxFile.c Deviation.c \ |
548 |
+ HpFile.c Marks.c Scale.c TraceElement.c \ |
549 |
+@@ -17,11 +18,27 @@ utils/hp2ps_dist_C_SRCS = AreaBelow.c Curves.c Error.c Main.c \ |
550 |
+ Utilities.c |
551 |
+ utils/hp2ps_dist_EXTRA_LIBRARIES = m |
552 |
+ utils/hp2ps_dist_PROGNAME = hp2ps |
553 |
+-utils/hp2ps_dist_INSTALL = YES |
554 |
+ utils/hp2ps_dist_INSTALL_INPLACE = YES |
555 |
+ utils/hp2ps_dist_SHELL_WRAPPER = YES |
556 |
+ utils/hp2ps_dist_INSTALL_SHELL_WRAPPER_NAME = hp2ps |
557 |
+ |
558 |
+ utils/hp2ps_CC_OPTS += $(addprefix -I,$(GHC_INCLUDE_DIRS)) |
559 |
+ |
560 |
++# stage 1 |
561 |
++utils/hp2ps_dist-install_C_SRCS = $(utils/hp2ps_dist_C_SRCS) |
562 |
++utils/hp2ps_dist-install_EXTRA_LIBRARIES = $(utils/hp2ps_dist_EXTRA_LIBRARIES) |
563 |
++utils/hp2ps_dist-install_PROGNAME = $(utils/hp2ps_dist_PROGNAME) |
564 |
++utils/hp2ps_dist-install_INSTALL_INPLACE = NO |
565 |
++utils/hp2ps_dist-install_SHELL_WRAPPER = YES |
566 |
++utils/hp2ps_dist-install_INSTALL_SHELL_WRAPPER_NAME = $(utils/hp2ps_dist_INSTALL_SHELL_WRAPPER_NAME) |
567 |
++ |
568 |
++ifeq "$(Stage1Only)" "YES" |
569 |
++utils/hp2ps_dist_INSTALL = YES |
570 |
++utils/hp2ps_dist-install_INSTALL = NO |
571 |
++else |
572 |
++utils/hp2ps_dist_INSTALL = NO |
573 |
++utils/hp2ps_dist-install_INSTALL = YES |
574 |
++endif |
575 |
++ |
576 |
+ $(eval $(call build-prog,utils/hp2ps,dist,0)) |
577 |
++$(eval $(call build-prog,utils/hp2ps,dist-install,1)) |
578 |
+diff --git a/utils/unlit/ghc.mk b/utils/unlit/ghc.mk |
579 |
+index e947989b5e..8911f4e856 100644 |
580 |
+--- a/utils/unlit/ghc.mk |
581 |
++++ b/utils/unlit/ghc.mk |
582 |
+@@ -10,11 +10,25 @@ |
583 |
+ # |
584 |
+ # ----------------------------------------------------------------------------- |
585 |
+ |
586 |
++# built by ghc-stage0 |
587 |
+ utils/unlit_dist_C_SRCS = unlit.c |
588 |
+ utils/unlit_dist_PROGNAME = unlit |
589 |
+ utils/unlit_dist_TOPDIR = YES |
590 |
+-utils/unlit_dist_INSTALL = YES |
591 |
+ utils/unlit_dist_INSTALL_INPLACE = YES |
592 |
+ |
593 |
+-$(eval $(call build-prog,utils/unlit,dist,0)) |
594 |
++# built by ghc-stage1 |
595 |
++utils/unlit_dist-install_C_SRCS = $(utils/unlit_dist_C_SRCS) |
596 |
++utils/unlit_dist-install_PROGNAME = $(utils/unlit_dist_PROGNAME) |
597 |
++utils/unlit_dist-install_TOPDIR = $(utils/unlit_dist_TOPDIR) |
598 |
++utils/unlit_dist-install_INSTALL_INPLACE = NO |
599 |
++ |
600 |
++ifeq "$(Stage1Only)" "YES" |
601 |
++utils/unlit_dist_INSTALL = YES |
602 |
++utils/unlit_dist-install_INSTALL = NO |
603 |
++else |
604 |
++utils/unlit_dist_INSTALL = NO |
605 |
++utils/unlit_dist-install_INSTALL = YES |
606 |
++endif |
607 |
+ |
608 |
++$(eval $(call build-prog,utils/unlit,dist,0)) |
609 |
++$(eval $(call build-prog,utils/unlit,dist-install,1)) |
610 |
|
611 |
diff --git a/dev-lang/ghc/files/ghc-8.2.1_rc1-stage2-cross.patch b/dev-lang/ghc/files/ghc-8.2.1_rc1-stage2-cross.patch |
612 |
new file mode 100644 |
613 |
index 00000000000..1439d722fef |
614 |
--- /dev/null |
615 |
+++ b/dev-lang/ghc/files/ghc-8.2.1_rc1-stage2-cross.patch |
616 |
@@ -0,0 +1,81 @@ |
617 |
+commit 54895c90440cb81f18657537b91f2aa35bd54173 |
618 |
+Author: Sergei Trofimovich <slyfox@g.o> |
619 |
+Date: Fri Apr 7 10:08:58 2017 +0100 |
620 |
+ |
621 |
+ fix 'make install' for cross-stage2 |
622 |
+ |
623 |
+ When cross-built GHC is being installed one of |
624 |
+ latest steps is to register installed libraries |
625 |
+ with 'ghc-pkg'. |
626 |
+ |
627 |
+ GHC uses freshly installed 'ghc-pkg' and 'ghc-stage2' |
628 |
+ for that. |
629 |
+ |
630 |
+ Tested as: |
631 |
+ ./configure --target=aarch64-unknown-linux-gnu |
632 |
+ make install DESTDIR=$(pwd)/__s2 STRIP_CMD=: |
633 |
+ |
634 |
+ Before the change install failed on ghc-pkg execution phase: |
635 |
+ |
636 |
+ ".../ghc-cross/__s2/usr/local/lib/ghc-8.3.20170406/bin/ghc-pkg" \ |
637 |
+ --force \ |
638 |
+ --global-package-db \ |
639 |
+ ".../ghc-cross/__s2/usr/local/lib/ghc-8.3.20170406/package.conf.d" \ |
640 |
+ update rts/dist/package.conf.install |
641 |
+ /bin/sh: .../ghc-cross/__s2/usr/local/lib/ghc-8.3.20170406/bin/ghc-pkg: \ |
642 |
+ No such file or directory |
643 |
+ |
644 |
+ To avoid breakage we use 'ghc' and 'ghc-pkg' built by stage0. |
645 |
+ |
646 |
+ Signed-off-by: Sergei Trofimovich <slyfox@g.o> |
647 |
+ |
648 |
+ Test Plan: run 'make install' on stage2 crosscompiler |
649 |
+ |
650 |
+ Reviewers: rwbarton, austin, bgamari |
651 |
+ |
652 |
+ Subscribers: thomie, snowleopard |
653 |
+ |
654 |
+ Differential Revision: https://phabricator.haskell.org/D3432 |
655 |
+ |
656 |
+diff --git a/ghc.mk b/ghc.mk |
657 |
+index caa6c38fbb..8971f25981 100644 |
658 |
+--- a/ghc.mk |
659 |
++++ b/ghc.mk |
660 |
+@@ -962,6 +962,12 @@ endif |
661 |
+ |
662 |
+ INSTALLED_PACKAGE_CONF=$(DESTDIR)$(topdir)/package.conf.d |
663 |
+ |
664 |
++ifeq "$(CrossCompiling)" "YES" |
665 |
++# when installing ghc-stage2 we can't run target's |
666 |
++# 'ghc-pkg' and 'ghc-stage2' but those are needed for registration. |
667 |
++INSTALLED_GHC_REAL=$(TOP)/inplace/bin/ghc-stage1 |
668 |
++INSTALLED_GHC_PKG_REAL=$(TOP)/$(ghc-pkg_DIST_BINARY) |
669 |
++else # CrossCompiling |
670 |
+ # Install packages in the right order, so that ghc-pkg doesn't complain. |
671 |
+ # Also, install ghc-pkg first. |
672 |
+ ifeq "$(Windows_Host)" "NO" |
673 |
+@@ -971,6 +977,7 @@ else |
674 |
+ INSTALLED_GHC_REAL=$(DESTDIR)$(bindir)/ghc.exe |
675 |
+ INSTALLED_GHC_PKG_REAL=$(DESTDIR)$(bindir)/ghc-pkg.exe |
676 |
+ endif |
677 |
++endif # CrossCompiling |
678 |
+ |
679 |
+ # Set the INSTALL_DISTDIR_p for each package; compiler is special |
680 |
+ $(foreach p,$(filter-out compiler,$(INSTALL_PACKAGES)),\ |
681 |
+diff --git a/utils/ghc-pkg/ghc.mk b/utils/ghc-pkg/ghc.mk |
682 |
+index 002c8122f2..4d5ef4e108 100644 |
683 |
+--- a/utils/ghc-pkg/ghc.mk |
684 |
++++ b/utils/ghc-pkg/ghc.mk |
685 |
+@@ -49,6 +49,12 @@ utils/ghc-pkg_dist_PROGNAME = ghc-pkg |
686 |
+ utils/ghc-pkg_dist_SHELL_WRAPPER = YES |
687 |
+ utils/ghc-pkg_dist_INSTALL_INPLACE = YES |
688 |
+ |
689 |
++# When cross-built ghc-stage2 is installed 'make install' needs to call |
690 |
++# native ghc-pkg (not the cross-built one) to register installed packages |
691 |
++# 'ghc-pkg_DIST_BINARY' variable only refer to native binary. |
692 |
++ghc-pkg_DIST_BINARY_NAME = ghc-pkg$(exeext0) |
693 |
++ghc-pkg_DIST_BINARY = utils/ghc-pkg/dist/build/tmp/$(ghc-pkg_DIST_BINARY_NAME) |
694 |
++ |
695 |
+ # See Note [Stage1Only vs stage=1] in mk/config.mk.in. |
696 |
+ ifeq "$(Stage1Only)" "YES" |
697 |
+ # Install the copy of ghc-pkg from the dist directory when running 'make |
698 |
|
699 |
diff --git a/dev-lang/ghc/files/ghc-8.2.1_rc1-staged-cross.patch b/dev-lang/ghc/files/ghc-8.2.1_rc1-staged-cross.patch |
700 |
new file mode 100644 |
701 |
index 00000000000..7e4ea7a9f61 |
702 |
--- /dev/null |
703 |
+++ b/dev-lang/ghc/files/ghc-8.2.1_rc1-staged-cross.patch |
704 |
@@ -0,0 +1,43 @@ |
705 |
+commit f2685df3b10e13f142736f28835e9064334bc143 |
706 |
+Author: Sergei Trofimovich <slyfox@g.o> |
707 |
+Date: Wed Apr 5 22:31:37 2017 +0100 |
708 |
+ |
709 |
+ avoid $(CrossCompilerPrefix) for stage2 install |
710 |
+ |
711 |
+ Suppose we are crossbuilding ghc (when ghc-stage2 |
712 |
+ is a normal compiler for $target): |
713 |
+ |
714 |
+ For this case 'make install' should install unprefixed |
715 |
+ stage2 'ghc' and not '$(CorssCompilePrefix)-ghc'. |
716 |
+ |
717 |
+ That way cross-built ghc is installable and |
718 |
+ usable on target as if it would be built natively |
719 |
+ on a target. |
720 |
+ |
721 |
+ Signed-off-by: Sergei Trofimovich <slyfox@g.o> |
722 |
+ |
723 |
+diff --git a/mk/config.mk.in b/mk/config.mk.in |
724 |
+index 4d5d82aa80..5e274bb71f 100644 |
725 |
+--- a/mk/config.mk.in |
726 |
++++ b/mk/config.mk.in |
727 |
+@@ -530,7 +530,7 @@ SUPPORTS_THIS_UNIT_ID = @SUPPORTS_THIS_UNIT_ID@ |
728 |
+ # needs to know which gcc you're using in order to perform its tests. |
729 |
+ |
730 |
+ GccVersion = @GccVersion@ |
731 |
+-CrossCompilePrefix = @CrossCompilePrefix@ |
732 |
++ |
733 |
+ # TargetPlatformFull retains the string passed to configure so we have it in |
734 |
+ # the necessary format to pass to libffi's configure. |
735 |
+ TargetPlatformFull = @TargetPlatformFull@ |
736 |
+@@ -567,6 +567,11 @@ CrossCompiling = @CrossCompiling@ |
737 |
+ # See Note [Stage1Only vs stage=1] |
738 |
+ Stage1Only = NO |
739 |
+ |
740 |
++# Installed tools prefix: |
741 |
++# we add prefix to crosscompiler GHC only (ghc-stage1), |
742 |
++# not cross-built GHC (not ghc-stage2). |
743 |
++CrossCompilePrefix = $(if $(filter YES,$(Stage1Only)),@CrossCompilePrefix@,) |
744 |
++ |
745 |
+ # Install stage 2 by default, or stage 1 in the cross compiler |
746 |
+ # case. Can be changed to 3 |
747 |
+ INSTALL_GHC_STAGE= $(if $(filter YES,$(Stage1Only)),1,2) |
748 |
|
749 |
diff --git a/dev-lang/ghc/files/ghc-8.2.1_rc1-unphased-cross.patch b/dev-lang/ghc/files/ghc-8.2.1_rc1-unphased-cross.patch |
750 |
new file mode 100644 |
751 |
index 00000000000..a5528956de1 |
752 |
--- /dev/null |
753 |
+++ b/dev-lang/ghc/files/ghc-8.2.1_rc1-unphased-cross.patch |
754 |
@@ -0,0 +1,30 @@ |
755 |
+commit 6ff98b962db15d18eb1d082fe344cef692ecef8e |
756 |
+Author: Sergei Trofimovich <slyfox@g.o> |
757 |
+Date: Thu Apr 6 08:55:56 2017 +0100 |
758 |
+ |
759 |
+ config.mk.in: remove phase=0 hack for CrossCompilePrefix |
760 |
+ |
761 |
+ $(CrossCompilePrefix) is used only in 'make install' |
762 |
+ target filenames in $(DESTDIR). None of inplace (or boot) |
763 |
+ files contain $(CrossCompilePrefix). |
764 |
+ |
765 |
+ Thus we don't need to worry about phases. |
766 |
+ |
767 |
+ Signed-off-by: Sergei Trofimovich <slyfox@g.o> |
768 |
+ |
769 |
+diff --git a/mk/config.mk.in b/mk/config.mk.in |
770 |
+index 4e61eea821..4d5d82aa80 100644 |
771 |
+--- a/mk/config.mk.in |
772 |
++++ b/mk/config.mk.in |
773 |
+@@ -530,11 +530,7 @@ SUPPORTS_THIS_UNIT_ID = @SUPPORTS_THIS_UNIT_ID@ |
774 |
+ # needs to know which gcc you're using in order to perform its tests. |
775 |
+ |
776 |
+ GccVersion = @GccVersion@ |
777 |
+-ifeq "$(phase)" "0" |
778 |
+-CrossCompilePrefix = |
779 |
+-else |
780 |
+ CrossCompilePrefix = @CrossCompilePrefix@ |
781 |
+-endif |
782 |
+ # TargetPlatformFull retains the string passed to configure so we have it in |
783 |
+ # the necessary format to pass to libffi's configure. |
784 |
+ TargetPlatformFull = @TargetPlatformFull@ |
785 |
|
786 |
diff --git a/dev-lang/ghc/files/ghc-8.2.1_rc1-win32-cross-1.patch b/dev-lang/ghc/files/ghc-8.2.1_rc1-win32-cross-1.patch |
787 |
new file mode 100644 |
788 |
index 00000000000..79751e1ecbd |
789 |
--- /dev/null |
790 |
+++ b/dev-lang/ghc/files/ghc-8.2.1_rc1-win32-cross-1.patch |
791 |
@@ -0,0 +1,124 @@ |
792 |
+commit a691f6a7a191a268380805481d8e63134764a4a1 |
793 |
+Author: Sergei Trofimovich <slyfox@×××××.ru> |
794 |
+Date: Sat Apr 29 22:02:24 2017 +0100 |
795 |
+ |
796 |
+ add basic cross-compilation support (#87) |
797 |
+ |
798 |
+ * fix include case: s/#include <Lmcons.h>/#include <lmcons.h> |
799 |
+ |
800 |
+ Noticed when cross-compiling win32 on linux to i686-w64-mingw32-gcc. |
801 |
+ i686-w64-mingw32 provides all headers in lowercase. |
802 |
+ |
803 |
+ Signed-off-by: Sergei Trofimovich <slyfox@g.o> |
804 |
+ |
805 |
+ * Pen.hsc: don't use c99-style comments in enum declarations |
806 |
+ |
807 |
+ Ths change workarounds hsc2hs bug in cross-compile mode: |
808 |
+ https://ghc.haskell.org/trac/ghc/ticket/13619 |
809 |
+ |
810 |
+ To reproduce the build failure it's enough to run |
811 |
+ $ cabal configure --hsc2hs-options='--cross-safe --cross-compile' |
812 |
+ $ cabal build --hsc2hs-options='--cross-safe --cross-compile' |
813 |
+ |
814 |
+ Signed-off-by: Sergei Trofimovich <slyfox@g.o> |
815 |
+ |
816 |
+ * SimpleMAPI.hsc: don't use #ifdef in enum declarations |
817 |
+ |
818 |
+ This change workarounds hsc2hs bug in cross-compile mode: |
819 |
+ https://ghc.haskell.org/trac/ghc/ticket/13620 |
820 |
+ |
821 |
+ To reproduce the build failure it's enough to run |
822 |
+ $ cabal configure --hsc2hs-options='--cross-safe --cross-compile' |
823 |
+ $ cabal build --hsc2hs-options='--cross-safe --cross-compile' |
824 |
+ |
825 |
+ Signed-off-by: Sergei Trofimovich <slyfox@g.o> |
826 |
+ |
827 |
+diff --git a/Graphics/Win32/GDI/Pen.hsc b/Graphics/Win32/GDI/Pen.hsc |
828 |
+index c880170..8d8df5d 100644 |
829 |
+--- a/Graphics/Win32/GDI/Pen.hsc |
830 |
++++ b/Graphics/Win32/GDI/Pen.hsc |
831 |
+@@ -56,7 +56,7 @@ foreign import WINDOWS_CCONV unsafe "windows.h DeleteObject" |
832 |
+ |
833 |
+ type PenStyle = INT |
834 |
+ |
835 |
+-#{enum PenStyle, // Pick one of these |
836 |
++#{enum PenStyle, |
837 |
+ , pS_SOLID = PS_SOLID // default |
838 |
+ , pS_DASH = PS_DASH // ------- |
839 |
+ , pS_DOT = PS_DOT // ....... |
840 |
+@@ -69,14 +69,14 @@ type PenStyle = INT |
841 |
+ , pS_STYLE_MASK = PS_STYLE_MASK // all the above |
842 |
+ } |
843 |
+ |
844 |
+-#{enum PenStyle , // "or" with one of these |
845 |
++#{enum PenStyle, |
846 |
+ , pS_ENDCAP_ROUND = PS_ENDCAP_ROUND // default |
847 |
+ , pS_ENDCAP_SQUARE = PS_ENDCAP_SQUARE |
848 |
+ , pS_ENDCAP_FLAT = PS_ENDCAP_FLAT |
849 |
+ , pS_ENDCAP_MASK = PS_ENDCAP_MASK // all the above |
850 |
+ } |
851 |
+ |
852 |
+-#{enum PenStyle, // "or" with one of these |
853 |
++#{enum PenStyle, |
854 |
+ , pS_JOIN_ROUND = PS_JOIN_ROUND // default |
855 |
+ , pS_JOIN_BEVEL = PS_JOIN_BEVEL |
856 |
+ , pS_JOIN_MITER = PS_JOIN_MITER |
857 |
+@@ -87,7 +87,7 @@ If PS_JOIN_MASK is not defined with your GNU Windows32 header files, |
858 |
+ you'll have to define it. |
859 |
+ -} |
860 |
+ |
861 |
+-#{enum PenStyle, // "or" with one of these |
862 |
++#{enum PenStyle, |
863 |
+ , pS_COSMETIC = PS_COSMETIC // default |
864 |
+ , pS_GEOMETRIC = PS_GEOMETRIC |
865 |
+ , pS_TYPE_MASK = PS_TYPE_MASK // all the above |
866 |
+diff --git a/System/Win32/Info/Computer.hsc b/System/Win32/Info/Computer.hsc |
867 |
+index bb2eb72..65ae8dc 100644 |
868 |
+--- a/System/Win32/Info/Computer.hsc |
869 |
++++ b/System/Win32/Info/Computer.hsc |
870 |
+@@ -65,7 +65,7 @@ import System.Win32.Utils ( tryWithoutNull ) |
871 |
+ import System.Win32.Word ( DWORD, LPDWORD ) |
872 |
+ |
873 |
+ #include <windows.h> |
874 |
+-#include <Lmcons.h> |
875 |
++#include <lmcons.h> |
876 |
+ #include "alignment.h" |
877 |
+ ##include "windows_cconv.h" |
878 |
+ |
879 |
+diff --git a/System/Win32/SimpleMAPI.hsc b/System/Win32/SimpleMAPI.hsc |
880 |
+index 9727cfc..5ebf06b 100644 |
881 |
+--- a/System/Win32/SimpleMAPI.hsc |
882 |
++++ b/System/Win32/SimpleMAPI.hsc |
883 |
+@@ -53,12 +53,6 @@ type MapiFlag = ULONG |
884 |
+ , mAPI_LOGON_UI = MAPI_LOGON_UI |
885 |
+ , mAPI_NEW_SESSION = MAPI_NEW_SESSION |
886 |
+ , mAPI_FORCE_DOWNLOAD = MAPI_FORCE_DOWNLOAD |
887 |
+-#ifdef MAPI_LOGOFF_SHARED |
888 |
+- , mAPI_LOGOFF_SHARED = MAPI_LOGOFF_SHARED |
889 |
+-#endif |
890 |
+-#ifdef MAPI_LOGOFF_UI |
891 |
+- , mAPI_LOGOFF_UI = MAPI_LOGOFF_UI |
892 |
+-#endif |
893 |
+ , mAPI_DIALOG = MAPI_DIALOG |
894 |
+ , mAPI_UNREAD_ONLY = MAPI_UNREAD_ONLY |
895 |
+ , mAPI_LONG_MSGID = MAPI_LONG_MSGID |
896 |
+@@ -74,6 +68,19 @@ type MapiFlag = ULONG |
897 |
+ , mAPI_RECEIPT_REQUESTED = MAPI_RECEIPT_REQUESTED |
898 |
+ , mAPI_SENT = MAPI_SENT |
899 |
+ } |
900 |
++-- Have to define enum values outside previous declaration due to |
901 |
++-- hsc2hs bug in --cross-compile mode: |
902 |
++-- https://ghc.haskell.org/trac/ghc/ticket/13620 |
903 |
++#ifdef MAPI_LOGOFF_SHARED |
904 |
++#{enum MapiFlag, |
905 |
++ , mAPI_LOGOFF_SHARED = MAPI_LOGOFF_SHARED |
906 |
++} |
907 |
++#endif |
908 |
++#ifdef MAPI_LOGOFF_UI |
909 |
++#{enum MapiFlag, |
910 |
++ , mAPI_LOGOFF_UI = MAPI_LOGOFF_UI |
911 |
++} |
912 |
++#endif |
913 |
+ |
914 |
+ mapiErrors :: [(ULONG,String)] |
915 |
+ mapiErrors = |
916 |
|
917 |
diff --git a/dev-lang/ghc/files/ghc-8.2.1_rc1-win32-cross-2-hack.patch b/dev-lang/ghc/files/ghc-8.2.1_rc1-win32-cross-2-hack.patch |
918 |
new file mode 100644 |
919 |
index 00000000000..6fdcf2d1278 |
920 |
--- /dev/null |
921 |
+++ b/dev-lang/ghc/files/ghc-8.2.1_rc1-win32-cross-2-hack.patch |
922 |
@@ -0,0 +1,144 @@ |
923 |
+hsc2hs can't detect values at compile-time if those are |
924 |
+declared as pointers: https://github.com/haskell/win32/issues/88 |
925 |
+ |
926 |
+This patch is a huge hack: we encode absolute vaues from <windows.h> |
927 |
+diff --git a/Graphics/Win32/GDI/Types.hsc b/Graphics/Win32/GDI/Types.hsc |
928 |
+index c363530..8643cee 100644 |
929 |
+--- a/Graphics/Win32/GDI/Types.hsc |
930 |
++++ b/Graphics/Win32/GDI/Types.hsc |
931 |
+@@ -216,10 +216,10 @@ type HWND = HANDLE |
932 |
+ type MbHWND = Maybe HWND |
933 |
+ |
934 |
+ #{enum HWND, castUINTPtrToPtr |
935 |
+- , hWND_BOTTOM = (UINT_PTR)HWND_BOTTOM |
936 |
+- , hWND_NOTOPMOST = (UINT_PTR)HWND_NOTOPMOST |
937 |
+- , hWND_TOP = (UINT_PTR)HWND_TOP |
938 |
+- , hWND_TOPMOST = (UINT_PTR)HWND_TOPMOST |
939 |
++ , hWND_BOTTOM = (UINT_PTR)(INT_PTR)(1) |
940 |
++ , hWND_NOTOPMOST = (UINT_PTR)(INT_PTR)(-2) |
941 |
++ , hWND_TOP = (UINT_PTR)(INT_PTR)(0) |
942 |
++ , hWND_TOPMOST = (UINT_PTR)(INT_PTR)(-1) |
943 |
+ } |
944 |
+ |
945 |
+ type HMENU = HANDLE |
946 |
+diff --git a/Graphics/Win32/Misc.hsc b/Graphics/Win32/Misc.hsc |
947 |
+index 1248b5a..c791a20 100644 |
948 |
+--- a/Graphics/Win32/Misc.hsc |
949 |
++++ b/Graphics/Win32/Misc.hsc |
950 |
+@@ -67,23 +67,23 @@ foreign import WINDOWS_CCONV unsafe "windows.h LoadIconW" |
951 |
+ c_LoadIcon :: HINSTANCE -> Icon -> IO HICON |
952 |
+ |
953 |
+ #{enum Cursor, castUINTPtrToPtr |
954 |
+- , iDC_ARROW = (UINT_PTR)IDC_ARROW |
955 |
+- , iDC_IBEAM = (UINT_PTR)IDC_IBEAM |
956 |
+- , iDC_WAIT = (UINT_PTR)IDC_WAIT |
957 |
+- , iDC_CROSS = (UINT_PTR)IDC_CROSS |
958 |
+- , iDC_UPARROW = (UINT_PTR)IDC_UPARROW |
959 |
+- , iDC_SIZENWSE = (UINT_PTR)IDC_SIZENWSE |
960 |
+- , iDC_SIZENESW = (UINT_PTR)IDC_SIZENESW |
961 |
+- , iDC_SIZEWE = (UINT_PTR)IDC_SIZEWE |
962 |
+- , iDC_SIZENS = (UINT_PTR)IDC_SIZENS |
963 |
++ , iDC_ARROW = (UINT_PTR)(32512) |
964 |
++ , iDC_IBEAM = (UINT_PTR)(32513) |
965 |
++ , iDC_WAIT = (UINT_PTR)(32514) |
966 |
++ , iDC_CROSS = (UINT_PTR)(32515) |
967 |
++ , iDC_UPARROW = (UINT_PTR)(32516) |
968 |
++ , iDC_SIZENWSE = (UINT_PTR)(32642) |
969 |
++ , iDC_SIZENESW = (UINT_PTR)(32643) |
970 |
++ , iDC_SIZEWE = (UINT_PTR)(32644) |
971 |
++ , iDC_SIZENS = (UINT_PTR)(32645) |
972 |
+ } |
973 |
+ |
974 |
+ #{enum Icon, castUINTPtrToPtr |
975 |
+- , iDI_APPLICATION = (UINT_PTR)IDI_APPLICATION |
976 |
+- , iDI_HAND = (UINT_PTR)IDI_HAND |
977 |
+- , iDI_QUESTION = (UINT_PTR)IDI_QUESTION |
978 |
+- , iDI_EXCLAMATION = (UINT_PTR)IDI_EXCLAMATION |
979 |
+- , iDI_ASTERISK = (UINT_PTR)IDI_ASTERISK |
980 |
++ , iDI_APPLICATION = (UINT_PTR)(32512) |
981 |
++ , iDI_HAND = (UINT_PTR)(32513) |
982 |
++ , iDI_QUESTION = (UINT_PTR)(32514) |
983 |
++ , iDI_EXCLAMATION = (UINT_PTR)(32515) |
984 |
++ , iDI_ASTERISK = (UINT_PTR)(32516) |
985 |
+ } |
986 |
+ |
987 |
+ ---------------------------------------------------------------- |
988 |
+diff --git a/Graphics/Win32/Resource.hsc b/Graphics/Win32/Resource.hsc |
989 |
+index e8ad565..ca58fa2 100644 |
990 |
+--- a/Graphics/Win32/Resource.hsc |
991 |
++++ b/Graphics/Win32/Resource.hsc |
992 |
+@@ -61,23 +61,23 @@ foreign import WINDOWS_CCONV unsafe "windows.h EndUpdateResourceW" |
993 |
+ type ResourceType = LPCTSTR |
994 |
+ |
995 |
+ #{enum ResourceType, castUINTPtrToPtr |
996 |
+- , rT_ACCELERATOR = (UINT_PTR)RT_ACCELERATOR // Accelerator table |
997 |
+- , rT_ANICURSOR = (UINT_PTR)RT_ANICURSOR // Animated cursor |
998 |
+- , rT_ANIICON = (UINT_PTR)RT_ANIICON // Animated icon |
999 |
+- , rT_BITMAP = (UINT_PTR)RT_BITMAP // Bitmap resource |
1000 |
+- , rT_CURSOR = (UINT_PTR)RT_CURSOR // Hardware-dependent cursor resource |
1001 |
+- , rT_DIALOG = (UINT_PTR)RT_DIALOG // Dialog box |
1002 |
+- , rT_FONT = (UINT_PTR)RT_FONT // Font resource |
1003 |
+- , rT_FONTDIR = (UINT_PTR)RT_FONTDIR // Font directory resource |
1004 |
+- , rT_GROUP_CURSOR = (UINT_PTR)RT_GROUP_CURSOR // Hardware-independent cursor resource |
1005 |
+- , rT_GROUP_ICON = (UINT_PTR)RT_GROUP_ICON // Hardware-independent icon resource |
1006 |
+- , rT_HTML = (UINT_PTR)RT_HTML // HTML document |
1007 |
+- , rT_ICON = (UINT_PTR)RT_ICON // Hardware-dependent icon resource |
1008 |
+- , rT_MENU = (UINT_PTR)RT_MENU // Menu resource |
1009 |
+- , rT_MESSAGETABLE = (UINT_PTR)RT_MESSAGETABLE // Message-table entry |
1010 |
+- , rT_RCDATA = (UINT_PTR)RT_RCDATA // Application-defined resource (raw data) |
1011 |
+- , rT_STRING = (UINT_PTR)RT_STRING // String-table entry |
1012 |
+- , rT_VERSION = (UINT_PTR)RT_VERSION // Version resource |
1013 |
++ , rT_ACCELERATOR = (UINT_PTR)(9) |
1014 |
++ , rT_ANICURSOR = (UINT_PTR)(21) |
1015 |
++ , rT_ANIICON = (UINT_PTR)(22) |
1016 |
++ , rT_BITMAP = (UINT_PTR)(2) |
1017 |
++ , rT_CURSOR = (UINT_PTR)(1) |
1018 |
++ , rT_DIALOG = (UINT_PTR)(5) |
1019 |
++ , rT_FONT = (UINT_PTR)(8) |
1020 |
++ , rT_FONTDIR = (UINT_PTR)(7) |
1021 |
++ , rT_GROUP_CURSOR = (UINT_PTR)(1 + DIFFERENCE) |
1022 |
++ , rT_GROUP_ICON = (UINT_PTR)(3 + DIFFERENCE) |
1023 |
++ , rT_HTML = (UINT_PTR)(23) |
1024 |
++ , rT_ICON = (UINT_PTR)(3) |
1025 |
++ , rT_MENU = (UINT_PTR)(4) |
1026 |
++ , rT_MESSAGETABLE = (UINT_PTR)(11) |
1027 |
++ , rT_RCDATA = (UINT_PTR)(10) |
1028 |
++ , rT_STRING = (UINT_PTR)(6) |
1029 |
++ , rT_VERSION = (UINT_PTR)(16) |
1030 |
+ } |
1031 |
+ |
1032 |
+ findResource :: HMODULE -> String -> ResourceType -> IO HRSRC |
1033 |
+diff --git a/Graphics/Win32/Window/PostMessage.hsc b/Graphics/Win32/Window/PostMessage.hsc |
1034 |
+index 7f4c9f0..609f3f6 100644 |
1035 |
+--- a/Graphics/Win32/Window/PostMessage.hsc |
1036 |
++++ b/Graphics/Win32/Window/PostMessage.hsc |
1037 |
+@@ -41,7 +41,7 @@ foreign import WINDOWS_CCONV "windows.h PostThreadMessageW" |
1038 |
+ c_PostThreadMessage :: DWORD -> WindowMessage -> WPARAM -> LPARAM -> IO BOOL |
1039 |
+ |
1040 |
+ #{enum HWND, castUINTPtrToPtr |
1041 |
+- , hWND_BROADCAST = (UINT_PTR)HWND_BROADCAST |
1042 |
++ , hWND_BROADCAST = (UINT_PTR)(0xffff) |
1043 |
+ } |
1044 |
+ |
1045 |
+ foreign import WINDOWS_CCONV "windows.h InSendMessage" |
1046 |
+diff --git a/System/Win32/Registry.hsc b/System/Win32/Registry.hsc |
1047 |
+index afbb011..c7edfc1 100644 |
1048 |
+--- a/System/Win32/Registry.hsc |
1049 |
++++ b/System/Win32/Registry.hsc |
1050 |
+@@ -80,11 +80,11 @@ import System.Win32.Types (castUINTPtrToPtr, failUnlessSuccessOr, maybePtr) |
1051 |
+ #include <windows.h> |
1052 |
+ |
1053 |
+ #{enum HKEY, (unsafePerformIO . newForeignHANDLE . castUINTPtrToPtr) |
1054 |
+- , hKEY_CLASSES_ROOT = (UINT_PTR)HKEY_CLASSES_ROOT |
1055 |
+- , hKEY_CURRENT_CONFIG = (UINT_PTR)HKEY_CURRENT_CONFIG |
1056 |
+- , hKEY_CURRENT_USER = (UINT_PTR)HKEY_CURRENT_USER |
1057 |
+- , hKEY_LOCAL_MACHINE = (UINT_PTR)HKEY_LOCAL_MACHINE |
1058 |
+- , hKEY_USERS = (UINT_PTR)HKEY_USERS |
1059 |
++ , hKEY_CLASSES_ROOT = (UINT_PTR)(0x80000000) |
1060 |
++ , hKEY_CURRENT_CONFIG = (UINT_PTR)(0x80000005) |
1061 |
++ , hKEY_CURRENT_USER = (UINT_PTR)(0x80000001) |
1062 |
++ , hKEY_LOCAL_MACHINE = (UINT_PTR)(0x80000002) |
1063 |
++ , hKEY_USERS = (UINT_PTR)(0x80000003) |
1064 |
+ } |
1065 |
+ -- , PKEYERFORMANCE_DATA NT only |
1066 |
+ -- , HKEY_DYN_DATA 95/98 only |
1067 |
|
1068 |
diff --git a/dev-lang/ghc/files/ghc-8.2.1_rc2-O2-unreg.patch b/dev-lang/ghc/files/ghc-8.2.1_rc2-O2-unreg.patch |
1069 |
new file mode 100644 |
1070 |
index 00000000000..00f9ca4fdff |
1071 |
--- /dev/null |
1072 |
+++ b/dev-lang/ghc/files/ghc-8.2.1_rc2-O2-unreg.patch |
1073 |
@@ -0,0 +1,35 @@ |
1074 |
+ghc -O2 generates too large C files for unregisterised compiler. |
1075 |
+On ia64 it causes DynFlags to compile for 60 minutes (then assembler |
1076 |
+crashes). |
1077 |
+ |
1078 |
+To decrease C code inflation we don't use -O2 in UNREG mode. |
1079 |
+diff --git a/mk/config.mk.in b/mk/config.mk.in |
1080 |
+index 4e61eea..15a56e9 100644 |
1081 |
+--- a/mk/config.mk.in |
1082 |
++++ b/mk/config.mk.in |
1083 |
+@@ -72,11 +72,2 @@ GhcStage3HcOpts=-O2 |
1084 |
+ |
1085 |
+-# Disable -O2 optimization. Otherwise amount of generated C code |
1086 |
+-# makes things very slow to compile (~5 minutes on core-i7 for 'compiler/hsSyn/HsExpr.hs') |
1087 |
+-# and sometimes not compile at all (powerpc64 overflows something |
1088 |
+-# on 'compiler/hsSyn/HsExpr.hs'). |
1089 |
+-ifeq "$(GhcUnregisterised)" "YES" |
1090 |
+-GhcStage1HcOpts= |
1091 |
+-GhcStage2HcOpts= |
1092 |
+-GhcStage3HcOpts= |
1093 |
+-endif |
1094 |
+ |
1095 |
+@@ -904 +895,13 @@ CURSES_INCLUDE_DIRS = @CURSES_INCLUDE_DIRS@ |
1096 |
+ CURSES_LIB_DIRS = @CURSES_LIB_DIRS@ |
1097 |
++ |
1098 |
++# Disable -O2 optimization. Otherwise amount of generated C code |
1099 |
++# makes things very slow to compile (~5 minutes on core-i7 for 'compiler/hsSyn/HsExpr.hs') |
1100 |
++# and sometimes not compile at all (powerpc64 overflows something |
1101 |
++# on 'compiler/hsSyn/HsExpr.hs'). |
1102 |
++ifeq "$(GhcUnregisterised)" "YES" |
1103 |
++GhcStage1HcOpts= |
1104 |
++GhcStage2HcOpts= |
1105 |
++GhcStage3HcOpts= |
1106 |
++ |
1107 |
++GhcLibHcOpts= |
1108 |
++endif |
1109 |
|
1110 |
diff --git a/dev-lang/ghc/files/ghc-8.2.1_rc3-any-vendor.patch b/dev-lang/ghc/files/ghc-8.2.1_rc3-any-vendor.patch |
1111 |
new file mode 100644 |
1112 |
index 00000000000..b55e37a8bf9 |
1113 |
--- /dev/null |
1114 |
+++ b/dev-lang/ghc/files/ghc-8.2.1_rc3-any-vendor.patch |
1115 |
@@ -0,0 +1,44 @@ |
1116 |
+From c2303dff95aa174021a1950656fdf9a1cf983959 Mon Sep 17 00:00:00 2001 |
1117 |
+From: Sergei Trofimovich <slyfox@g.o> |
1118 |
+Date: Sat, 8 Jul 2017 09:47:12 +0100 |
1119 |
+Subject: [PATCH] aclocal.m4: allow arbitrary <vendor> string in toolchain |
1120 |
+ triplets |
1121 |
+ |
1122 |
+Canonical triplets have a form of |
1123 |
+ <arch>-<vendor>-<os>[-<abi>] |
1124 |
+ |
1125 |
+Checking for vendor is almost never correct as it's an |
1126 |
+arbitrary string. |
1127 |
+ |
1128 |
+It's useful to have multiple "vendors" to denote |
1129 |
+otherwise the same (WRT <arch>, <os>, <abi>) target: |
1130 |
+ --target=x86_64-pc-linux-gnu |
1131 |
+ --target=x86_64-unknown-linux-gnu |
1132 |
+ --target=x86_64-ghc80-linux-gnu |
1133 |
+ --target=x86_64-ghchead-linux-gnu |
1134 |
+ |
1135 |
+Do not fail unknown vendors. Only emit a warning. |
1136 |
+Ideally configure checks should never use "vendor". |
1137 |
+ |
1138 |
+Signed-off-by: Sergei Trofimovich <slyfox@g.o> |
1139 |
+--- |
1140 |
+ aclocal.m4 | 3 +-- |
1141 |
+ 1 file changed, 1 insertion(+), 2 deletions(-) |
1142 |
+ |
1143 |
+diff --git a/aclocal.m4 b/aclocal.m4 |
1144 |
+index 001f813dfc..1d9c09b0cd 100644 |
1145 |
+--- a/aclocal.m4 |
1146 |
++++ b/aclocal.m4 |
1147 |
+@@ -230,8 +230,7 @@ AC_DEFUN([FPTOOLS_SET_HASKELL_PLATFORM_VARS], |
1148 |
+ dec|none|unknown|hp|apple|next|sun|sgi|ibm|montavista|portbld) |
1149 |
+ ;; |
1150 |
+ *) |
1151 |
+- echo "Unknown vendor [$]1" |
1152 |
+- exit 1 |
1153 |
++ AC_MSG_WARN([Unknown vendor [$]1]) |
1154 |
+ ;; |
1155 |
+ esac |
1156 |
+ } |
1157 |
+-- |
1158 |
+2.13.3 |
1159 |
+ |
1160 |
|
1161 |
diff --git a/dev-lang/ghc/files/ghc-8.2.1_rc3-stginit-data.patch b/dev-lang/ghc/files/ghc-8.2.1_rc3-stginit-data.patch |
1162 |
new file mode 100644 |
1163 |
index 00000000000..81e751d778c |
1164 |
--- /dev/null |
1165 |
+++ b/dev-lang/ghc/files/ghc-8.2.1_rc3-stginit-data.patch |
1166 |
@@ -0,0 +1,27 @@ |
1167 |
+Fix label type for __stginit_* labels: those are .data labels, not .text |
1168 |
+ |
1169 |
+Noticed when was building --enable-unregisterised build for x86_64: |
1170 |
+ |
1171 |
+/tmp/ghc22931_0/ghc_3.hc:5:9: error: |
1172 |
+ error: '__stginit_ghczmprim_GHCziTypes' redeclared as different kind of symbol |
1173 |
+ StgWord __stginit_ghczmprim_GHCziTypes[]__attribute__((aligned(8)))= { |
1174 |
+ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
1175 |
+ | |
1176 |
+5 | StgWord __stginit_ghczmprim_GHCziTypes[]__attribute__((aligned(8)))= { |
1177 |
+ | ^ |
1178 |
+ |
1179 |
+In file included from /tmp/ghc22931_0/ghc_3.hc:3:0: error: |
1180 |
+ |
1181 |
+/tmp/ghc22931_0/ghc_3.hc:4:5: error: |
1182 |
+ note: previous declaration of '__stginit_ghczmprim_GHCziTypes' was here |
1183 |
+ EF_(__stginit_ghczmprim_GHCziTypes); |
1184 |
+ ^ |
1185 |
+diff --git a/compiler/cmm/CLabel.hs b/compiler/cmm/CLabel.hs |
1186 |
+index 77a889a..05d71ab 100644 |
1187 |
+--- a/compiler/cmm/CLabel.hs |
1188 |
++++ b/compiler/cmm/CLabel.hs |
1189 |
+@@ -956,3 +956,3 @@ labelType (CaseLabel _ CaseReturnInfo) = DataLabel |
1190 |
+ labelType (CaseLabel _ _) = CodeLabel |
1191 |
+-labelType (PlainModuleInitLabel _) = CodeLabel |
1192 |
++labelType (PlainModuleInitLabel _) = DataLabel |
1193 |
+ labelType (SRTLabel _) = DataLabel |
1194 |
|
1195 |
diff --git a/dev-lang/ghc/ghc-8.2.1.ebuild b/dev-lang/ghc/ghc-8.2.1.ebuild |
1196 |
new file mode 100644 |
1197 |
index 00000000000..56c31c83f65 |
1198 |
--- /dev/null |
1199 |
+++ b/dev-lang/ghc/ghc-8.2.1.ebuild |
1200 |
@@ -0,0 +1,770 @@ |
1201 |
+# Copyright 1999-2017 Gentoo Foundation |
1202 |
+# Distributed under the terms of the GNU General Public License v2 |
1203 |
+ |
1204 |
+EAPI=5 |
1205 |
+ |
1206 |
+# to make make a crosscompiler use crossdev and symlink ghc tree into |
1207 |
+# cross overlay. result would look like 'cross-sparc-unknown-linux-gnu/ghc' |
1208 |
+export CBUILD=${CBUILD:-${CHOST}} |
1209 |
+export CTARGET=${CTARGET:-${CHOST}} |
1210 |
+if [[ ${CTARGET} = ${CHOST} ]] ; then |
1211 |
+ if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then |
1212 |
+ export CTARGET=${CATEGORY/cross-} |
1213 |
+ fi |
1214 |
+fi |
1215 |
+ |
1216 |
+inherit autotools bash-completion-r1 eutils flag-o-matic ghc-package |
1217 |
+inherit multilib pax-utils toolchain-funcs versionator prefix |
1218 |
+inherit check-reqs |
1219 |
+DESCRIPTION="The Glasgow Haskell Compiler" |
1220 |
+HOMEPAGE="http://www.haskell.org/ghc/" |
1221 |
+ |
1222 |
+# we don't have any binaries yet |
1223 |
+arch_binaries="" |
1224 |
+ |
1225 |
+# sorted! |
1226 |
+#arch_binaries="$arch_binaries alpha? ( http://code.haskell.org/~slyfox/ghc-alpha/ghc-bin-${PV}-alpha.tbz2 )" |
1227 |
+#arch_binaries="$arch_binaries arm? ( http://code.haskell.org/~slyfox/ghc-arm/ghc-bin-${PV}-armv7a-hardfloat-linux-gnueabi.tbz2 )" |
1228 |
+#arch_binaries="$arch_binaries arm64? ( http://code.haskell.org/~slyfox/ghc-arm64/ghc-bin-${PV}-aarch64-unknown-linux-gnu.tbz2 )" |
1229 |
+arch_binaries="$arch_binaries amd64? ( http://code.haskell.org/~slyfox/ghc-amd64/ghc-bin-${PV}-x86_64-pc-linux-gnu.tbz2 )" |
1230 |
+#arch_binaries="$arch_binaries ia64? ( http://code.haskell.org/~slyfox/ghc-ia64/ghc-bin-${PV}-ia64-fixed-fiw.tbz2 )" |
1231 |
+#arch_binaries="$arch_binaries ppc? ( http://code.haskell.org/~slyfox/ghc-ppc/ghc-bin-${PV}-ppc.tbz2 )" |
1232 |
+#arch_binaries="$arch_binaries ppc64? ( http://code.haskell.org/~slyfox/ghc-ppc64/ghc-bin-${PV}-ppc64.tbz2 )" |
1233 |
+#arch_binaries="$arch_binaries sparc? ( http://code.haskell.org/~slyfox/ghc-sparc/ghc-bin-${PV}-sparc.tbz2 )" |
1234 |
+arch_binaries="$arch_binaries x86? ( http://code.haskell.org/~slyfox/ghc-x86/ghc-bin-${PV}-i686-pc-linux-gnu.tbz2 )" |
1235 |
+ |
1236 |
+# various ports: |
1237 |
+#arch_binaries="$arch_binaries x86-fbsd? ( http://code.haskell.org/~slyfox/ghc-x86-fbsd/ghc-bin-${PV}-x86-fbsd.tbz2 )" |
1238 |
+ |
1239 |
+# 0 - yet |
1240 |
+yet_binary() { |
1241 |
+ case "${ARCH}" in |
1242 |
+ #alpha) return 0 ;; |
1243 |
+ #arm64) return 0 ;; |
1244 |
+ #arm) return 0 ;; |
1245 |
+ amd64) return 0 ;; |
1246 |
+ #ia64) return 0 ;; |
1247 |
+ #ppc) return 0 ;; |
1248 |
+ #ppc64) return 0 ;; |
1249 |
+ #sparc) return 0 ;; |
1250 |
+ x86) return 0 ;; |
1251 |
+ *) return 1 ;; |
1252 |
+ esac |
1253 |
+} |
1254 |
+ |
1255 |
+GHC_PV=${PV} |
1256 |
+#GHC_PV=8.2.0.20170704 # uncomment only for -rc ebuilds |
1257 |
+GHC_P=${PN}-${GHC_PV} # using ${P} is almost never correct |
1258 |
+ |
1259 |
+SRC_URI="!binary? ( http://downloads.haskell.org/~ghc/${PV/_rc/-rc}/${GHC_P}-src.tar.xz )" |
1260 |
+S="${WORKDIR}"/${GHC_P} |
1261 |
+ |
1262 |
+[[ -n $arch_binaries ]] && SRC_URI+=" !ghcbootstrap? ( $arch_binaries )" |
1263 |
+ |
1264 |
+BUMP_LIBRARIES=( |
1265 |
+ # "hackage-name hackage-version" |
1266 |
+) |
1267 |
+ |
1268 |
+LICENSE="BSD" |
1269 |
+SLOT="0/${PV}" |
1270 |
+#KEYWORDS="~alpha ~amd64 ~x86 ~amd64-linux ~x86-linux" |
1271 |
+IUSE="doc ghcbootstrap ghcmakebinary +gmp profile" |
1272 |
+IUSE+=" binary" |
1273 |
+ |
1274 |
+RDEPEND=" |
1275 |
+ >=dev-lang/perl-5.6.1 |
1276 |
+ dev-libs/gmp:0= |
1277 |
+ sys-libs/ncurses:0=[unicode] |
1278 |
+ !ghcmakebinary? ( virtual/libffi:= ) |
1279 |
+" |
1280 |
+ |
1281 |
+# This set of dependencies is needed to run |
1282 |
+# prebuilt ghc. We specifically avoid ncurses |
1283 |
+# dependency with: |
1284 |
+# utils/ghc-pkg_HC_OPTS += -DBOOTSTRAPPING |
1285 |
+PREBUILT_BINARY_DEPENDS=" |
1286 |
+ !prefix? ( elibc_glibc? ( >=sys-libs/glibc-2.17 ) ) |
1287 |
+" |
1288 |
+# This set of dependencies is needed to install |
1289 |
+# ghc[binary] in system. terminfo package is linked |
1290 |
+# against ncurses. |
1291 |
+PREBUILT_BINARY_RDEPENDS="${PREBUILT_BINARY_DEPENDS} |
1292 |
+ sys-libs/ncurses:0/6 |
1293 |
+" |
1294 |
+ |
1295 |
+RDEPEND+="binary? ( ${PREBUILT_BINARY_RDEPENDS} )" |
1296 |
+ |
1297 |
+DEPEND="${RDEPEND} |
1298 |
+ doc? ( app-text/docbook-xml-dtd:4.2 |
1299 |
+ app-text/docbook-xml-dtd:4.5 |
1300 |
+ app-text/docbook-xsl-stylesheets |
1301 |
+ dev-python/sphinx |
1302 |
+ >=dev-libs/libxslt-1.1.2 ) |
1303 |
+ !ghcbootstrap? ( ${PREBUILT_BINARY_DEPENDS} )" |
1304 |
+ |
1305 |
+PDEPEND="!ghcbootstrap? ( =app-admin/haskell-updater-1.2* )" |
1306 |
+ |
1307 |
+REQUIRED_USE="?? ( ghcbootstrap binary )" |
1308 |
+ |
1309 |
+# haskell libraries built with cabal in configure mode, #515354 |
1310 |
+QA_CONFIGURE_OPTIONS+=" --with-compiler --with-gcc" |
1311 |
+ |
1312 |
+is_crosscompile() { |
1313 |
+ [[ ${CHOST} != ${CTARGET} ]] |
1314 |
+} |
1315 |
+ |
1316 |
+is_native() { |
1317 |
+ [[ ${CHOST} == ${CBUILD} ]] && [[ ${CHOST} == ${CTARGET} ]] |
1318 |
+} |
1319 |
+ |
1320 |
+# returns tool prefix for crosscompiler. |
1321 |
+# Example: |
1322 |
+# CTARGET=armv7a-unknown-linux-gnueabi |
1323 |
+# CHOST=x86_64-pc-linux-gnu |
1324 |
+# "armv7a-unknown-linux-gnueabi-" |
1325 |
+# CTARGET=${CHOST} |
1326 |
+# "" |
1327 |
+# Used in tools and library prefix: |
1328 |
+# "${ED}"/usr/bin/$(cross)haddock |
1329 |
+# "${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d" |
1330 |
+ |
1331 |
+cross() { |
1332 |
+ if is_crosscompile; then |
1333 |
+ echo "${CTARGET}-" |
1334 |
+ else |
1335 |
+ echo "" |
1336 |
+ fi |
1337 |
+} |
1338 |
+ |
1339 |
+append-ghc-cflags() { |
1340 |
+ local persistent compile assemble link |
1341 |
+ local flag ghcflag |
1342 |
+ |
1343 |
+ for flag in $*; do |
1344 |
+ case ${flag} in |
1345 |
+ persistent) persistent="yes";; |
1346 |
+ compile) compile="yes";; |
1347 |
+ assemble) assemble="yes";; |
1348 |
+ link) link="yes";; |
1349 |
+ *) |
1350 |
+ [[ ${compile} ]] && ghcflag="-optc${flag}" CFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" && |
1351 |
+ [[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}" |
1352 |
+ [[ ${assemble} ]] && ghcflag="-opta${flag}" CFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" && |
1353 |
+ [[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}" |
1354 |
+ [[ ${link} ]] && ghcflag="-optl${flag}" LDFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" && |
1355 |
+ [[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}" |
1356 |
+ ;; |
1357 |
+ esac |
1358 |
+ done |
1359 |
+} |
1360 |
+ |
1361 |
+# $1 - lib name (under libraries/) |
1362 |
+# $2 - lib version |
1363 |
+# example: bump_lib "transformers" "0.4.2.0" |
1364 |
+bump_lib() { |
1365 |
+ local pn=$1 pv=$2 |
1366 |
+ local p=${pn}-${pv} |
1367 |
+ local f |
1368 |
+ |
1369 |
+ einfo "Bumping ${pn} up to ${pv}" |
1370 |
+ |
1371 |
+ for f in ghc.mk GNUmakefile; do |
1372 |
+ mv libraries/"${pn}"/$f "${WORKDIR}"/"${p}"/$f || die |
1373 |
+ done |
1374 |
+ mv libraries/"${pn}" "${WORKDIR}"/"${pn}".old || die |
1375 |
+ mv "${WORKDIR}"/"${p}" libraries/"${pn}" || die |
1376 |
+} |
1377 |
+ |
1378 |
+update_SRC_URI() { |
1379 |
+ local p pn pv |
1380 |
+ for p in "${BUMP_LIBRARIES[@]}"; do |
1381 |
+ set -- $p |
1382 |
+ pn=$1 pv=$2 |
1383 |
+ |
1384 |
+ SRC_URI+=" mirror://hackage/package/${pn}/${pn}-${pv}.tar.gz" |
1385 |
+ done |
1386 |
+} |
1387 |
+ |
1388 |
+update_SRC_URI |
1389 |
+ |
1390 |
+bump_libs() { |
1391 |
+ local p pn pv |
1392 |
+ for p in "${BUMP_LIBRARIES[@]}"; do |
1393 |
+ set -- $p |
1394 |
+ pn=$1 pv=$2 |
1395 |
+ |
1396 |
+ bump_lib "${pn}" "${pv}" |
1397 |
+ done |
1398 |
+} |
1399 |
+ |
1400 |
+ghc_setup_cflags() { |
1401 |
+ # TODO: plumb CFLAGS and BUILD_CFLAGS to respective CONF_CC_OPTS_STAGE<N> |
1402 |
+ if ! is_native; then |
1403 |
+ export CFLAGS=${GHC_CFLAGS-"-O2 -pipe"} |
1404 |
+ export LDFLAGS=${GHC_LDFLAGS-"-Wl,-O1"} |
1405 |
+ einfo "Crosscompiling mode:" |
1406 |
+ einfo " CHOST: ${CHOST}" |
1407 |
+ einfo " CTARGET: ${CTARGET}" |
1408 |
+ einfo " CFLAGS: ${CFLAGS}" |
1409 |
+ einfo " LDFLAGS: ${LDFLAGS}" |
1410 |
+ einfo " prefix: $(cross)" |
1411 |
+ return |
1412 |
+ fi |
1413 |
+ # We need to be very careful with the CFLAGS we ask ghc to pass through to |
1414 |
+ # gcc. There are plenty of flags which will make gcc produce output that |
1415 |
+ # breaks ghc in various ways. The main ones we want to pass through are |
1416 |
+ # -mcpu / -march flags. These are important for arches like alpha & sparc. |
1417 |
+ # We also use these CFLAGS for building the C parts of ghc, ie the rts. |
1418 |
+ strip-flags |
1419 |
+ strip-unsupported-flags |
1420 |
+ |
1421 |
+ # Cmm can't parse line numbers #482086 |
1422 |
+ replace-flags -ggdb[3-9] -ggdb2 |
1423 |
+ |
1424 |
+ GHC_FLAGS="" |
1425 |
+ GHC_PERSISTENT_FLAGS="" |
1426 |
+ for flag in ${CFLAGS}; do |
1427 |
+ case ${flag} in |
1428 |
+ |
1429 |
+ # Ignore extra optimisation (ghc passes -O to gcc anyway) |
1430 |
+ # -O2 and above break on too many systems |
1431 |
+ -O*) ;; |
1432 |
+ |
1433 |
+ # Arch and ABI flags are what we're really after |
1434 |
+ -m*) append-ghc-cflags compile assemble ${flag};; |
1435 |
+ |
1436 |
+ # Sometimes it's handy to see backtrace of RTS |
1437 |
+ # to get an idea what happens there |
1438 |
+ -g*) append-ghc-cflags compile ${flag};; |
1439 |
+ |
1440 |
+ # Ignore all other flags, including all -f* flags |
1441 |
+ esac |
1442 |
+ done |
1443 |
+ |
1444 |
+ for flag in ${LDFLAGS}; do |
1445 |
+ append-ghc-cflags link ${flag} |
1446 |
+ done |
1447 |
+ |
1448 |
+ # GHC uses ${CBUILD}-gcc, ${CHOST}-gcc and ${CTARGET}-gcc at a single build. |
1449 |
+ # Skip any gentoo-specific tweaks for cross-case to avoid passing unsupported |
1450 |
+ # options to gcc. |
1451 |
+ if is_native; then |
1452 |
+ # hardened-gcc needs to be disabled, because our prebuilt binaries/libraries |
1453 |
+ # are not built with fPIC, bug #606666 |
1454 |
+ gcc-specs-pie && append-ghc-cflags persistent compile link -nopie |
1455 |
+ tc-is-gcc && version_is_at_least 6.3 $(gcc-version) && if ! use ghcbootstrap; then |
1456 |
+ # gcc-6.3 has support for -no-pie upstream, but spelling differs from |
1457 |
+ # gentoo-specific '-nopie'. We enable it in non-bootstrap to allow |
1458 |
+ # hardened users try '-pie' in USE=ghcbootstrap mode. |
1459 |
+ append-ghc-cflags compile link -no-pie |
1460 |
+ fi |
1461 |
+ |
1462 |
+ # prevent from failing to build unregisterised ghc: |
1463 |
+ # http://www.mail-archive.com/debian-bugs-dist@××××××××××××.org/msg171602.html |
1464 |
+ use ppc64 && append-ghc-cflags persistent compile -mminimal-toc |
1465 |
+ fi |
1466 |
+} |
1467 |
+ |
1468 |
+# substitutes string $1 to $2 in files $3 $4 ... |
1469 |
+relocate_path() { |
1470 |
+ local from=$1 |
1471 |
+ local to=$2 |
1472 |
+ shift 2 |
1473 |
+ local file= |
1474 |
+ for file in "$@" |
1475 |
+ do |
1476 |
+ sed -i -e "s|$from|$to|g" \ |
1477 |
+ "$file" || die "path relocation failed for '$file'" |
1478 |
+ done |
1479 |
+} |
1480 |
+ |
1481 |
+# changes hardcoded ghc paths and updates package index |
1482 |
+# $1 - new absolute root path |
1483 |
+relocate_ghc() { |
1484 |
+ local to=$1 |
1485 |
+ |
1486 |
+ # libdir for prebuilt binary and for current system may mismatch |
1487 |
+ # It does for prefix installation for example: bug #476998 |
1488 |
+ local bin_ghc_prefix=${WORKDIR}/usr |
1489 |
+ local bin_libpath=$(echo "${bin_ghc_prefix}"/lib*) |
1490 |
+ local bin_libdir=${bin_libpath#${bin_ghc_prefix}/} |
1491 |
+ |
1492 |
+ # backup original script to use it later after relocation |
1493 |
+ local gp_back="${T}/ghc-pkg-${GHC_PV}-orig" |
1494 |
+ cp "${WORKDIR}/usr/bin/ghc-pkg-${GHC_PV}" "$gp_back" || die "unable to backup ghc-pkg wrapper" |
1495 |
+ |
1496 |
+ if [[ ${bin_libdir} != $(get_libdir) ]]; then |
1497 |
+ einfo "Relocating '${bin_libdir}' to '$(get_libdir)' (bug #476998)" |
1498 |
+ # moving the dir itself is not strictly needed |
1499 |
+ # but then USE=binary would result in installing |
1500 |
+ # in '${bin_libdir}' |
1501 |
+ mv "${bin_ghc_prefix}/${bin_libdir}" "${bin_ghc_prefix}/$(get_libdir)" || die |
1502 |
+ |
1503 |
+ relocate_path "/usr/${bin_libdir}" "/usr/$(get_libdir)" \ |
1504 |
+ "${WORKDIR}/usr/bin/ghc-${GHC_PV}" \ |
1505 |
+ "${WORKDIR}/usr/bin/ghci-${GHC_PV}" \ |
1506 |
+ "${WORKDIR}/usr/bin/ghc-pkg-${GHC_PV}" \ |
1507 |
+ "${WORKDIR}/usr/bin/hsc2hs" \ |
1508 |
+ "${WORKDIR}/usr/bin/runghc-${GHC_PV}" \ |
1509 |
+ "$gp_back" \ |
1510 |
+ "${WORKDIR}/usr/$(get_libdir)/${GHC_P}/package.conf.d/"* |
1511 |
+ fi |
1512 |
+ |
1513 |
+ # Relocate from /usr to ${EPREFIX}/usr |
1514 |
+ relocate_path "/usr" "${to}/usr" \ |
1515 |
+ "${WORKDIR}/usr/bin/ghc-${GHC_PV}" \ |
1516 |
+ "${WORKDIR}/usr/bin/ghci-${GHC_PV}" \ |
1517 |
+ "${WORKDIR}/usr/bin/ghc-pkg-${GHC_PV}" \ |
1518 |
+ "${WORKDIR}/usr/bin/hsc2hs" \ |
1519 |
+ "${WORKDIR}/usr/bin/runghc-${GHC_PV}" \ |
1520 |
+ "${WORKDIR}/usr/$(get_libdir)/${GHC_P}/package.conf.d/"* |
1521 |
+ |
1522 |
+ # this one we will use to regenerate cache |
1523 |
+ # so it should point to current tree location |
1524 |
+ relocate_path "/usr" "${WORKDIR}/usr" "$gp_back" |
1525 |
+ |
1526 |
+ if use prefix; then |
1527 |
+ # and insert LD_LIBRARY_PATH entry to EPREFIX dir tree |
1528 |
+ # TODO: add the same for darwin's CHOST and it's DYLD_ |
1529 |
+ local new_ldpath='LD_LIBRARY_PATH="'${EPREFIX}/$(get_libdir):${EPREFIX}/usr/$(get_libdir)'${LD_LIBRARY_PATH:+:}${LD_LIBRARY_PATH}"\nexport LD_LIBRARY_PATH' |
1530 |
+ sed -i -e '2i'"$new_ldpath" \ |
1531 |
+ "${WORKDIR}/usr/bin/ghc-${GHC_PV}" \ |
1532 |
+ "${WORKDIR}/usr/bin/ghci-${GHC_PV}" \ |
1533 |
+ "${WORKDIR}/usr/bin/ghc-pkg-${GHC_PV}" \ |
1534 |
+ "${WORKDIR}/usr/bin/hsc2hs" \ |
1535 |
+ "${WORKDIR}/usr/bin/runghc-${GHC_PV}" \ |
1536 |
+ "$gp_back" \ |
1537 |
+ || die "Adding LD_LIBRARY_PATH for wrappers failed" |
1538 |
+ hprefixify "${bin_libpath}"/${PN}*/settings |
1539 |
+ fi |
1540 |
+ |
1541 |
+ # regenerate the binary package cache |
1542 |
+ "$gp_back" recache || die "failed to update cache after relocation" |
1543 |
+ rm "$gp_back" |
1544 |
+} |
1545 |
+ |
1546 |
+ghc-check-reqs() { |
1547 |
+ # These are pessimistic values (slightly bigger than worst-case) |
1548 |
+ # Worst case is UNREG USE=profile ia64. See bug #611866 for some |
1549 |
+ # numbers on various arches. |
1550 |
+ CHECKREQS_DISK_BUILD=8G |
1551 |
+ CHECKREQS_DISK_USR=2G |
1552 |
+ # USE=binary roughly takes |
1553 |
+ use binary && CHECKREQS_DISK_BUILD=4G |
1554 |
+ |
1555 |
+ "$@" |
1556 |
+} |
1557 |
+ |
1558 |
+pkg_pretend() { |
1559 |
+ ghc-check-reqs check-reqs_pkg_pretend |
1560 |
+} |
1561 |
+ |
1562 |
+pkg_setup() { |
1563 |
+ ghc-check-reqs check-reqs_pkg_setup |
1564 |
+ |
1565 |
+ # quiet portage about prebuilt binaries |
1566 |
+ use binary && QA_PREBUILT="*" |
1567 |
+ |
1568 |
+ [[ ${MERGE_TYPE} == binary ]] && return |
1569 |
+ |
1570 |
+ if use ghcbootstrap; then |
1571 |
+ ewarn "You requested ghc bootstrapping, this is usually only used" |
1572 |
+ ewarn "by Gentoo developers to make binary .tbz2 packages." |
1573 |
+ |
1574 |
+ [[ -z $(type -P ghc) ]] && \ |
1575 |
+ die "Could not find a ghc to bootstrap with." |
1576 |
+ else |
1577 |
+ if ! yet_binary; then |
1578 |
+ eerror "Please try emerging with USE=ghcbootstrap and report build" |
1579 |
+ eerror "sucess or failure to the haskell team (haskell@g.o)" |
1580 |
+ die "No binary available for '${ARCH}' arch yet, USE=ghcbootstrap" |
1581 |
+ fi |
1582 |
+ fi |
1583 |
+} |
1584 |
+ |
1585 |
+src_unpack() { |
1586 |
+ # Create the ${S} dir if we're using the binary version |
1587 |
+ use binary && mkdir "${S}" |
1588 |
+ |
1589 |
+ # the Solaris and Darwin binaries from ghc (maeder) need to be |
1590 |
+ # unpacked separately, so prevent them from being unpacked |
1591 |
+ local ONLYA=${A} |
1592 |
+ case ${CHOST} in |
1593 |
+ *-darwin* | *-solaris*) ONLYA=${GHC_P}-src.tar.bz2 ;; |
1594 |
+ esac |
1595 |
+ unpack ${ONLYA} |
1596 |
+} |
1597 |
+ |
1598 |
+src_prepare() { |
1599 |
+ ghc_setup_cflags |
1600 |
+ |
1601 |
+ if ! use ghcbootstrap && [[ ${CHOST} != *-darwin* && ${CHOST} != *-solaris* ]]; then |
1602 |
+ # Modify the wrapper script from the binary tarball to use GHC_PERSISTENT_FLAGS. |
1603 |
+ # See bug #313635. |
1604 |
+ sed -i -e "s|\"\$topdir\"|\"\$topdir\" ${GHC_PERSISTENT_FLAGS}|" \ |
1605 |
+ "${WORKDIR}/usr/bin/ghc-${GHC_PV}" |
1606 |
+ |
1607 |
+ # allow hardened users use vanilla binary to bootstrap ghc |
1608 |
+ # ghci uses mmap with rwx protection at it implements dynamic |
1609 |
+ # linking on it's own (bug #299709) |
1610 |
+ pax-mark -m "${WORKDIR}/usr/$(get_libdir)/${GHC_P}/bin/ghc" |
1611 |
+ fi |
1612 |
+ |
1613 |
+ if use binary; then |
1614 |
+ if use prefix; then |
1615 |
+ relocate_ghc "${EPREFIX}" |
1616 |
+ fi |
1617 |
+ |
1618 |
+ # Move unpacked files to the expected place |
1619 |
+ mv "${WORKDIR}/usr" "${S}" |
1620 |
+ else |
1621 |
+ if ! use ghcbootstrap; then |
1622 |
+ case ${CHOST} in |
1623 |
+ *-darwin* | *-solaris*) |
1624 |
+ # UPDATE ME for ghc-7 |
1625 |
+ mkdir "${WORKDIR}"/ghc-bin-installer || die |
1626 |
+ pushd "${WORKDIR}"/ghc-bin-installer > /dev/null || die |
1627 |
+ use sparc-solaris && unpack ghc-6.10.4-sparc-sun-solaris2.tar.bz2 |
1628 |
+ use x86-solaris && unpack ghc-7.0.3-i386-unknown-solaris2.tar.bz2 |
1629 |
+ use x86-macos && unpack ghc-7.4.1-i386-apple-darwin.tar.bz2 |
1630 |
+ use x64-macos && unpack ghc-7.4.1-x86_64-apple-darwin.tar.bz2 |
1631 |
+ popd > /dev/null |
1632 |
+ |
1633 |
+ pushd "${WORKDIR}"/ghc-bin-installer/ghc-[67].?*.? > /dev/null || die |
1634 |
+ # fix the binaries so they run, on Solaris we need an |
1635 |
+ # LD_LIBRARY_PATH which has our prefix libdirs, on |
1636 |
+ # Darwin we need to replace the frameworks with our libs |
1637 |
+ # from the prefix fix before installation, because some |
1638 |
+ # of the tools are actually used during configure/make |
1639 |
+ if [[ ${CHOST} == *-solaris* ]] ; then |
1640 |
+ export LD_LIBRARY_PATH="${EPREFIX}/$(get_libdir):${EPREFIX}/usr/$(get_libdir):${LD_LIBRARY_PATH}" |
1641 |
+ elif [[ ${CHOST} == *-darwin* ]] ; then |
1642 |
+ local readline_framework=GNUreadline.framework/GNUreadline |
1643 |
+ local gmp_framework=/opt/local/lib/libgmp.10.dylib |
1644 |
+ local ncurses_file=/opt/local/lib/libncurses.5.dylib |
1645 |
+ for binary in $(scanmacho -BRE MH_EXECUTE -F '%F' .) ; do |
1646 |
+ install_name_tool -change \ |
1647 |
+ ${readline_framework} \ |
1648 |
+ "${EPREFIX}"/lib/libreadline.dylib \ |
1649 |
+ ${binary} || die |
1650 |
+ install_name_tool -change \ |
1651 |
+ ${gmp_framework} \ |
1652 |
+ "${EPREFIX}"/usr/lib/libgmp.dylib \ |
1653 |
+ ${binary} || die |
1654 |
+ install_name_tool -change \ |
1655 |
+ ${ncurses_file} \ |
1656 |
+ "${EPREFIX}"/usr/lib/libncurses.dylib \ |
1657 |
+ ${binary} || die |
1658 |
+ done |
1659 |
+ # we don't do frameworks! |
1660 |
+ sed -i \ |
1661 |
+ -e 's/\(frameworks = \)\["GMP"\]/\1[]/g' \ |
1662 |
+ -e 's/\(extraLibraries = \)\["m"\]/\1["m","gmp"]/g' \ |
1663 |
+ rts/package.conf.in || die |
1664 |
+ fi |
1665 |
+ |
1666 |
+ # it is autoconf, but we really don't want to give it too |
1667 |
+ # much arguments, in fact we do the make in-place anyway |
1668 |
+ ./configure --prefix="${WORKDIR}"/usr || die |
1669 |
+ make install || die |
1670 |
+ popd > /dev/null |
1671 |
+ ;; |
1672 |
+ *) |
1673 |
+ relocate_ghc "${WORKDIR}" |
1674 |
+ ;; |
1675 |
+ esac |
1676 |
+ fi |
1677 |
+ |
1678 |
+ sed -i -e "s|\"\$topdir\"|\"\$topdir\" ${GHC_PERSISTENT_FLAGS}|" \ |
1679 |
+ "${S}/ghc/ghc.wrapper" |
1680 |
+ |
1681 |
+ cd "${S}" # otherwise epatch will break |
1682 |
+ |
1683 |
+ epatch "${FILESDIR}"/${PN}-7.0.4-CHOST-prefix.patch |
1684 |
+ |
1685 |
+ epatch "${FILESDIR}"/${PN}-8.2.1_rc1-cgen-constify.patch |
1686 |
+ epatch "${FILESDIR}"/${PN}-7.8.3-prim-lm.patch |
1687 |
+ |
1688 |
+ epatch "${FILESDIR}"/${PN}-8.2.1_rc2-O2-unreg.patch |
1689 |
+ |
1690 |
+ # a bunch of crosscompiler patches |
1691 |
+ epatch "${FILESDIR}"/${PN}-8.2.1_rc1-unphased-cross.patch |
1692 |
+ epatch "${FILESDIR}"/${PN}-8.2.1_rc1-staged-cross.patch |
1693 |
+ epatch "${FILESDIR}"/${PN}-8.2.1_rc1-ghci-cross.patch |
1694 |
+ epatch "${FILESDIR}"/${PN}-8.2.1_rc1-stage2-cross.patch |
1695 |
+ epatch "${FILESDIR}"/${PN}-8.2.1_rc1-hp2ps-cross.patch |
1696 |
+ epatch "${FILESDIR}"/${PN}-8.2.1_rc3-any-vendor.patch |
1697 |
+ epatch "${FILESDIR}"/${PN}-8.2.1_rc3-stginit-data.patch |
1698 |
+ |
1699 |
+ # needs a new libffi release |
1700 |
+ epatch "${FILESDIR}"/${PN}-8.0.2-libffi-alpha.patch |
1701 |
+ |
1702 |
+ # mingw32 target |
1703 |
+ pushd "${S}/libraries/Win32" |
1704 |
+ epatch "${FILESDIR}"/${PN}-8.2.1_rc1-win32-cross-1.patch # upstreamed, waits for merge to -HEAD |
1705 |
+ epatch "${FILESDIR}"/${PN}-8.2.1_rc1-win32-cross-2-hack.patch # bad workaround |
1706 |
+ popd |
1707 |
+ |
1708 |
+ if use prefix; then |
1709 |
+ # Make configure find docbook-xsl-stylesheets from Prefix |
1710 |
+ sed -e '/^FP_DIR_DOCBOOK_XSL/s:\[.*\]:['"${EPREFIX}"'/usr/share/sgml/docbook/xsl-stylesheets/]:' \ |
1711 |
+ -i utils/haddock/doc/configure.ac || die |
1712 |
+ fi |
1713 |
+ |
1714 |
+ bump_libs |
1715 |
+ |
1716 |
+ # as we have changed the build system |
1717 |
+ eautoreconf |
1718 |
+ fi |
1719 |
+} |
1720 |
+ |
1721 |
+src_configure() { |
1722 |
+ if ! use binary; then |
1723 |
+ # initialize build.mk |
1724 |
+ echo '# Gentoo changes' > mk/build.mk |
1725 |
+ |
1726 |
+ # Put docs into the right place, ie /usr/share/doc/ghc-${GHC_PV} |
1727 |
+ echo "docdir = ${EPREFIX}/usr/share/doc/$(cross)${P}" >> mk/build.mk |
1728 |
+ echo "htmldir = ${EPREFIX}/usr/share/doc/$(cross)${P}" >> mk/build.mk |
1729 |
+ |
1730 |
+ # We also need to use the GHC_FLAGS flags when building ghc itself |
1731 |
+ echo "SRC_HC_OPTS+=${HCFLAGS} ${GHC_FLAGS}" >> mk/build.mk |
1732 |
+ echo "SRC_CC_OPTS+=${CFLAGS}" >> mk/build.mk |
1733 |
+ echo "SRC_LD_OPTS+=${LDFLAGS}" >> mk/build.mk |
1734 |
+ # Speed up initial Cabal bootstrap |
1735 |
+ echo "utils/ghc-cabal_dist_EXTRA_HC_OPTS+=$(ghc-make-args)" >> mk/build.mk |
1736 |
+ |
1737 |
+ # We can't depend on haddock except when bootstrapping when we |
1738 |
+ # must build docs and include them into the binary .tbz2 package |
1739 |
+ # app-text/dblatex is not in portage, can not build PDF or PS |
1740 |
+ echo "BUILD_SPHINX_PDF = NO" >> mk/build.mk |
1741 |
+ echo "BUILD_SPHINX_HTML = $(usex doc YES NO)" >> mk/build.mk |
1742 |
+ echo "BUILD_MAN = $(usex doc YES NO)" >> mk/build.mk |
1743 |
+ |
1744 |
+ # this controls presence on 'xhtml' and 'haddock' in final install |
1745 |
+ echo "HADDOCK_DOCS = YES" >> mk/build.mk |
1746 |
+ |
1747 |
+ # not used outside of ghc's test |
1748 |
+ if [[ -n ${GHC_BUILD_DPH} ]]; then |
1749 |
+ echo "BUILD_DPH = YES" >> mk/build.mk |
1750 |
+ else |
1751 |
+ echo "BUILD_DPH = NO" >> mk/build.mk |
1752 |
+ fi |
1753 |
+ |
1754 |
+ # Any non-native build has to skip as it needs |
1755 |
+ # target haddock binary to be runnabine. |
1756 |
+ if ! is_native; then |
1757 |
+ # disable docs generation as it requires running stage2 |
1758 |
+ echo "HADDOCK_DOCS=NO" >> mk/build.mk |
1759 |
+ echo "BUILD_SPHINX_HTML=NO" >> mk/build.mk |
1760 |
+ echo "BUILD_SPHINX_PDF=NO" >> mk/build.mk |
1761 |
+ fi |
1762 |
+ |
1763 |
+ if is_crosscompile; then |
1764 |
+ # Install ghc-stage1 crosscompiler instead of |
1765 |
+ # ghc-stage2 cross-built compiler. |
1766 |
+ echo "Stage1Only=YES" >> mk/build.mk |
1767 |
+ fi |
1768 |
+ |
1769 |
+ # allows overriding build flavours for libraries: |
1770 |
+ # v - vanilla (static libs) |
1771 |
+ # p - profiled |
1772 |
+ # dyn - shared libraries |
1773 |
+ # example: GHC_LIBRARY_WAYS="v dyn" |
1774 |
+ if [[ -n ${GHC_LIBRARY_WAYS} ]]; then |
1775 |
+ echo "GhcLibWays=${GHC_LIBRARY_WAYS}" >> mk/build.mk |
1776 |
+ fi |
1777 |
+ echo "BUILD_PROF_LIBS = $(usex profile YES NO)" >> mk/build.mk |
1778 |
+ |
1779 |
+ # Get ghc from the unpacked binary .tbz2 |
1780 |
+ # except when bootstrapping we just pick ghc up off the path |
1781 |
+ if ! use ghcbootstrap; then |
1782 |
+ export PATH="${WORKDIR}/usr/bin:${PATH}" |
1783 |
+ fi |
1784 |
+ |
1785 |
+ echo "INTEGER_LIBRARY = $(usex gmp integer-gmp integer-simple)" >> mk/build.mk |
1786 |
+ |
1787 |
+ # don't strip anything. Very useful when stage2 SIGSEGVs on you |
1788 |
+ echo "STRIP_CMD = :" >> mk/build.mk |
1789 |
+ |
1790 |
+ local econf_args=() |
1791 |
+ |
1792 |
+ # GHC embeds toolchain it was built by and uses it later. |
1793 |
+ # Don't allow things like ccache or versioned binary slip. |
1794 |
+ # We use stable thing across gcc upgrades. |
1795 |
+ # User can use EXTRA_ECONF=CC=... to override this default. |
1796 |
+ econf_args+=( |
1797 |
+ AR=${CTARGET}-ar |
1798 |
+ CC=${CTARGET}-gcc |
1799 |
+ LD=${CTARGET}-ld |
1800 |
+ # these should be inferred by GHC but ghc defaults |
1801 |
+ # to using bundled tools on windows. |
1802 |
+ Windres=${CTARGET}-windres |
1803 |
+ DllWrap=${CTARGET}-dllwrap |
1804 |
+ ) |
1805 |
+ if [[ ${CTARGET} == arm* ]] ; then |
1806 |
+ # ld.bfd-2.28 does not work for ghc. Force ld.gold |
1807 |
+ # instead. This should be removed once gentoo gets |
1808 |
+ # a fix for R_ARM_COPY bug: https://sourceware.org/PR16177 |
1809 |
+ econf_args+=(LD=${CTARGET}-ld.gold) |
1810 |
+ fi |
1811 |
+ |
1812 |
+ if [[ ${CBUILD} != ${CHOST} ]]; then |
1813 |
+ # GHC bug: ghc claims not to support cross-building. |
1814 |
+ # It does, but does not distinct --host= value |
1815 |
+ # for stage1 and stage2 compiler. |
1816 |
+ econf_args+=(--host=${CBUILD}) |
1817 |
+ fi |
1818 |
+ |
1819 |
+ if use ghcmakebinary; then |
1820 |
+ # When building booting libary we are trying to |
1821 |
+ # bundle or restrict most of external depends |
1822 |
+ # with unstable ABI: |
1823 |
+ # - embed libffi (default GHC behaviour) |
1824 |
+ # - disable ncurses support for ghci (via haskeline) |
1825 |
+ # https://bugs.gentoo.org/557478 |
1826 |
+ # - disable ncurses support for ghc-pkg |
1827 |
+ echo "libraries/haskeline_CONFIGURE_OPTS += --flag=-terminfo" >> mk/build.mk |
1828 |
+ echo "utils/ghc-pkg_HC_OPTS += -DBOOTSTRAPPING" >> mk/build.mk |
1829 |
+ elif is_native; then |
1830 |
+ # using ${GTARGET}'s libffi is not supported yet: |
1831 |
+ # GHC embeds full path for ffi includes without /usr/${CTARGET} account. |
1832 |
+ econf_args+=(--with-system-libffi) |
1833 |
+ econf_args+=(--with-ffi-includes=$(pkg-config libffi --cflags-only-I | sed -e 's@^-I@@')) |
1834 |
+ fi |
1835 |
+ |
1836 |
+ einfo "Final mk/build.mk:" |
1837 |
+ cat mk/build.mk || die |
1838 |
+ |
1839 |
+ econf ${econf_args[@]} --enable-bootstrap-with-devel-snapshot |
1840 |
+ |
1841 |
+ if [[ ${PV} == *9999* ]]; then |
1842 |
+ GHC_PV="$(grep 'S\[\"PACKAGE_VERSION\"\]' config.status | sed -e 's@^.*=\"\(.*\)\"@\1@')" |
1843 |
+ GHC_P=${PN}-${GHC_PV} |
1844 |
+ fi |
1845 |
+ fi # ! use binary |
1846 |
+} |
1847 |
+ |
1848 |
+src_compile() { |
1849 |
+ if ! use binary; then |
1850 |
+ # Stage1Only crosscompiler does not build stage2 |
1851 |
+ if ! is_crosscompile; then |
1852 |
+ # 1. build/pax-mark compiler binary first |
1853 |
+ emake ghc/stage2/build/tmp/ghc-stage2 |
1854 |
+ # 2. pax-mark (bug #516430) |
1855 |
+ pax-mark -m ghc/stage2/build/tmp/ghc-stage2 |
1856 |
+ # 2. build/pax-mark haddock using ghc-stage2 |
1857 |
+ if is_native; then |
1858 |
+ # non-native build does not build haddock |
1859 |
+ # due to HADDOCK_DOCS=NO, but it could. |
1860 |
+ emake utils/haddock/dist/build/tmp/haddock |
1861 |
+ pax-mark -m utils/haddock/dist/build/tmp/haddock |
1862 |
+ fi |
1863 |
+ fi |
1864 |
+ # 3. and then all the rest |
1865 |
+ emake all |
1866 |
+ fi # ! use binary |
1867 |
+} |
1868 |
+ |
1869 |
+src_install() { |
1870 |
+ if use binary; then |
1871 |
+ use prefix && mkdir -p "${ED}" |
1872 |
+ mv "${S}/usr" "${ED}" |
1873 |
+ else |
1874 |
+ [[ -f VERSION ]] || emake VERSION |
1875 |
+ |
1876 |
+ # -j1 due to a rare race in install script: |
1877 |
+ # make --no-print-directory -f ghc.mk phase=final install |
1878 |
+ # /usr/lib/portage/python3.4/ebuild-helpers/xattr/install -c -m 755 \ |
1879 |
+ # -d "/tmp/portage-tmpdir/portage/cross-armv7a-unknown-linux-gnueabi/ghc-9999/image/usr/lib64/armv7a-unknown-linux-gnueabi-ghc-8.3.20170404/include" |
1880 |
+ # /usr/lib/portage/python3.4/ebuild-helpers/xattr/install -c -m 644 utils/hsc2hs/template-hsc.h \ |
1881 |
+ # "/tmp/portage-tmpdir/portage/cross-armv7a-unknown-linux-gnueabi/ghc-9999/image/usr/lib64/armv7a-unknown-linux-gnueabi-ghc-8.3.20170404" |
1882 |
+ # /usr/bin/install: cannot create regular file \ |
1883 |
+ # '/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 |
1884 |
+ emake -j1 install DESTDIR="${D}" |
1885 |
+ |
1886 |
+ # Skip for cross-targets as they all share target location: |
1887 |
+ # /usr/share/doc/ghc-9999/ |
1888 |
+ if ! is_crosscompile; then |
1889 |
+ dodoc "distrib/README" "ANNOUNCE" "LICENSE" "VERSION" |
1890 |
+ fi |
1891 |
+ |
1892 |
+ # rename ghc-shipped files to avoid collision |
1893 |
+ # of external packages. Motivating example: |
1894 |
+ # user had installed: |
1895 |
+ # dev-lang/ghc-7.8.4-r0 (with transformers-0.3.0.0) |
1896 |
+ # dev-haskell/transformers-0.4.2.0 |
1897 |
+ # then user tried to update to |
1898 |
+ # dev-lang/ghc-7.8.4-r1 (with transformers-0.4.2.0) |
1899 |
+ # this will lead to single .conf file collision. |
1900 |
+ local shipped_conf renamed_conf |
1901 |
+ local package_confdir="${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d" |
1902 |
+ for shipped_conf in "${package_confdir}"/*.conf; do |
1903 |
+ # rename 'pkg-ver-id.conf' to 'pkg-ver-id-gentoo-${PF}.conf' |
1904 |
+ renamed_conf=${shipped_conf%.conf}-gentoo-${PF}.conf |
1905 |
+ mv "${shipped_conf}" "${renamed_conf}" || die |
1906 |
+ done |
1907 |
+ |
1908 |
+ # remove link, but leave 'haddock-${GHC_P}' |
1909 |
+ rm -f "${ED}"/usr/bin/$(cross)haddock |
1910 |
+ |
1911 |
+ if ! is_crosscompile; then |
1912 |
+ newbashcomp "${FILESDIR}"/ghc-bash-completion ghc-pkg |
1913 |
+ newbashcomp utils/completion/ghc.bash ghc |
1914 |
+ fi |
1915 |
+ fi |
1916 |
+ |
1917 |
+ # path to the package.cache |
1918 |
+ local package_confdir="${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d" |
1919 |
+ PKGCACHE="${package_confdir}"/package.cache |
1920 |
+ # copy the package.conf.d, including timestamp, save it so we can help |
1921 |
+ # users that have a broken package.conf.d |
1922 |
+ cp -pR "${package_confdir}"{,.initial} || die "failed to backup intial package.conf.d" |
1923 |
+ |
1924 |
+ # copy the package.conf, including timestamp, save it so we later can put it |
1925 |
+ # back before uninstalling, or when upgrading. |
1926 |
+ cp -p "${PKGCACHE}"{,.shipped} \ |
1927 |
+ || die "failed to copy package.conf.d/package.cache" |
1928 |
+} |
1929 |
+ |
1930 |
+pkg_preinst() { |
1931 |
+ # have we got an earlier version of ghc installed? |
1932 |
+ if has_version "<${CATEGORY}/${PF}"; then |
1933 |
+ haskell_updater_warn="1" |
1934 |
+ fi |
1935 |
+} |
1936 |
+ |
1937 |
+pkg_postinst() { |
1938 |
+ ghc-reregister |
1939 |
+ |
1940 |
+ # path to the package.cache |
1941 |
+ PKGCACHE="${EROOT}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d/package.cache" |
1942 |
+ |
1943 |
+ # give the cache a new timestamp, it must be as recent as |
1944 |
+ # the package.conf.d directory. |
1945 |
+ touch "${PKGCACHE}" |
1946 |
+ |
1947 |
+ if [[ "${haskell_updater_warn}" == "1" ]]; then |
1948 |
+ ewarn |
1949 |
+ ewarn "\e[1;31m************************************************************************\e[0m" |
1950 |
+ ewarn |
1951 |
+ ewarn "You have just upgraded from an older version of GHC." |
1952 |
+ ewarn "You may have to run" |
1953 |
+ ewarn " 'haskell-updater'" |
1954 |
+ ewarn "to rebuild all ghc-based Haskell libraries." |
1955 |
+ ewarn |
1956 |
+ ewarn "\e[1;31m************************************************************************\e[0m" |
1957 |
+ ewarn |
1958 |
+ fi |
1959 |
+} |
1960 |
+ |
1961 |
+pkg_prerm() { |
1962 |
+ PKGCACHE="${EROOT}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d/package.cache" |
1963 |
+ rm -rf "${PKGCACHE}" |
1964 |
+ |
1965 |
+ cp -p "${PKGCACHE}"{.shipped,} |
1966 |
+} |
1967 |
+ |
1968 |
+pkg_postrm() { |
1969 |
+ ghc-package_pkg_postrm |
1970 |
+} |