[commit: ghc] master: Fix -fobject-code with -fexternal-interpreter (fa70b1e)
git at git.haskell.org
git at git.haskell.org
Wed Nov 16 14:31:23 UTC 2016
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/fa70b1ec2e4638886e610279857c1c7529d6a361/ghc
>---------------------------------------------------------------
commit fa70b1ec2e4638886e610279857c1c7529d6a361
Author: Simon Marlow <marlowsd at gmail.com>
Date: Tue Nov 15 16:49:33 2016 +0000
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.
>---------------------------------------------------------------
fa70b1ec2e4638886e610279857c1c7529d6a361
compiler/ghci/GHCi.hs | 18 +++++++++++++++---
testsuite/driver/extra_files.py | 1 +
testsuite/tests/ghci/scripts/all.T | 1 +
testsuite/tests/ghci/scripts/ghci062.script | 9 +++++++++
.../tests/ghci/scripts/ghci062.stdout | 0
testsuite/tests/ghci/scripts/ghci062/Test.hs | 3 +++
6 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/compiler/ghci/GHCi.hs b/compiler/ghci/GHCi.hs
index c6d0d22..755771e 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 eb0aa27..3b92935 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 20888ae..4927abc 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 0000000..80aad1a
--- /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/libraries/base/tests/IO/T4144.stdout b/testsuite/tests/ghci/scripts/ghci062.stdout
similarity index 100%
copy from libraries/base/tests/IO/T4144.stdout
copy to testsuite/tests/ghci/scripts/ghci062.stdout
diff --git a/testsuite/tests/ghci/scripts/ghci062/Test.hs b/testsuite/tests/ghci/scripts/ghci062/Test.hs
new file mode 100644
index 0000000..f840579
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/ghci062/Test.hs
@@ -0,0 +1,3 @@
+module Test where
+
+test = "test"
More information about the ghc-commits
mailing list