Commit 2b3f4718 authored by Phuong Trinh's avatar Phuong Trinh Committed by Marge Bot
Browse files

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.
parent 63b7d5fb
......@@ -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
......
......@@ -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
......
module A (message) where
message :: String
message = "Hello!!"
module B where
import A (message)
main :: IO ()
main = do
putStrLn message
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
test('T16500', [extra_files(['A.hs','B.hs',]),], run_command, ['$MAKE -s --no-print-directory T16500'])
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