slyfox 14/09/04 20:30:42
Modified: ghc-7.8.3-prim-lm.patch
Added: 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-deRefStablePtr.patch
ghc-7.8.3-linker-warn.patch
Removed: ghc-7.8.2-ia64-no-shared.patch
Log:
A bunch of UNREG backports (fixes sparc dynamic libraries, ia64 gmp support).
(Portage version: 2.2.12_p12/cvs/Linux x86_64, signed Manifest commit with
key 611FF3AA)
Revision Changes Path
1.2 dev-lang/ghc/files/ghc-7.8.3-prim-lm.patch
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
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
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
Index: ghc-7.8.3-prim-lm.patch
===================================================================
RCS file: /var/cvsroot/gentoo-x86/dev-lang/ghc/files/ghc-7.8.3-prim-lm.patch,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ghc-7.8.3-prim-lm.patch 30 Jul 2014 11:47:32 -0000 1.1
+++ ghc-7.8.3-prim-lm.patch 4 Sep 2014 20:30:42 -0000 1.2
@@ -5,10 +5,7 @@
index ffb32af..0431380 100644
--- a/libraries/ghc-prim/ghc-prim.cabal
+++ b/libraries/ghc-prim/ghc-prim.cabal
-@@ -65,3 +65,7 @@ Library
- -- We need to set the package name to ghc-prim (without a version number)
- -- as it's magic.
- ghc-options: -package-name ghc-prim
+@@ -68,0 +68,4 @@ Library
+
+ -- ghc 'sin' (and other) primops generate 'libm' calls,
+ -- but ghc itself does not add '-lm'
1.1 dev-lang/ghc/files/ghc-7.8.3-cc-lang.patch
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
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
Index: ghc-7.8.3-cc-lang.patch
===================================================================
commit 4d4d07704ee78221607a18b8118294b0aea1bac4
Author: Sergei Trofimovich <[email protected]>
Date: Tue Sep 2 00:06:56 2014 +0300
systools: fix gcc version detecton on non-english locale
Summary:
ghc runs 'gcc -v' to check if we run under vanilla gcc
or disaguised clang by checking for string
"gcc version <something>"
But this check does not always work as gcc has that string
localized via gettext mechanism:
(some gcc's locale strings)
be.po-msgstr "версія gcc %s\n"
da.po-msgstr "GCC version %s\n"
de.po-msgstr "gcc-Version %s %s\n"
el.po-msgstr "έκδοση gcc %s\n"
...
To ping gcc to English locale we now override environment
variable with 'LANGUAGE=en' value.
Fixes Issue #8825
Signed-off-by: Sergei Trofimovich <[email protected]>
Test Plan: validate
Reviewers: austin
Reviewed By: austin
Subscribers: simonmar, ezyang, carter
Differential Revision: https://phabricator.haskell.org/D185
GHC Trac Issues: #8825
diff --git a/compiler/main/SysTools.lhs b/compiler/main/SysTools.lhs
index 72fa19b..67926f5 100644
--- a/compiler/main/SysTools.lhs
+++ b/compiler/main/SysTools.lhs
@@ -492,6 +492,51 @@ readCreateProcess proc = do
return (ex, output)
+readProcessEnvWithExitCode
+ :: String -- ^ program path
+ -> [String] -- ^ program args
+ -> [(String, String)] -- ^ environment to override
+ -> IO (ExitCode, String, String) -- ^ (exit_code, stdout, stderr)
+readProcessEnvWithExitCode prog args env_update = do
+ current_env <- getEnvironment
+ let new_env = env_update ++ [ (k, v)
+ | let overriden_keys = map fst env_update
+ , (k, v) <- current_env
+ , k `notElem` overriden_keys
+ ]
+ p = proc prog args
+
+ (_stdin, Just stdoh, Just stdeh, pid) <-
+ createProcess p{ std_out = CreatePipe
+ , std_err = CreatePipe
+ , env = Just new_env
+ }
+
+ outMVar <- newEmptyMVar
+ errMVar <- newEmptyMVar
+
+ _ <- forkIO $ do
+ stdo <- hGetContents stdoh
+ _ <- evaluate (length stdo)
+ putMVar outMVar stdo
+
+ _ <- forkIO $ do
+ stde <- hGetContents stdeh
+ _ <- evaluate (length stde)
+ putMVar errMVar stde
+
+ out <- takeMVar outMVar
+ hClose stdoh
+ err <- takeMVar errMVar
+ hClose stdeh
+
+ ex <- waitForProcess pid
+
+ return (ex, out, err)
+
+-- Don't let gcc localize version info string, #8825
+en_locale_env :: [(String, String)]
+en_locale_env = [("LANGUAGE", "en")]
-- If the -B<dir> option is set, add <dir> to PATH. This works around
-- a bug in gcc on Windows Vista where it can't find its auxiliary
@@ -746,8 +791,9 @@ getLinkerInfo' dflags = do
_ -> do
-- In practice, we use the compiler as the linker here. Pass
-- -Wl,--version to get linker version info.
- (exitc, stdo, stde) <- readProcessWithExitCode pgm
- ["-Wl,--version"] ""
+ (exitc, stdo, stde) <- readProcessEnvWithExitCode pgm
+ ["-Wl,--version"]
+ en_locale_env
-- Split the output by lines to make certain kinds
-- of processing easier. In particular, 'clang' and 'gcc'
-- have slightly different outputs for '-Wl,--version', but
@@ -802,7 +848,8 @@ getCompilerInfo' dflags = do
-- Process the executable call
info <- catchIO (do
- (exitc, stdo, stde) <- readProcessWithExitCode pgm ["-v"] ""
+ (exitc, stdo, stde) <-
+ readProcessEnvWithExitCode pgm ["-v"] en_locale_env
-- Split the output by lines to make certain kinds
-- of processing easier.
parseCompilerInfo (lines stdo) (lines stde) exitc
@@ -952,7 +999,8 @@ readElfSection _dflags section exe = do
prog = "readelf"
args = [Option "-p", Option section, FileOption "" exe]
--
- r <- readProcessWithExitCode prog (filter notNull (map showOpt args)) ""
+ r <- readProcessEnvWithExitCode prog (filter notNull (map showOpt args))
+ en_locale_env
case r of
(ExitSuccess, out, _err) -> return (doFilter (lines out))
_ -> return Nothing
1.1 dev-lang/ghc/files/ghc-7.8.3-pic-asm.patch
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
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
Index: ghc-7.8.3-pic-asm.patch
===================================================================
commit a93ab43ab5f40cadbedea2f6342b93c245e91434
Author: Sergei Trofimovich <[email protected]>
Date: Wed Aug 27 22:19:52 2014 +0300
driver: pass '-fPIC' option to assembler as well
Summary:
Before the patch '-fPIC' was passed only to C compiler,
but not to assembler itself.
It led to runtime crash in GHC_DYNAMIC_PROGRAMS=YES mode
on sparc32.
Technical details are in 'Note [-fPIC for assembler]'.
Signed-off-by: Sergei Trofimovich <[email protected]>
Test Plan: validate on sparc
Reviewers: simonmar, austin, kgardas
Reviewed By: austin
Subscribers: simonmar, ezyang, carter
Differential Revision: https://phabricator.haskell.org/D177
diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs
index 183f435..5a18e6e 100644
--- a/compiler/main/DriverPipeline.hs
+++ b/compiler/main/DriverPipeline.hs
@@ -1199,6 +1199,7 @@ runPhase (RealPhase (As with_cpp)) input_fn dflags
as_prog <- whichAsProg
let cmdline_include_paths = includePaths dflags
+ let pic_c_flags = picCCOpts dflags
next_phase <- maybeMergeStub
output_fn <- phaseOutputFilename next_phase
@@ -1212,6 +1213,9 @@ runPhase (RealPhase (As with_cpp)) input_fn dflags
= liftIO $ as_prog dflags
([ SysTools.Option ("-I" ++ p) | p <-
cmdline_include_paths ]
+ -- See Note [-fPIC for assembler]
+ ++ map SysTools.Option pic_c_flags
+
-- We only support SparcV9 and better because V8 lacks an atomic CAS
-- instruction so we have to make sure that the assembler accepts the
-- instruction set. Note that the user can still override this
@@ -1253,6 +1257,8 @@ runPhase (RealPhase SplitAs) _input_fn dflags
osuf = objectSuf dflags
split_odir = base_o ++ "_" ++ osuf ++ "_split"
+ let pic_c_flags = picCCOpts dflags
+
-- this also creates the hierarchy
liftIO $ createDirectoryIfMissing True split_odir
@@ -1286,6 +1292,9 @@ runPhase (RealPhase SplitAs) _input_fn dflags
then [SysTools.Option "-mcpu=v9"]
else []) ++
+ -- See Note [-fPIC for assembler]
+ map SysTools.Option pic_c_flags ++
+
[ SysTools.Option "-c"
, SysTools.Option "-o"
, SysTools.FileOption "" (split_obj n)
@@ -2203,3 +2212,38 @@ haveRtsOptsFlags dflags =
isJust (rtsOpts dflags) || case rtsOptsEnabled dflags of
RtsOptsSafeOnly -> False
_ -> True
+
+-- Note [-fPIC for assembler]
+-- When compiling .c source file GHC's driver pipeline basically
+-- does the following two things:
+-- 1. ${CC} -S 'PIC_CFLAGS' source.c
+-- 2. ${CC} -x assembler -c 'PIC_CFLAGS' source.S
+--
+-- Why do we need to pass 'PIC_CFLAGS' both to C compiler and assembler?
+-- Because on some architectures (at least sparc32) assembler also choses
+-- relocation type!
+-- Consider the following C module:
+--
+-- /* pic-sample.c */
+-- int v;
+-- void set_v (int n) { v = n; }
+-- int get_v (void) { return v; }
+--
+-- $ gcc -S -fPIC pic-sample.c
+-- $ gcc -c pic-sample.s -o pic-sample.no-pic.o # incorrect binary
+-- $ gcc -c -fPIC pic-sample.s -o pic-sample.pic.o # correct binary
+--
+-- $ objdump -r -d pic-sample.pic.o > pic-sample.pic.o.od
+-- $ objdump -r -d pic-sample.no-pic.o > pic-sample.no-pic.o.od
+-- $ diff -u pic-sample.pic.o.od pic-sample.no-pic.o.od
+--
+-- Most of architectures won't show any difference in this test, but on sparc32
+-- the following assembly snippet:
+--
+-- sethi %hi(_GLOBAL_OFFSET_TABLE_-8), %l7
+--
+-- generates two kinds or relocations, only 'R_SPARC_PC22' is correct:
+--
+-- 3c: 2f 00 00 00 sethi %hi(0), %l7
+-- - 3c: R_SPARC_PC22 _GLOBAL_OFFSET_TABLE_-0x8
+-- + 3c: R_SPARC_HI22 _GLOBAL_OFFSET_TABLE_-0x8
1.1 dev-lang/ghc/files/ghc-7.8.3-ia64-prim.patch
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
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
Index: ghc-7.8.3-ia64-prim.patch
===================================================================
commit e2a8801b9779949010f30db6f6ef66f3c3a70776
Author: Sergei Trofimovich <[email protected]>
Date: Thu Sep 4 17:50:45 2014 +0300
pprC: declare extern cmm primitives as functions, not data
Summary:
The commit fixes incorrect code generation of
integer-gmp package on ia64 due to C prototype mismatch.
Before patch prototype was
StgWord poizh[];
After patch it became
StgFunPtr poizh();
Long story:
Consider the following simple example:
{-# LANGUAGE MagicHash, GHCForeignImportPrim, UnliftedFFITypes #-}
module M where
import GHC.Prim -- Int#
foreign import prim "poizh" poi# :: Int# -> Int#
Before the patch Unregisterised build generated the
following 'poizh' reference:
EI_(poizh); /* StgWord poizh[]; */
FN_(M_poizh_entry) {
// ...
JMP_((W_)&poizh);
}
After the patch it looks this way:
EF_(poizh); /* StgFunPtr poizh(); */
FN_(M_poizh_entry) {
// ...
JMP_((W_)&poizh);
}
On ia64 it leads to different relocation types being generated:
incorrect one:
addl r14 = @ltoffx(poizh#)
ld8.mov r14 = [r14], poizh#
correct one:
addl r14 = @ltoff(@fptr(poizh#)), gp
ld8 r14 = [r14]
'@fptr(poizh#)' basically instructs assembler to creates
another obect consisting of real address to 'poizh' instructions
and module address. That '@fptr' object is used as a function "address".
This object is different for every module referencing 'poizh' symbol.
All indirect function calls expect '@fptr' object. That way
call site can read real destination address and set destination
module address in 'gp' register.
Signed-off-by: Sergei Trofimovich <[email protected]>
diff --git a/compiler/cmm/CLabel.hs b/compiler/cmm/CLabel.hs
index 02ad026..0f2c0ae 100644
--- a/compiler/cmm/CLabel.hs
+++ b/compiler/cmm/CLabel.hs
@@ -813,6 +813,7 @@ labelType (CmmLabel _ _ CmmClosure) = GcPtrLabel
labelType (CmmLabel _ _ CmmCode) = CodeLabel
labelType (CmmLabel _ _ CmmInfo) = DataLabel
labelType (CmmLabel _ _ CmmEntry) = CodeLabel
+labelType (CmmLabel _ _ CmmPrimCall) = CodeLabel
labelType (CmmLabel _ _ CmmRetInfo) = DataLabel
labelType (CmmLabel _ _ CmmRet) = CodeLabel
labelType (RtsLabel (RtsSelectorInfoTable _ _)) = DataLabel
1.1 dev-lang/ghc/files/ghc-7.8.3-pic-sparc.patch
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
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
Index: ghc-7.8.3-pic-sparc.patch
===================================================================
commit 78863edbb0751f5c9694ea10c6132a87cfd0ee10
Author: Sergei Trofimovich <[email protected]>
Date: Wed Aug 27 22:20:33 2014 +0300
Revert "disable shared libs on sparc (linux/solaris) (fixes #8857)"
This reverts commit 623883f1ed0ee11cc925c4590fb09565403fd231.
The commit a93ab43ab5f40cadbedea2f6342b93c245e91434
driver: pass '-fPIC' option to assembler as well
fixes shared libraries on sparc at least on linux.
Properly fixes Issue #8857
Signed-off-by: Sergei Trofimovich <[email protected]>
diff --git a/mk/config.mk.in b/mk/config.mk.in
index c210cd3..392237f 100644
--- a/mk/config.mk.in
+++ b/mk/config.mk.in
@@ -97,9 +97,7 @@ endif
# Some platforms don't support shared libraries
NoSharedLibsPlatformList = powerpc-unknown-linux \
x86_64-unknown-mingw32 \
- i386-unknown-mingw32 \
- sparc-sun-solaris2 \
- sparc-unknown-linux
+ i386-unknown-mingw32
ifeq "$(SOLARIS_BROKEN_SHLD)" "YES"
NoSharedLibsPlatformList += i386-unknown-solaris2
1.1 dev-lang/ghc/files/ghc-7.8.3-deRefStablePtr.patch
file :
http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-lang/ghc/files/ghc-7.8.3-deRefStablePtr.patch?rev=1.1&view=markup
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
Index: ghc-7.8.3-deRefStablePtr.patch
===================================================================
commit 104a66a461f4f89b8e5ad9c829923bb7ca8ceddb
Author: Sergei Trofimovich <[email protected]>
Date: Sat Aug 23 13:11:23 2014 +0300
rts/Linker.c: declare 'deRefStablePtr' as an exported 'rts' symbol
$ inplace/bin/ghc-stage2 -fforce-recomp -dcore-lint -dcmm-lint
-dno-debug-output -no-user-package-db -rtsopts -optc-fno-builtin
-fno-ghci-history \
testsuite/tests/ffi/should_run/T4038.hs --interactive -v0
-ignore-dot-ghci +RTS -I0.1 -RTS
*Main> main
<interactive>: /tmp/ghc16668_0/ghc16668_5.o: unknown symbol
`deRefStablePtr'
The reference to 'deRefStablePtr' is generated by
'compiler/deSugar/DsForeign.lhs':
the_cfun
= case maybe_target of
Nothing -> text "(StgClosure*)deRefStablePtr(the_stableptr)"
Just hs_fn -> char '&' <> ppr hs_fn <> text "_closure"
Patch fixes all broken tests using 'import wrapper':
TEST="ffi013 ffi010 ffi011 ffi005 ffi020 ffi006 ffi019 fed001 T1679
T4038"
Tests manifested as broken only in DYNAMIC_GHC_PROGRAMS=NO builds,
where GHCi's custom linker is used instead of system's linker.
Signed-off-by: Sergei Trofimovich <[email protected]>
diff --git a/rts/Linker.c b/rts/Linker.c
index e97580d..b24be58 100644
--- a/rts/Linker.c
+++ b/rts/Linker.c
@@ -1092,6 +1092,7 @@ typedef struct _RtsSymbolVal {
SymI_HasProto(__word_encodeFloat) \
SymI_HasProto(stg_atomicallyzh) \
SymI_HasProto(barf) \
+ SymI_HasProto(deRefStablePtr) \
SymI_HasProto(debugBelch) \
SymI_HasProto(errorBelch) \
SymI_HasProto(sysErrorBelch) \
1.1 dev-lang/ghc/files/ghc-7.8.3-linker-warn.patch
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
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
Index: ghc-7.8.3-linker-warn.patch
===================================================================
commit 326046739801a380c5457ef4c87bce8fb95497ba
Author: Sergei Trofimovich <[email protected]>
Date: Sun Aug 10 22:12:28 2014 +0300
systools info: fix warning about C compiler (message said about linker)
Summary: Signed-off-by: Sergei Trofimovich <[email protected]>
Test Plan: build-tested
Reviewers: austin
Reviewed By: austin
Subscribers: phaskell, simonmar, relrod, ezyang, carter
Differential Revision: https://phabricator.haskell.org/D132
diff --git a/compiler/main/SysTools.lhs b/compiler/main/SysTools.lhs
index 1c1c52c..72fa19b 100644
--- a/compiler/main/SysTools.lhs
+++ b/compiler/main/SysTools.lhs
@@ -809,10 +809,10 @@ getCompilerInfo' dflags = do
)
(\err -> do
debugTraceMsg dflags 2
- (text "Error (figuring out compiler information):" <+>
+ (text "Error (figuring out C compiler information):" <+>
text (show err))
errorMsg dflags $ hang (text "Warning:") 9 $
- text "Couldn't figure out linker information!" $$
+ text "Couldn't figure out C compiler information!" $$
text "Make sure you're using GNU gcc, or clang"
return UnknownCC)
return info