diff options
-rw-r--r-- | compiler/ghci/GHCi.hs | 18 | ||||
-rw-r--r-- | testsuite/driver/extra_files.py | 1 | ||||
-rwxr-xr-x | testsuite/tests/ghci/scripts/all.T | 1 | ||||
-rw-r--r-- | testsuite/tests/ghci/scripts/ghci062.script | 9 | ||||
-rw-r--r-- | testsuite/tests/ghci/scripts/ghci062.stdout | 1 | ||||
-rw-r--r-- | testsuite/tests/ghci/scripts/ghci062/Test.hs | 3 |
6 files changed, 30 insertions, 3 deletions
diff --git a/compiler/ghci/GHCi.hs b/compiler/ghci/GHCi.hs index c6d0d229fd..755771e1ba 100644 --- a/compiler/ghci/GHCi.hs +++ b/compiler/ghci/GHCi.hs @@ -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 = diff --git a/testsuite/driver/extra_files.py b/testsuite/driver/extra_files.py index eb0aa27ca2..3b9293585d 100644 --- a/testsuite/driver/extra_files.py +++ b/testsuite/driver/extra_files.py @@ -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'], diff --git a/testsuite/tests/ghci/scripts/all.T b/testsuite/tests/ghci/scripts/all.T index 20888ae1db..4927abcb97 100755 --- a/testsuite/tests/ghci/scripts/all.T +++ b/testsuite/tests/ghci/scripts/all.T @@ -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']) diff --git a/testsuite/tests/ghci/scripts/ghci062.script b/testsuite/tests/ghci/scripts/ghci062.script new file mode 100644 index 0000000000..80aad1ad44 --- /dev/null +++ b/testsuite/tests/ghci/scripts/ghci062.script @@ -0,0 +1,9 @@ +-- 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 diff --git a/testsuite/tests/ghci/scripts/ghci062.stdout b/testsuite/tests/ghci/scripts/ghci062.stdout new file mode 100644 index 0000000000..8b8441b91d --- /dev/null +++ b/testsuite/tests/ghci/scripts/ghci062.stdout @@ -0,0 +1 @@ +"test" diff --git a/testsuite/tests/ghci/scripts/ghci062/Test.hs b/testsuite/tests/ghci/scripts/ghci062/Test.hs new file mode 100644 index 0000000000..f8405796d7 --- /dev/null +++ b/testsuite/tests/ghci/scripts/ghci062/Test.hs @@ -0,0 +1,3 @@ +module Test where + +test = "test" |