-
-
Notifications
You must be signed in to change notification settings - Fork 378
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Detect ghc version mismatches * Add ghc-check to stack extra deps * ghc-check: explicit libdir and delay version error
- Loading branch information
1 parent
f804b13
commit 9ccd9ee
Showing
8 changed files
with
128 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
module Util (setupDynFlags, getLibdir) where | ||
|
||
-- Set the GHC libdir to the nix libdir if it's present. | ||
import qualified GHC.Paths as GHCPaths | ||
import DynFlags ( gopt_unset | ||
, GhcMode(CompManager) | ||
, HscTarget(HscNothing) | ||
, GhcLink(LinkInMemory) | ||
, GeneralFlag | ||
( Opt_IgnoreInterfacePragmas | ||
, Opt_IgnoreOptimChanges | ||
, Opt_WriteInterface | ||
) | ||
, gopt_set | ||
, updOptLevel | ||
, DynFlags(..) | ||
) | ||
import Data.Maybe ( fromMaybe ) | ||
import Development.IDE.GHC.Util ( setDefaultHieDir | ||
, dontWriteHieFiles | ||
) | ||
import System.Environment ( lookupEnv ) | ||
import GHC (GhcMonad, setSessionDynFlags ) | ||
import Data.Functor ( void ) | ||
|
||
setupDynFlags :: GhcMonad f => FilePath -> DynFlags -> f () | ||
setupDynFlags cacheDir = | ||
void | ||
. setSessionDynFlags | ||
-- disabled, generated directly by ghcide instead | ||
. flip gopt_unset Opt_WriteInterface | ||
-- disabled, generated directly by ghcide instead | ||
-- also, it can confuse the interface stale check | ||
. dontWriteHieFiles | ||
. setHiDir cacheDir | ||
. setDefaultHieDir cacheDir | ||
. setIgnoreInterfacePragmas | ||
. setLinkerOptions | ||
. disableOptimisation | ||
|
||
getLibdir :: IO FilePath | ||
getLibdir = fromMaybe GHCPaths.libdir <$> lookupEnv "NIX_GHC_LIBDIR" | ||
|
||
-- we don't want to generate object code so we compile to bytecode | ||
-- (HscInterpreted) which implies LinkInMemory | ||
|
||
-- HscInterpreted | ||
setLinkerOptions :: DynFlags -> DynFlags | ||
setLinkerOptions df = | ||
df { ghcLink = LinkInMemory, hscTarget = HscNothing, ghcMode = CompManager } | ||
|
||
setIgnoreInterfacePragmas :: DynFlags -> DynFlags | ||
setIgnoreInterfacePragmas df = | ||
gopt_set (gopt_set df Opt_IgnoreInterfacePragmas) Opt_IgnoreOptimChanges | ||
|
||
disableOptimisation :: DynFlags -> DynFlags | ||
disableOptimisation df = updOptLevel 0 df | ||
|
||
setHiDir :: FilePath -> DynFlags -> DynFlags | ||
setHiDir f d = | ||
-- override user settings to avoid conflicts leading to recompilation | ||
d { hiDir = Just f } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters