X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2FcodeGen%2FCgForeignCall.hs;h=901dd96502e71f3c94f00272409dd54f19d3d154;hp=957651d3bae8567b6438eceb65df9ace8fd17c48;hb=6e9c0431a7cf2bf1a48f01db48c6a1d41fe15a09;hpb=1fede4bc9501744bf2269ce2a4cb9fb735969caa diff --git a/compiler/codeGen/CgForeignCall.hs b/compiler/codeGen/CgForeignCall.hs index 957651d..901dd96 100644 --- a/compiler/codeGen/CgForeignCall.hs +++ b/compiler/codeGen/CgForeignCall.hs @@ -33,6 +33,7 @@ import ClosureInfo import Constants import StaticFlags import Outputable +import Module import FastString import BasicTypes @@ -77,8 +78,20 @@ emitForeignCall results (CCall (CCallSpec target cconv safety)) args live where (call_args, cmm_target) = case target of - StaticTarget lbl -> (args, CmmLit (CmmLabel - (mkForeignLabel lbl call_size False IsFunction))) + -- If the packageId is Nothing then the label is taken to be in the + -- package currently being compiled. + StaticTarget lbl mPkgId + -> let labelSource + = case mPkgId of + Nothing -> ForeignLabelInThisPackage + Just pkgId -> ForeignLabelInPackage pkgId + in ( args + , CmmLit (CmmLabel + (mkForeignLabel lbl call_size labelSource IsFunction))) + + -- A label imported with "foreign import ccall "dynamic" ..." + -- Note: "dynamic" here doesn't mean "dynamic library". + -- Read the FFI spec for details. DynamicTarget -> case args of (CmmHinted fn _):rest -> (rest, fn) [] -> panic "emitForeignCall: DynamicTarget []" @@ -144,8 +157,8 @@ emitForeignCall' safety results target args vols _srt ret emitLoadThreadState suspendThread, resumeThread :: CmmExpr -suspendThread = CmmLit (CmmLabel (mkRtsCodeLabel (sLit "suspendThread"))) -resumeThread = CmmLit (CmmLabel (mkRtsCodeLabel (sLit "resumeThread"))) +suspendThread = CmmLit (CmmLabel (mkCmmCodeLabel rtsPackageId (fsLit "suspendThread"))) +resumeThread = CmmLit (CmmLabel (mkCmmCodeLabel rtsPackageId (fsLit "resumeThread"))) -- we might need to load arguments into temporaries before