Skip to content

Commit 5676fcc

Browse files
authored
Use object code for Template Haskell, emit desugarer warnings (haskell/ghcide#836)
* Use object code for TH * Set target location for TargetFiles * Fix tests * hlint * fix build on 8.10 * fix ghc-lib * address review comments * hlint * better error handling if module headers don't parse * Always desugar, don't call interactive API functions * deprioritize desugar when not TH, fix iface handling * write hie file on save * more tweaks * fix tests * disable desugarer warnings * use ModGuts for exports map * don't desugar * use bytecode * make HiFileStable early-cutoff * restore object code * re-enable desugar * review comments * Don't use ModIface for DocMap * fix docs for the current module * mark test as broken on windows
1 parent c82f253 commit 5676fcc

File tree

17 files changed

+468
-422
lines changed

17 files changed

+468
-422
lines changed

ghcide/session-loader/Development/IDE/Session.hs

+13-4
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,12 @@ loadSession dir = do
118118
-- files in the project so that `knownFiles` can learn about them and
119119
-- we can generate a complete module graph
120120
let extendKnownTargets newTargets = do
121-
knownTargets <- forM newTargets $ \TargetDetails{..} -> do
122-
found <- filterM (IO.doesFileExist . fromNormalizedFilePath) targetLocations
123-
return (targetTarget, found)
121+
knownTargets <- forM newTargets $ \TargetDetails{..} ->
122+
case targetTarget of
123+
TargetFile f -> pure (targetTarget, [f])
124+
TargetModule _ -> do
125+
found <- filterM (IO.doesFileExist . fromNormalizedFilePath) targetLocations
126+
return (targetTarget, found)
124127
modifyVar_ knownTargetsVar $ traverseHashed $ \known -> do
125128
let known' = HM.unionWith (<>) known $ HM.fromList knownTargets
126129
when (known /= known') $
@@ -501,6 +504,7 @@ setCacheDir logger prefix hscComponents comps dflags = do
501504
pure $ dflags
502505
& setHiDir cacheDir
503506
& setHieDir cacheDir
507+
& setODir cacheDir
504508

505509

506510
renderCradleError :: NormalizedFilePath -> CradleError -> FileDiagnostic
@@ -641,7 +645,7 @@ setOptions (ComponentOptions theOpts compRoot _) dflags = do
641645
setLinkerOptions :: DynFlags -> DynFlags
642646
setLinkerOptions df = df {
643647
ghcLink = LinkInMemory
644-
, hscTarget = HscNothing
648+
, hscTarget = HscAsm
645649
, ghcMode = CompManager
646650
}
647651

@@ -657,6 +661,11 @@ setHiDir f d =
657661
-- override user settings to avoid conflicts leading to recompilation
658662
d { hiDir = Just f}
659663

664+
setODir :: FilePath -> DynFlags -> DynFlags
665+
setODir f d =
666+
-- override user settings to avoid conflicts leading to recompilation
667+
d { objectDir = Just f}
668+
660669
getCacheDir :: String -> [String] -> IO FilePath
661670
getCacheDir prefix opts = getXdgDirectory XdgCache (cacheDir </> prefix ++ "-" ++ opts_hash)
662671
where

0 commit comments

Comments
 (0)