Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support 9.12 interface files #23

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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