summaryrefslogtreecommitdiff
path: root/compiler/GHC/Unit
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2022-03-23 17:34:17 +0000
committerMatthew Pickering <matthewtpickering@gmail.com>2022-04-01 11:15:32 +0100
commit5e5a12d9c672ee30590293e3f2dd48c15d1acf35 (patch)
tree4d2f403db0ef81050d9e8d51239ab74a57019ce6 /compiler/GHC/Unit
parentf8fc6d2e91038a98a321eceefe0a2ffff3dc9e72 (diff)
downloadhaskell-5e5a12d9c672ee30590293e3f2dd48c15d1acf35.tar.gz
driver: In oneshot mode, look for interface files in hidir
How things should work: * -i is the search path for source files * -hidir explicitly sets the search path for interface files and the output location for interface files. * -odir sets the search path and output location for object files. Before in one shot mode we would look for the interface file in the search locations given by `-i`, but then set the path to be in the `hidir`, so in unusual situations the finder could find an interface file in the `-i` dir but later fail because it tried to read the interface file from the `-hidir`. A bug identified by #20569
Diffstat (limited to 'compiler/GHC/Unit')
-rw-r--r--compiler/GHC/Unit/Finder.hs13
1 files changed, 10 insertions, 3 deletions
diff --git a/compiler/GHC/Unit/Finder.hs b/compiler/GHC/Unit/Finder.hs
index c3c517cb18..45057d13e2 100644
--- a/compiler/GHC/Unit/Finder.hs
+++ b/compiler/GHC/Unit/Finder.hs
@@ -412,6 +412,12 @@ findInstalledHomeModule fc fopts home_unit mod_name = do
home_path = case maybe_working_dir of
Nothing -> finder_importPaths fopts
Just fp -> augmentImports fp (finder_importPaths fopts)
+ hi_dir_path =
+ case finder_hiDir fopts of
+ Just hiDir -> case maybe_working_dir of
+ Nothing -> [hiDir]
+ Just fp -> [fp </> hiDir]
+ Nothing -> home_path
hisuf = finder_hiSuf fopts
mod = mkModule home_unit mod_name
@@ -431,8 +437,9 @@ findInstalledHomeModule fc fopts home_unit mod_name = do
-- In compilation manager modes, we look for source files in the home
-- package because we can compile these automatically. In one-shot
-- compilation mode we look for .hi and .hi-boot files only.
- exts | finder_lookupHomeInterfaces fopts = hi_exts
- | otherwise = source_exts
+ (search_dirs, exts)
+ | finder_lookupHomeInterfaces fopts = (hi_dir_path, hi_exts)
+ | otherwise = (home_path, source_exts)
in
-- special case for GHC.Prim; we won't find it in the filesystem.
@@ -440,7 +447,7 @@ findInstalledHomeModule fc fopts home_unit mod_name = do
-- is a home module).
if mod `installedModuleEq` gHC_PRIM
then return (InstalledFound (error "GHC.Prim ModLocation") mod)
- else searchPathExts home_path mod exts
+ else searchPathExts search_dirs mod exts
-- | Prepend the working directory to the search path.
augmentImports :: FilePath -> [FilePath] -> [FilePath]