X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2FcodeGen%2FCgForeignCall.hs;h=879d04332949709de68a82fbdca58bacf0539170;hp=809e10b875fbb8baa567848297ae8356ab941a40;hb=7854ec4b11e117f8514553890851d14a66690fbb;hpb=e5fba2f55f560b41e27047bf59958729d51aca84 diff --git a/compiler/codeGen/CgForeignCall.hs b/compiler/codeGen/CgForeignCall.hs index 809e10b..879d043 100644 --- a/compiler/codeGen/CgForeignCall.hs +++ b/compiler/codeGen/CgForeignCall.hs @@ -78,8 +78,27 @@ 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))) + + -- A target label known to be in the current package. + StaticTarget lbl + -> ( args + , CmmLit (CmmLabel + (mkForeignLabel lbl call_size ForeignLabelInThisPackage IsFunction))) + + -- If the packageId is Nothing then the label is taken to be in the + -- package currently being compiled. + PackageTarget 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 []"