Commit d82f5925 authored by Sergei Trofimovich's avatar Sergei Trofimovich Committed by Austin Seipp

CMM: add a mechanism to import C .data labels

This introduces new .cmm syntax for import:

    'import' 'CLOSURE' <identifier>;

Currently cmm syntax allows importing only function labels:

    import pthread_mutex_lock;

but sometimes ghc needs to import global gariables
or haskell closures:

    import ghczmprim_GHCziTypes_True_closure;
    import base_ControlziExceptionziBase_nestedAtomically_closure;
    import ghczmprim_GHCziTypes_False_closure;
    import sm_mutex;

It breaks on ia64 where there is a difference in
pointers to data and pointer to functions.

Patch fixes threaded runtime on ia64 where
dereference of 'sm_mutex' from CMM led to
incurrect location.

Exact breakage machanics are the same as in e18525fa

Merge into the 7.10 branch
Signed-off-by: default avatarSergei Trofimovich <>

Test Plan: passes ./validate, makes ghci work on ghc-7.8.4

Reviewers: simonmar, simonpj, austin

Reviewed By: austin

Subscribers: thomie

Differential Revision:
parent c024af13
......@@ -575,6 +575,10 @@ importName
{ ($1, mkForeignLabel $1 Nothing ForeignLabelInExternalPackage IsFunction) }
-- as previous 'NAME', but 'IsData'
{ ($2, mkForeignLabel $2 Nothing ForeignLabelInExternalPackage IsData) }
-- A label imported with an explicit packageId.
{ ($2, mkCmmCodeLabel (fsToPackageKey (mkFastString $1)) $2) }
......@@ -13,7 +13,7 @@
#include "Cmm.h"
#include "RaiseAsync.h"
import ghczmprim_GHCziTypes_True_closure;
import CLOSURE ghczmprim_GHCziTypes_True_closure;
/* -----------------------------------------------------------------------------
Exception Primitives
......@@ -28,12 +28,12 @@
import pthread_mutex_lock;
import pthread_mutex_unlock;
import base_ControlziExceptionziBase_nestedAtomically_closure;
import CLOSURE base_ControlziExceptionziBase_nestedAtomically_closure;
import EnterCriticalSection;
import LeaveCriticalSection;
import ghczmprim_GHCziTypes_False_closure;
import CLOSURE ghczmprim_GHCziTypes_False_closure;
#if defined(USE_MINIINTERPRETER) || !defined(mingw32_HOST_OS)
import sm_mutex;
import CLOSURE sm_mutex;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment