Commit fa70b1ec authored by Simon Marlow's avatar Simon Marlow

Fix -fobject-code with -fexternal-interpreter

If the user does :cd in GHCi with -fexternal-interpreter, then we can
fail to find the object files.
parent 0135188f
......@@ -79,6 +79,7 @@ import GHC.IO.Handle.Types (Handle)
import Foreign.C
import GHC.IO.Handle.FD (fdToHandle)
#else
import System.Directory
import System.Posix as Posix
#endif
import System.Process
......@@ -383,13 +384,24 @@ loadDLL :: HscEnv -> String -> IO (Maybe String)
loadDLL hsc_env str = iservCmd hsc_env (LoadDLL str)
loadArchive :: HscEnv -> String -> IO ()
loadArchive hsc_env str = iservCmd hsc_env (LoadArchive str)
loadArchive hsc_env path = do
path' <- canonicalizePath path -- Note [loadObj and relative paths]
iservCmd hsc_env (LoadArchive path')
loadObj :: HscEnv -> String -> IO ()
loadObj hsc_env str = iservCmd hsc_env (LoadObj str)
loadObj hsc_env path = do
path' <- canonicalizePath path -- Note [loadObj and relative paths]
iservCmd hsc_env (LoadObj path')
unloadObj :: HscEnv -> String -> IO ()
unloadObj hsc_env str = iservCmd hsc_env (UnloadObj str)
unloadObj hsc_env path = do
path' <- canonicalizePath path -- Note [loadObj and relative paths]
iservCmd hsc_env (UnloadObj path')
-- Note [loadObj and relative paths]
-- the iserv process might have a different current directory from the
-- GHC process, so we must make paths absolute before sending them
-- over.
addLibrarySearchPath :: HscEnv -> String -> IO (Ptr ())
addLibrarySearchPath hsc_env str =
......
......@@ -290,6 +290,7 @@ extra_src_files = {
'ghci026': ['../prog002'],
'ghci038': ['../shell.hs'],
'ghci058': ['../shell.hs'],
'ghci062': ['ghci062/', 'ghci062/Test.hs'],
'ghcilink001': ['TestLink.hs', 'f.c'],
'ghcilink002': ['TestLink.hs', 'f.c'],
'ghcilink004': ['TestLink.hs', 'f.c'],
......
......@@ -97,6 +97,7 @@ test('ghci056',
test('ghci057', normal, ghci_script, ['ghci057.script'])
test('ghci060', normal, ghci_script, ['ghci060.script'])
test('ghci061', normal, ghci_script, ['ghci061.script'])
test('ghci062', extra_ways(['ghci-ext']), ghci_script, ['ghci062.script'])
test('T2452', normal, ghci_script, ['T2452.script'])
test('T2766', normal, ghci_script, ['T2766.script'])
......
-- Tests for a bug in -fexternal-interpreter where we call loadObj
-- with a local path for the object file, and the iserv process is
-- running with a different current directory so it can't load the
-- object file.
:cd ghci062
:set -fobject-code
:load Test
test
module Test where
test = "test"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment