Gentoo Archives: gentoo-commits

From: "Sergei Trofimovich (slyfox)" <slyfox@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in dev-lang/ghc/files: ghc-7.8.3-cc-lang.patch ghc-7.8.3-pic-asm.patch ghc-7.8.3-ia64-prim.patch ghc-7.8.3-pic-sparc.patch ghc-7.8.3-prim-lm.patch ghc-7.8.3-deRefStablePtr.patch ghc-7.8.3-linker-warn.patch ghc-7.8.2-ia64-no-shared.patch
Date: Thu, 04 Sep 2014 20:30:48
Message-Id: 20140904203042.770B14B9B@oystercatcher.gentoo.org
1 slyfox 14/09/04 20:30:42
2
3 Modified: ghc-7.8.3-prim-lm.patch
4 Added: ghc-7.8.3-cc-lang.patch ghc-7.8.3-pic-asm.patch
5 ghc-7.8.3-ia64-prim.patch ghc-7.8.3-pic-sparc.patch
6 ghc-7.8.3-deRefStablePtr.patch
7 ghc-7.8.3-linker-warn.patch
8 Removed: ghc-7.8.2-ia64-no-shared.patch
9 Log:
10 A bunch of UNREG backports (fixes sparc dynamic libraries, ia64 gmp support).
11
12 (Portage version: 2.2.12_p12/cvs/Linux x86_64, signed Manifest commit with key 611FF3AA)
13
14 Revision Changes Path
15 1.2 dev-lang/ghc/files/ghc-7.8.3-prim-lm.patch
16
17 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-lang/ghc/files/ghc-7.8.3-prim-lm.patch?rev=1.2&view=markup
18 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-lang/ghc/files/ghc-7.8.3-prim-lm.patch?rev=1.2&content-type=text/plain
19 diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-lang/ghc/files/ghc-7.8.3-prim-lm.patch?r1=1.1&r2=1.2
20
21 Index: ghc-7.8.3-prim-lm.patch
22 ===================================================================
23 RCS file: /var/cvsroot/gentoo-x86/dev-lang/ghc/files/ghc-7.8.3-prim-lm.patch,v
24 retrieving revision 1.1
25 retrieving revision 1.2
26 diff -u -r1.1 -r1.2
27 --- ghc-7.8.3-prim-lm.patch 30 Jul 2014 11:47:32 -0000 1.1
28 +++ ghc-7.8.3-prim-lm.patch 4 Sep 2014 20:30:42 -0000 1.2
29 @@ -5,10 +5,7 @@
30 index ffb32af..0431380 100644
31 --- a/libraries/ghc-prim/ghc-prim.cabal
32 +++ b/libraries/ghc-prim/ghc-prim.cabal
33 -@@ -65,3 +65,7 @@ Library
34 - -- We need to set the package name to ghc-prim (without a version number)
35 - -- as it's magic.
36 - ghc-options: -package-name ghc-prim
37 +@@ -68,0 +68,4 @@ Library
38 +
39 + -- ghc 'sin' (and other) primops generate 'libm' calls,
40 + -- but ghc itself does not add '-lm'
41
42
43
44 1.1 dev-lang/ghc/files/ghc-7.8.3-cc-lang.patch
45
46 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-lang/ghc/files/ghc-7.8.3-cc-lang.patch?rev=1.1&view=markup
47 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-lang/ghc/files/ghc-7.8.3-cc-lang.patch?rev=1.1&content-type=text/plain
48
49 Index: ghc-7.8.3-cc-lang.patch
50 ===================================================================
51 commit 4d4d07704ee78221607a18b8118294b0aea1bac4
52 Author: Sergei Trofimovich <slyfox@g.o>
53 Date: Tue Sep 2 00:06:56 2014 +0300
54
55 systools: fix gcc version detecton on non-english locale
56
57 Summary:
58 ghc runs 'gcc -v' to check if we run under vanilla gcc
59 or disaguised clang by checking for string
60
61 "gcc version <something>"
62
63 But this check does not always work as gcc has that string
64 localized via gettext mechanism:
65
66 (some gcc's locale strings)
67 be.po-msgstr "версія gcc %s\n"
68 da.po-msgstr "GCC version %s\n"
69 de.po-msgstr "gcc-Version %s %s\n"
70 el.po-msgstr "έκδοση gcc %s\n"
71 ...
72
73 To ping gcc to English locale we now override environment
74 variable with 'LANGUAGE=en' value.
75
76 Fixes Issue #8825
77
78 Signed-off-by: Sergei Trofimovich <slyfox@g.o>
79
80 Test Plan: validate
81
82 Reviewers: austin
83
84 Reviewed By: austin
85
86 Subscribers: simonmar, ezyang, carter
87
88 Differential Revision: https://phabricator.haskell.org/D185
89
90 GHC Trac Issues: #8825
91
92 diff --git a/compiler/main/SysTools.lhs b/compiler/main/SysTools.lhs
93 index 72fa19b..67926f5 100644
94 --- a/compiler/main/SysTools.lhs
95 +++ b/compiler/main/SysTools.lhs
96 @@ -492,6 +492,51 @@ readCreateProcess proc = do
97
98 return (ex, output)
99
100 +readProcessEnvWithExitCode
101 + :: String -- ^ program path
102 + -> [String] -- ^ program args
103 + -> [(String, String)] -- ^ environment to override
104 + -> IO (ExitCode, String, String) -- ^ (exit_code, stdout, stderr)
105 +readProcessEnvWithExitCode prog args env_update = do
106 + current_env <- getEnvironment
107 + let new_env = env_update ++ [ (k, v)
108 + | let overriden_keys = map fst env_update
109 + , (k, v) <- current_env
110 + , k `notElem` overriden_keys
111 + ]
112 + p = proc prog args
113 +
114 + (_stdin, Just stdoh, Just stdeh, pid) <-
115 + createProcess p{ std_out = CreatePipe
116 + , std_err = CreatePipe
117 + , env = Just new_env
118 + }
119 +
120 + outMVar <- newEmptyMVar
121 + errMVar <- newEmptyMVar
122 +
123 + _ <- forkIO $ do
124 + stdo <- hGetContents stdoh
125 + _ <- evaluate (length stdo)
126 + putMVar outMVar stdo
127 +
128 + _ <- forkIO $ do
129 + stde <- hGetContents stdeh
130 + _ <- evaluate (length stde)
131 + putMVar errMVar stde
132 +
133 + out <- takeMVar outMVar
134 + hClose stdoh
135 + err <- takeMVar errMVar
136 + hClose stdeh
137 +
138 + ex <- waitForProcess pid
139 +
140 + return (ex, out, err)
141 +
142 +-- Don't let gcc localize version info string, #8825
143 +en_locale_env :: [(String, String)]
144 +en_locale_env = [("LANGUAGE", "en")]
145
146 -- If the -B<dir> option is set, add <dir> to PATH. This works around
147 -- a bug in gcc on Windows Vista where it can't find its auxiliary
148 @@ -746,8 +791,9 @@ getLinkerInfo' dflags = do
149 _ -> do
150 -- In practice, we use the compiler as the linker here. Pass
151 -- -Wl,--version to get linker version info.
152 - (exitc, stdo, stde) <- readProcessWithExitCode pgm
153 - ["-Wl,--version"] ""
154 + (exitc, stdo, stde) <- readProcessEnvWithExitCode pgm
155 + ["-Wl,--version"]
156 + en_locale_env
157 -- Split the output by lines to make certain kinds
158 -- of processing easier. In particular, 'clang' and 'gcc'
159 -- have slightly different outputs for '-Wl,--version', but
160 @@ -802,7 +848,8 @@ getCompilerInfo' dflags = do
161
162 -- Process the executable call
163 info <- catchIO (do
164 - (exitc, stdo, stde) <- readProcessWithExitCode pgm ["-v"] ""
165 + (exitc, stdo, stde) <-
166 + readProcessEnvWithExitCode pgm ["-v"] en_locale_env
167 -- Split the output by lines to make certain kinds
168 -- of processing easier.
169 parseCompilerInfo (lines stdo) (lines stde) exitc
170 @@ -952,7 +999,8 @@ readElfSection _dflags section exe = do
171 prog = "readelf"
172 args = [Option "-p", Option section, FileOption "" exe]
173 --
174 - r <- readProcessWithExitCode prog (filter notNull (map showOpt args)) ""
175 + r <- readProcessEnvWithExitCode prog (filter notNull (map showOpt args))
176 + en_locale_env
177 case r of
178 (ExitSuccess, out, _err) -> return (doFilter (lines out))
179 _ -> return Nothing
180
181
182
183 1.1 dev-lang/ghc/files/ghc-7.8.3-pic-asm.patch
184
185 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-lang/ghc/files/ghc-7.8.3-pic-asm.patch?rev=1.1&view=markup
186 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-lang/ghc/files/ghc-7.8.3-pic-asm.patch?rev=1.1&content-type=text/plain
187
188 Index: ghc-7.8.3-pic-asm.patch
189 ===================================================================
190 commit a93ab43ab5f40cadbedea2f6342b93c245e91434
191 Author: Sergei Trofimovich <slyfox@g.o>
192 Date: Wed Aug 27 22:19:52 2014 +0300
193
194 driver: pass '-fPIC' option to assembler as well
195
196 Summary:
197 Before the patch '-fPIC' was passed only to C compiler,
198 but not to assembler itself.
199
200 It led to runtime crash in GHC_DYNAMIC_PROGRAMS=YES mode
201 on sparc32.
202
203 Technical details are in 'Note [-fPIC for assembler]'.
204
205 Signed-off-by: Sergei Trofimovich <slyfox@g.o>
206
207 Test Plan: validate on sparc
208
209 Reviewers: simonmar, austin, kgardas
210
211 Reviewed By: austin
212
213 Subscribers: simonmar, ezyang, carter
214
215 Differential Revision: https://phabricator.haskell.org/D177
216
217 diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs
218 index 183f435..5a18e6e 100644
219 --- a/compiler/main/DriverPipeline.hs
220 +++ b/compiler/main/DriverPipeline.hs
221 @@ -1199,6 +1199,7 @@ runPhase (RealPhase (As with_cpp)) input_fn dflags
222
223 as_prog <- whichAsProg
224 let cmdline_include_paths = includePaths dflags
225 + let pic_c_flags = picCCOpts dflags
226
227 next_phase <- maybeMergeStub
228 output_fn <- phaseOutputFilename next_phase
229 @@ -1212,6 +1213,9 @@ runPhase (RealPhase (As with_cpp)) input_fn dflags
230 = liftIO $ as_prog dflags
231 ([ SysTools.Option ("-I" ++ p) | p <- cmdline_include_paths ]
232
233 + -- See Note [-fPIC for assembler]
234 + ++ map SysTools.Option pic_c_flags
235 +
236 -- We only support SparcV9 and better because V8 lacks an atomic CAS
237 -- instruction so we have to make sure that the assembler accepts the
238 -- instruction set. Note that the user can still override this
239 @@ -1253,6 +1257,8 @@ runPhase (RealPhase SplitAs) _input_fn dflags
240 osuf = objectSuf dflags
241 split_odir = base_o ++ "_" ++ osuf ++ "_split"
242
243 + let pic_c_flags = picCCOpts dflags
244 +
245 -- this also creates the hierarchy
246 liftIO $ createDirectoryIfMissing True split_odir
247
248 @@ -1286,6 +1292,9 @@ runPhase (RealPhase SplitAs) _input_fn dflags
249 then [SysTools.Option "-mcpu=v9"]
250 else []) ++
251
252 + -- See Note [-fPIC for assembler]
253 + map SysTools.Option pic_c_flags ++
254 +
255 [ SysTools.Option "-c"
256 , SysTools.Option "-o"
257 , SysTools.FileOption "" (split_obj n)
258 @@ -2203,3 +2212,38 @@ haveRtsOptsFlags dflags =
259 isJust (rtsOpts dflags) || case rtsOptsEnabled dflags of
260 RtsOptsSafeOnly -> False
261 _ -> True
262 +
263 +-- Note [-fPIC for assembler]
264 +-- When compiling .c source file GHC's driver pipeline basically
265 +-- does the following two things:
266 +-- 1. ${CC} -S 'PIC_CFLAGS' source.c
267 +-- 2. ${CC} -x assembler -c 'PIC_CFLAGS' source.S
268 +--
269 +-- Why do we need to pass 'PIC_CFLAGS' both to C compiler and assembler?
270 +-- Because on some architectures (at least sparc32) assembler also choses
271 +-- relocation type!
272 +-- Consider the following C module:
273 +--
274 +-- /* pic-sample.c */
275 +-- int v;
276 +-- void set_v (int n) { v = n; }
277 +-- int get_v (void) { return v; }
278 +--
279 +-- $ gcc -S -fPIC pic-sample.c
280 +-- $ gcc -c pic-sample.s -o pic-sample.no-pic.o # incorrect binary
281 +-- $ gcc -c -fPIC pic-sample.s -o pic-sample.pic.o # correct binary
282 +--
283 +-- $ objdump -r -d pic-sample.pic.o > pic-sample.pic.o.od
284 +-- $ objdump -r -d pic-sample.no-pic.o > pic-sample.no-pic.o.od
285 +-- $ diff -u pic-sample.pic.o.od pic-sample.no-pic.o.od
286 +--
287 +-- Most of architectures won't show any difference in this test, but on sparc32
288 +-- the following assembly snippet:
289 +--
290 +-- sethi %hi(_GLOBAL_OFFSET_TABLE_-8), %l7
291 +--
292 +-- generates two kinds or relocations, only 'R_SPARC_PC22' is correct:
293 +--
294 +-- 3c: 2f 00 00 00 sethi %hi(0), %l7
295 +-- - 3c: R_SPARC_PC22 _GLOBAL_OFFSET_TABLE_-0x8
296 +-- + 3c: R_SPARC_HI22 _GLOBAL_OFFSET_TABLE_-0x8
297
298
299
300 1.1 dev-lang/ghc/files/ghc-7.8.3-ia64-prim.patch
301
302 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-lang/ghc/files/ghc-7.8.3-ia64-prim.patch?rev=1.1&view=markup
303 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-lang/ghc/files/ghc-7.8.3-ia64-prim.patch?rev=1.1&content-type=text/plain
304
305 Index: ghc-7.8.3-ia64-prim.patch
306 ===================================================================
307 commit e2a8801b9779949010f30db6f6ef66f3c3a70776
308 Author: Sergei Trofimovich <slyfox@g.o>
309 Date: Thu Sep 4 17:50:45 2014 +0300
310
311 pprC: declare extern cmm primitives as functions, not data
312
313 Summary:
314 The commit fixes incorrect code generation of
315 integer-gmp package on ia64 due to C prototype mismatch.
316 Before patch prototype was
317 StgWord poizh[];
318 After patch it became
319 StgFunPtr poizh();
320
321 Long story:
322
323 Consider the following simple example:
324
325 {-# LANGUAGE MagicHash, GHCForeignImportPrim, UnliftedFFITypes #-}
326 module M where
327 import GHC.Prim -- Int#
328 foreign import prim "poizh" poi# :: Int# -> Int#
329
330 Before the patch Unregisterised build generated the
331 following 'poizh' reference:
332 EI_(poizh); /* StgWord poizh[]; */
333 FN_(M_poizh_entry) {
334 // ...
335 JMP_((W_)&poizh);
336 }
337
338 After the patch it looks this way:
339 EF_(poizh); /* StgFunPtr poizh(); */
340 FN_(M_poizh_entry) {
341 // ...
342 JMP_((W_)&poizh);
343 }
344
345 On ia64 it leads to different relocation types being generated:
346 incorrect one:
347 addl r14 = @ltoffx(poizh#)
348 ld8.mov r14 = [r14], poizh#
349 correct one:
350 addl r14 = @ltoff(@fptr(poizh#)), gp
351 ld8 r14 = [r14]
352
353 '@fptr(poizh#)' basically instructs assembler to creates
354 another obect consisting of real address to 'poizh' instructions
355 and module address. That '@fptr' object is used as a function "address".
356 This object is different for every module referencing 'poizh' symbol.
357
358 All indirect function calls expect '@fptr' object. That way
359 call site can read real destination address and set destination
360 module address in 'gp' register.
361
362 Signed-off-by: Sergei Trofimovich <slyfox@g.o>
363
364 diff --git a/compiler/cmm/CLabel.hs b/compiler/cmm/CLabel.hs
365 index 02ad026..0f2c0ae 100644
366 --- a/compiler/cmm/CLabel.hs
367 +++ b/compiler/cmm/CLabel.hs
368 @@ -813,6 +813,7 @@ labelType (CmmLabel _ _ CmmClosure) = GcPtrLabel
369 labelType (CmmLabel _ _ CmmCode) = CodeLabel
370 labelType (CmmLabel _ _ CmmInfo) = DataLabel
371 labelType (CmmLabel _ _ CmmEntry) = CodeLabel
372 +labelType (CmmLabel _ _ CmmPrimCall) = CodeLabel
373 labelType (CmmLabel _ _ CmmRetInfo) = DataLabel
374 labelType (CmmLabel _ _ CmmRet) = CodeLabel
375 labelType (RtsLabel (RtsSelectorInfoTable _ _)) = DataLabel
376
377
378
379 1.1 dev-lang/ghc/files/ghc-7.8.3-pic-sparc.patch
380
381 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-lang/ghc/files/ghc-7.8.3-pic-sparc.patch?rev=1.1&view=markup
382 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-lang/ghc/files/ghc-7.8.3-pic-sparc.patch?rev=1.1&content-type=text/plain
383
384 Index: ghc-7.8.3-pic-sparc.patch
385 ===================================================================
386 commit 78863edbb0751f5c9694ea10c6132a87cfd0ee10
387 Author: Sergei Trofimovich <slyfox@g.o>
388 Date: Wed Aug 27 22:20:33 2014 +0300
389
390 Revert "disable shared libs on sparc (linux/solaris) (fixes #8857)"
391
392 This reverts commit 623883f1ed0ee11cc925c4590fb09565403fd231.
393
394 The commit a93ab43ab5f40cadbedea2f6342b93c245e91434
395 driver: pass '-fPIC' option to assembler as well
396 fixes shared libraries on sparc at least on linux.
397
398 Properly fixes Issue #8857
399
400 Signed-off-by: Sergei Trofimovich <slyfox@g.o>
401
402 diff --git a/mk/config.mk.in b/mk/config.mk.in
403 index c210cd3..392237f 100644
404 --- a/mk/config.mk.in
405 +++ b/mk/config.mk.in
406 @@ -97,9 +97,7 @@ endif
407 # Some platforms don't support shared libraries
408 NoSharedLibsPlatformList = powerpc-unknown-linux \
409 x86_64-unknown-mingw32 \
410 - i386-unknown-mingw32 \
411 - sparc-sun-solaris2 \
412 - sparc-unknown-linux
413 + i386-unknown-mingw32
414
415 ifeq "$(SOLARIS_BROKEN_SHLD)" "YES"
416 NoSharedLibsPlatformList += i386-unknown-solaris2
417
418
419
420 1.1 dev-lang/ghc/files/ghc-7.8.3-deRefStablePtr.patch
421
422 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-lang/ghc/files/ghc-7.8.3-deRefStablePtr.patch?rev=1.1&view=markup
423 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-lang/ghc/files/ghc-7.8.3-deRefStablePtr.patch?rev=1.1&content-type=text/plain
424
425 Index: ghc-7.8.3-deRefStablePtr.patch
426 ===================================================================
427 commit 104a66a461f4f89b8e5ad9c829923bb7ca8ceddb
428 Author: Sergei Trofimovich <slyfox@g.o>
429 Date: Sat Aug 23 13:11:23 2014 +0300
430
431 rts/Linker.c: declare 'deRefStablePtr' as an exported 'rts' symbol
432
433 $ inplace/bin/ghc-stage2 -fforce-recomp -dcore-lint -dcmm-lint -dno-debug-output -no-user-package-db -rtsopts -optc-fno-builtin -fno-ghci-history \
434 testsuite/tests/ffi/should_run/T4038.hs --interactive -v0 -ignore-dot-ghci +RTS -I0.1 -RTS
435
436 *Main> main
437 <interactive>: /tmp/ghc16668_0/ghc16668_5.o: unknown symbol `deRefStablePtr'
438
439 The reference to 'deRefStablePtr' is generated by 'compiler/deSugar/DsForeign.lhs':
440 the_cfun
441 = case maybe_target of
442 Nothing -> text "(StgClosure*)deRefStablePtr(the_stableptr)"
443 Just hs_fn -> char '&' <> ppr hs_fn <> text "_closure"
444
445 Patch fixes all broken tests using 'import wrapper':
446 TEST="ffi013 ffi010 ffi011 ffi005 ffi020 ffi006 ffi019 fed001 T1679 T4038"
447
448 Tests manifested as broken only in DYNAMIC_GHC_PROGRAMS=NO builds,
449 where GHCi's custom linker is used instead of system's linker.
450
451 Signed-off-by: Sergei Trofimovich <slyfox@g.o>
452
453 diff --git a/rts/Linker.c b/rts/Linker.c
454 index e97580d..b24be58 100644
455 --- a/rts/Linker.c
456 +++ b/rts/Linker.c
457 @@ -1092,6 +1092,7 @@ typedef struct _RtsSymbolVal {
458 SymI_HasProto(__word_encodeFloat) \
459 SymI_HasProto(stg_atomicallyzh) \
460 SymI_HasProto(barf) \
461 + SymI_HasProto(deRefStablePtr) \
462 SymI_HasProto(debugBelch) \
463 SymI_HasProto(errorBelch) \
464 SymI_HasProto(sysErrorBelch) \
465
466
467
468 1.1 dev-lang/ghc/files/ghc-7.8.3-linker-warn.patch
469
470 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-lang/ghc/files/ghc-7.8.3-linker-warn.patch?rev=1.1&view=markup
471 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-lang/ghc/files/ghc-7.8.3-linker-warn.patch?rev=1.1&content-type=text/plain
472
473 Index: ghc-7.8.3-linker-warn.patch
474 ===================================================================
475 commit 326046739801a380c5457ef4c87bce8fb95497ba
476 Author: Sergei Trofimovich <slyfox@g.o>
477 Date: Sun Aug 10 22:12:28 2014 +0300
478
479 systools info: fix warning about C compiler (message said about linker)
480
481 Summary: Signed-off-by: Sergei Trofimovich <slyfox@g.o>
482
483 Test Plan: build-tested
484
485 Reviewers: austin
486
487 Reviewed By: austin
488
489 Subscribers: phaskell, simonmar, relrod, ezyang, carter
490
491 Differential Revision: https://phabricator.haskell.org/D132
492
493 diff --git a/compiler/main/SysTools.lhs b/compiler/main/SysTools.lhs
494 index 1c1c52c..72fa19b 100644
495 --- a/compiler/main/SysTools.lhs
496 +++ b/compiler/main/SysTools.lhs
497 @@ -809,10 +809,10 @@ getCompilerInfo' dflags = do
498 )
499 (\err -> do
500 debugTraceMsg dflags 2
501 - (text "Error (figuring out compiler information):" <+>
502 + (text "Error (figuring out C compiler information):" <+>
503 text (show err))
504 errorMsg dflags $ hang (text "Warning:") 9 $
505 - text "Couldn't figure out linker information!" $$
506 + text "Couldn't figure out C compiler information!" $$
507 text "Make sure you're using GNU gcc, or clang"
508 return UnknownCC)
509 return info