[commit: ghc] master: Properly externalise codegen identifiers (#8166) (776cfe2)

git at git.haskell.org git at git.haskell.org
Tue Aug 27 04:18:35 CEST 2013


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/776cfe28cf089c24a56a288f2f0c49494f7d9e47/ghc

>---------------------------------------------------------------

commit 776cfe28cf089c24a56a288f2f0c49494f7d9e47
Author: Austin Seipp <aseipp at pobox.com>
Date:   Mon Aug 26 20:12:02 2013 -0500

    Properly externalise codegen identifiers (#8166)
    
    388e14e2 unfortunately broke a subtle invariant in the code generator:
    when generating code for an application, names may need to be
    externalised, in case you're building against something external with
    was built with -split-objs.
    
    We were never externalising the ids of the applied functions. This means
    if the libraries are split and we call into them, then the compiler
    won't may not generate correct ids when making references to functions
    in the library (causing linker failure).
    
    I'm not entirely sure how this didn't break everything, but it certainly
    caused several failures for a bunch of people. I had to fiddle with my
    tree a little to make this occur.
    
    This should fix #8166.
    
    Signed-off-by: Austin Seipp <aseipp at pobox.com>


>---------------------------------------------------------------

776cfe28cf089c24a56a288f2f0c49494f7d9e47
 compiler/codeGen/StgCmmExpr.hs |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/compiler/codeGen/StgCmmExpr.hs b/compiler/codeGen/StgCmmExpr.hs
index 24b12f7..6b010bb 100644
--- a/compiler/codeGen/StgCmmExpr.hs
+++ b/compiler/codeGen/StgCmmExpr.hs
@@ -634,12 +634,16 @@ cgIdApp fun_id [] | isVoidId fun_id = emitReturn []
 cgIdApp fun_id args = do
     dflags   <- getDynFlags
     fun_info <- getCgIdInfo fun_id
-    let fun_arg     = StgVarArg fun_id
-        fun_name    = idName            fun_id
+    let cg_fun_id   = cg_id fun_info
+        -- NB. use (cg_id fun_info) instead of fun_id, because the former
+        -- may be externalised for -split-objs.
+        -- See StgCmm.maybeExternaliseId.
+        fun_arg     = StgVarArg cg_fun_id
+        fun_name    = idName            cg_fun_id
         fun         = idInfoToAmode     fun_info
         lf_info     = cg_lf        fun_info
         node_points dflags = nodeMustPointToIt dflags lf_info
-    case (getCallMethod dflags fun_name (idCafInfo fun_id) lf_info (length args)) of
+    case (getCallMethod dflags fun_name (idCafInfo cg_fun_id) lf_info (length args)) of
 
             -- A value in WHNF, so we can just return it.
         ReturnIt -> emitReturn [fun]    -- ToDo: does ReturnIt guarantee tagged?





More information about the ghc-commits mailing list