Making hadrian/ghci.sh work executing :main
Since !559 (merged) !555 (merged) !554 (merged) you can load GHC into GHCi like normal and run functions to inspect their result and use the GHCi debugger and so on.
However, if you try to invoke :main
on any file then you are greeted with a segfault.
If you try to turn on -fexternal-interpreter
you run into errors about missing symbols. The solution here is to add
the .o
files from c-sources
to the hadrian/ghci.sh
command line but then you can some confusing errors from the linker.
+ let context = vanillaContext Stage0 compiler
+ cSrcs' <- interpretInContext (vanillaContext Stage0 compiler)
+ (getContextData cSrcs)
+ cObjs <- mapM (objectPath context) cSrcs'
+ need cObjs
+
-- Find out the arguments that are needed to load a module into the
-- session
arg_list <- interpret fake_target getArgs
- liftIO $ putStrLn (intercalate " " arg_list)
+ liftIO $ putStrLn (intercalate " " (arg_list ++ cObjs))
Perhaps if -fexternal-interpreter
is fixed then the segfaults will also stop happening in the normal version.