Skip to content
Snippets Groups Projects
Commit 4e0b5bfa authored by Cheng Shao's avatar Cheng Shao :beach:
Browse files

ghc-heap: fix HalfWord incompatible Binary instances for cross GHC

ghc-heap defines HalfWord as Word32/Word16 depending on host word
size. For cross GHC with different host/target word sizes, the Binary
instances are incompatible and breaks iserv serialization of any
message type that involves HalfWord, breaking the ghci debugger. This
patch fixes the issue and has been tested to fix ghci debugger
functionality of the wasm backend. Fixes #25420 #25781.

(cherry picked from commit b228fcb5)
parent bc886a74
No related branches found
No related tags found
No related merge requests found
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module GHC.Exts.Heap.InfoTable.Types
( StgInfoTable(..)
, EntryFunPtr
, HalfWord
, HalfWord(..)
, ItblCodes
) where
......@@ -18,13 +21,16 @@ type ItblCodes = Either [Word8] [Word32]
#include "ghcautoconf.h"
-- Ultra-minimalist version specially for constructors
#if SIZEOF_VOID_P == 8
type HalfWord = Word32
type HalfWord' = Word32
#elif SIZEOF_VOID_P == 4
type HalfWord = Word16
type HalfWord' = Word16
#else
#error Unknown SIZEOF_VOID_P
#endif
newtype HalfWord = HalfWord HalfWord'
deriving newtype (Enum, Eq, Integral, Num, Ord, Real, Show, Storable)
type EntryFunPtr = FunPtr (Ptr () -> IO (Ptr ()))
-- | This is a somewhat faithful representation of an info table. See
......
......@@ -498,6 +498,10 @@ instance Binary (FunPtr a) where
put = put . castFunPtrToPtr
get = castPtrToFunPtr <$> get
instance Binary Heap.HalfWord where
put x = put (fromIntegral x :: Word32)
get = fromIntegral <$> (get :: Get Word32)
-- Binary instances to support the GetClosure message
#if MIN_VERSION_ghc_heap(8,11,0)
instance Binary Heap.StgTSOProfInfo
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment