Skip to content

Commit

Permalink
Merge pull request #23 from hsyl20/hsyl20/ghc-9.12
Browse files Browse the repository at this point in the history
Support 9.12 interface files
  • Loading branch information
mpilgrem authored Oct 21, 2024
2 parents 6e5c603 + 9d0affb commit 88d8587
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/HiFileParser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ data IfaceVersion
| V9041
| V9045
| V9081
| V9120
deriving (Show,Eq,Ord,Enum)
-- careful, the Ord matters!

Expand Down Expand Up @@ -645,6 +646,12 @@ getInterfaceRecent version d = do
getInterface :: Get Interface
getInterface = do
let enableLEB128 = modify (\c -> c { useLEB128 = True})
-- read a relative bin pointer
let getRelPtr = do
c <- bytesRead
p <- getPtr
pure (fromIntegral c + p)


magic <- lookAhead getWord32be >>= \case
-- normal magic
Expand Down Expand Up @@ -679,6 +686,7 @@ getInterface = do
traceGet ("Version: " ++ version)

let !ifaceVersion
| version >= "9120" = V9120
| version >= "9081" = V9081
| version >= "9045" = V9045
| version >= "9041" = V9041
Expand All @@ -705,7 +713,9 @@ getInterface = do
when (ifaceVersion >= V9001) $ void getPtr

-- dict_ptr
dictPtr <- getPtr
dictPtr <- if ifaceVersion >= V9120 -- 9.12 uses relative pointers
then getRelPtr
else getPtr
traceGet ("Dict ptr: " ++ show dictPtr)

-- dict
Expand All @@ -714,7 +724,12 @@ getInterface = do
-- symtable_ptr
void getPtr

-- IfaceType table
when (ifaceVersion >= V9120) $
void getPtr

case ifaceVersion of
V9120 -> getInterfaceRecent ifaceVersion dict
V9081 -> getInterfaceRecent ifaceVersion dict
V9045 -> getInterfaceRecent ifaceVersion dict
V9041 -> getInterfaceRecent ifaceVersion dict
Expand Down
Binary file added test-files/iface/x64/ghc9120/Main.hi
Binary file not shown.
Binary file added test-files/iface/x64/ghc9120/X.hi
Binary file not shown.
1 change: 1 addition & 0 deletions test/HiFileParserSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ versions64 =
, "ghc9047" -- Last in GHC 9.4 series, using GHC 9.4.5 format
, "ghc9063" -- Last in GHC 9.6 series, using GHC 9.4.5 format
, "ghc9081" -- First in GHC 9.8 series, using GHC 9.8.1 format
, "ghc9120" -- First in GHC 9.12 series, using GHC 9.12 format
]

spec :: Spec
Expand Down

0 comments on commit 88d8587

Please sign in to comment.