
Hi all, we are working on a Haskell support plugin for IntelliJ IDEA, and need to provide correct compilation of Haskell programs. We compile the latter using GHC API, with options specifying .hi and .o paths. For some reason, unlike a standalone GHC compilation, GHC API ignores the values of the outputFile and outputHi flags. Please find attached a minimal example where "err_test.hs" uses GHC API to compile "src/A.hs". Thus, "test_ghc.sh" and "test_my.sh" should do the same, but the first works correctly while the latter puts "use.o" and "use.hi" to the "src" folder. To launch "test_my.sh", please change the value of lib in "err_test.hs" according to your GHC installation path. Thank you very much in advance! Marianna Rapoport, amaurremi@gmail.com Oleg Sobolev, sobolev_ov@mail.ru

Hi Marianna, On Sun, Jul 17, 2011 at 12:11:57PM +0200, Marianna Rapoport wrote:
Thus, "test_ghc.sh" and "test_my.sh" should do the same, but the first works correctly while the latter puts "use.o" and "use.hi" to the "src" folder.
I'm no expert on the GHC API, but replacing doWalk with this seems to do what you want: import GhcMonad import GHC import HscTypes import DriverPhases import DriverPipeline doWalk :: [String] -> String -> Ghc () doWalk cmdFlags file = do flg <- getSessionDynFlags (flg, _, _) <- parseDynamicFlags flg (map noLoc cmdFlags) setSessionDynFlags flg { ghcLink = NoLink, ghcMode = OneShot } hsc_env <- GHC.getSession let srcs = [(file, Nothing)] liftIO $ oneShot hsc_env StopLn srcs Thanks Ian
participants (2)
-
Ian Lynagh
-
Marianna Rapoport