[Git][ghc/ghc][master] Fix #16500: look for interface files in -hidir flag in OneShot mode

Marge Bot gitlab at gitlab.haskell.org
Mon Apr 8 18:41:48 UTC 2019



 Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
2b3f4718 by Phuong Trinh at 2019-04-08T18:35:43Z
Fix #16500: look for interface files in -hidir flag in OneShot mode

We are currently ignoring options set in the hiDir field of hsc_dflags
when looking for interface files while compiling in OneShot mode. This
is inconsistent with the behaviour of other directory redirecting fields
(such as objectDir or hieDir). It is also inconsistent with the
behaviour of compilation in CompManager mode (a.k.a `ghc --make`) which
looks for interface files in the directory set in hidir flag. This
changes Finder.hs so that we use the value of hiDir while looking for
interface in OneShot mode.

- - - - -


7 changed files:

- compiler/main/Finder.hs
- docs/users_guide/separate_compilation.rst
- + testsuite/tests/driver/T16500/A.hs
- + testsuite/tests/driver/T16500/B.hs
- + testsuite/tests/driver/T16500/Makefile
- + testsuite/tests/driver/T16500/T16500.stdout
- + testsuite/tests/driver/T16500/all.T


Changes:

=====================================
compiler/main/Finder.hs
=====================================
@@ -313,8 +313,10 @@ findInstalledHomeModule hsc_env mod_name =
       , ("lhsig",  mkHomeModLocationSearched dflags mod_name "lhsig")
       ]
 
-     hi_exts = [ (hisuf,                mkHiOnlyModLocation dflags hisuf)
-               , (addBootSuffix hisuf,  mkHiOnlyModLocation dflags hisuf)
+     -- we use mkHomeModHiOnlyLocation instead of mkHiOnlyModLocation so that
+     -- when hiDir field is set in dflags, we know to look there (see #16500)
+     hi_exts = [ (hisuf,                mkHomeModHiOnlyLocation dflags mod_name)
+               , (addBootSuffix hisuf,  mkHomeModHiOnlyLocation dflags mod_name)
                ]
 
         -- In compilation manager modes, we look for source files in the home
@@ -489,6 +491,15 @@ mkHomeModLocation2 dflags mod src_basename ext = do
                         ml_obj_file  = obj_fn,
                         ml_hie_file  = hie_fn })
 
+mkHomeModHiOnlyLocation :: DynFlags
+                        -> ModuleName
+                        -> FilePath
+                        -> BaseName
+                        -> IO ModLocation
+mkHomeModHiOnlyLocation dflags mod path basename = do
+   loc <- mkHomeModLocation2 dflags mod (path </> basename) ""
+   return loc { ml_hs_file = Nothing }
+
 mkHiOnlyModLocation :: DynFlags -> Suffix -> FilePath -> String
                     -> IO ModLocation
 mkHiOnlyModLocation dflags hisuf path basename


=====================================
docs/users_guide/separate_compilation.rst
=====================================
@@ -260,6 +260,9 @@ Redirecting the compilation output(s)
     example, they would still be put in ``parse/Foo.hi``,
     ``parse/Bar.hi``, and ``gurgle/Bumble.hi``.
 
+    Please also note that when doing incremental compilation, this directory is
+    where GHC looks into to find object files from previous builds.
+
 .. ghc-flag:: -ohi ⟨file⟩
     :shortdesc: set the filename in which to put the interface
     :type: dynamic
@@ -288,6 +291,10 @@ Redirecting the compilation output(s)
     Redirects all generated interface files into ⟨dir⟩, instead of the
     default.
 
+    Please also note that when doing incremental compilation (by ``ghc --make``
+    or ``ghc -c``), this directory is where GHC looks into to find interface
+    files.
+
 .. ghc-flag:: -hiedir ⟨dir⟩
     :shortdesc: set directory for extended interface files
     :type: dynamic
@@ -296,6 +303,10 @@ Redirecting the compilation output(s)
     Redirects all generated extended interface files into ⟨dir⟩, instead of
     the default.
 
+    Please also note that when doing incremental compilation (by ``ghc --make``
+    or ``ghc -c``), this directory is where GHC looks into to find extended
+    interface files.
+
 .. ghc-flag:: -stubdir ⟨dir⟩
     :shortdesc: redirect FFI stub files
     :type: dynamic


=====================================
testsuite/tests/driver/T16500/A.hs
=====================================
@@ -0,0 +1,4 @@
+module A (message) where
+
+message :: String
+message = "Hello!!"


=====================================
testsuite/tests/driver/T16500/B.hs
=====================================
@@ -0,0 +1,7 @@
+module B where
+
+import A (message)
+
+main :: IO ()
+main = do
+    putStrLn message


=====================================
testsuite/tests/driver/T16500/Makefile
=====================================
@@ -0,0 +1,12 @@
+TOP=../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
+
+T16500:
+	$(RM) -rf interfaces objects
+	$(RM) A.hi
+	mkdir -p interfaces
+	mkdir -p objects
+	"$(TEST_HC)" $(TEST_HC_OPTS) -v0 -c A.hs -iinterfaces -hidir interfaces -odir objects
+	touch A.hi
+	"$(TEST_HC)" $(TEST_HC_OPTS) -v0 -c B.hs -iinterfaces -hidir interfaces -odir objects


=====================================
testsuite/tests/driver/T16500/T16500.stdout
=====================================


=====================================
testsuite/tests/driver/T16500/all.T
=====================================
@@ -0,0 +1 @@
+test('T16500', [extra_files(['A.hs','B.hs',]),], run_command, ['$MAKE -s --no-print-directory T16500'])



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/commit/2b3f4718502465e2b4dfa4a7868ed7a3ad5e4ff1

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/commit/2b3f4718502465e2b4dfa4a7868ed7a3ad5e4ff1
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20190408/3675967e/attachment-0001.html>


More information about the ghc-commits mailing list