Ticket #10462: 0001-ghci-indicate-that-foreign-primops-are-not-supported.patch

File 0001-ghci-indicate-that-foreign-primops-are-not-supported.patch, 1.9 KB (added by hsyl20, 3 years ago)
  • compiler/ghci/ByteCodeGen.hs

    From 1dc0af855dd4be8b751fbca959f1bfebb8471028 Mon Sep 17 00:00:00 2001
    From: Sylvain HENRY <hsyl20@gmail.com>
    Date: Mon, 26 Oct 2015 14:11:39 +0100
    Subject: [PATCH] ghci: indicate that foreign primops are not supported
    
    ---
     compiler/ghci/ByteCodeGen.hs | 21 ++++++++++++++++++++-
     1 file changed, 20 insertions(+), 1 deletion(-)
    
    diff --git a/compiler/ghci/ByteCodeGen.hs b/compiler/ghci/ByteCodeGen.hs
    index b06d1a4..2aea730 100644
    a b schemeT d s p app 
    598598
    599599   -- Case 1
    600600   | Just (CCall ccall_spec) <- isFCallId_maybe fn
    601    = generateCCall d s p ccall_spec fn args_r_to_l
     601   = if isSupportedCConv ccall_spec
     602      then generateCCall d s p ccall_spec fn args_r_to_l
     603      else unsupportedCConvException
     604
    602605
    603606   -- Case 2: Constructor application
    604607   | Just con <- maybe_saturated_dcon,
    unboxedTupleException 
    15151518            "  Possibly due to foreign import/export decls in source.\n"++
    15161519            "  Workaround: use -fobject-code, or compile this module to .o separately."))
    15171520
     1521-- | Indicate if the calling convention is supported
     1522isSupportedCConv :: CCallSpec -> Bool
     1523isSupportedCConv (CCallSpec _ cconv _) = case cconv of
     1524   CCallConv            -> True     -- we explicitly pattern match on every
     1525   StdCallConv          -> True     -- convention to ensure that a warning is triggered
     1526   PrimCallConv         -> False    -- when a new one is added
     1527   JavaScriptCallConv   -> False
     1528   CApiConv             -> False
     1529
     1530-- See bug #10462
     1531unsupportedCConvException :: a
     1532unsupportedCConvException
     1533   = throwGhcException
     1534        (ProgramError
     1535           ("Error: bytecode compiler can't handle some foreign calling conventions\n"++
     1536            "  Workaround: use -fobject-code, or compile this module to .o separately."))
    15181537
    15191538mkSLIDE :: Word16 -> Word -> OrdList BCInstr
    15201539mkSLIDE n d