1 -----------------------------------------------------------------------------
4 -- Module : Distribution.Simple.GHC.ImplInfo
6 -- Maintainer : cabal-devel@haskell.org
7 -- Portability : portable
9 -- This module contains the data structure describing invocation
10 -- details for a GHC or GHC-derived compiler, such as supported flags
11 -- and workarounds for bugs.
12 module Distribution
.Simple
.GHC
.ImplInfo
16 , ghcjsVersionImplInfo
19 import Distribution
.Compat
.Prelude
22 import Distribution
.Simple
.Compiler
23 import Distribution
.Version
26 -- Information about features and quirks of a GHC-based implementation.
28 -- Compiler flavors based on GHC behave similarly enough that some of
29 -- the support code for them is shared. Every implementation has its
30 -- own peculiarities, that may or may not be a direct result of the
31 -- underlying GHC version. This record keeps track of these differences.
33 -- All shared code (i.e. everything not in the Distribution.Simple.FLAVOR
34 -- module) should use implementation info rather than version numbers
35 -- to test for supported features.
36 data GhcImplInfo
= GhcImplInfo
37 { supportsHaskell2010
:: Bool
38 -- ^ -XHaskell2010 and -XHaskell98 flags
39 , supportsGHC2021
:: Bool
41 , reportsNoExt
:: Bool
42 -- ^ --supported-languages gives Ext and NoExt
43 , alwaysNondecIndent
:: Bool
44 -- ^ NondecreasingIndentation is always on
45 , flagGhciScript
:: Bool
46 -- ^ -ghci-script flag supported
47 , flagProfAuto
:: Bool
48 -- ^ new style -fprof-auto* flags
49 , flagProfLate
:: Bool
51 , flagPackageConf
:: Bool
52 -- ^ use package-conf instead of package-db
53 , flagDebugInfo
:: Bool
54 -- ^ -g flag supported
56 -- ^ -hiedir flag supported
57 , supportsDebugLevels
:: Bool
58 -- ^ supports numeric @-g@ levels
59 , supportsPkgEnvFiles
:: Bool
60 -- ^ picks up @.ghc.environment@ files
61 , flagWarnMissingHomeModules
:: Bool
62 -- ^ -Wmissing-home-modules is supported
63 , unitIdForExes
:: Bool
64 -- ^ Pass -this-unit-id flag when building executables
67 getImplInfo
:: Compiler
-> GhcImplInfo
69 case compilerFlavor comp
of
70 GHC
-> ghcVersionImplInfo
(compilerVersion comp
)
71 GHCJS
-> case compilerCompatVersion GHC comp
of
72 Just ghcVer
-> ghcjsVersionImplInfo
(compilerVersion comp
) ghcVer
75 ( "Distribution.Simple.GHC.Props.getImplProps: "
76 ++ "could not find GHC version for GHCJS compiler"
80 ( "Distribution.Simple.GHC.Props.getImplProps only works"
81 ++ "for GHC-like compilers (GHC, GHCJS)"
86 ghcVersionImplInfo
:: Version
-> GhcImplInfo
87 ghcVersionImplInfo ver
=
89 { supportsHaskell2010
= v
>= [7]
90 , supportsGHC2021
= v
>= [9, 1]
91 , reportsNoExt
= v
>= [7]
92 , alwaysNondecIndent
= v
< [7, 1]
93 , flagGhciScript
= v
>= [7, 2]
94 , flagProfAuto
= v
>= [7, 4]
95 , flagProfLate
= v
>= [9, 4]
96 , flagPackageConf
= v
< [7, 5]
97 , flagDebugInfo
= v
>= [7, 10]
98 , flagHie
= v
>= [8, 8]
99 , supportsDebugLevels
= v
>= [8, 0]
100 , supportsPkgEnvFiles
= v
>= [8, 0, 1, 20160901] -- broken in 8.0.1, fixed in 8.0.2
101 , flagWarnMissingHomeModules
= v
>= [8, 2]
102 , unitIdForExes
= v
>= [9, 2]
105 v
= versionNumbers ver
109 -- ^ The GHCJS version
113 ghcjsVersionImplInfo _ghcjsver ghcver
=
115 { supportsHaskell2010
= True
116 , supportsGHC2021
= True
117 , reportsNoExt
= True
118 , alwaysNondecIndent
= False
119 , flagGhciScript
= True
120 , flagProfAuto
= True
121 , flagProfLate
= True
122 , flagPackageConf
= False
123 , flagDebugInfo
= False
124 , flagHie
= ghcv
>= [8, 8]
125 , supportsDebugLevels
= ghcv
>= [8, 0]
126 , supportsPkgEnvFiles
= ghcv
>= [8, 0, 2] -- TODO: check this works in ghcjs
127 , flagWarnMissingHomeModules
= ghcv
>= [8, 2]
128 , unitIdForExes
= ghcv
>= [9, 2]
131 ghcv
= versionNumbers ghcver