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 , supportsGHC2024
:: Bool
43 , reportsNoExt
:: Bool
44 -- ^ --supported-languages gives Ext and NoExt
45 , alwaysNondecIndent
:: Bool
46 -- ^ NondecreasingIndentation is always on
47 , flagGhciScript
:: Bool
48 -- ^ -ghci-script flag supported
49 , flagProfAuto
:: Bool
50 -- ^ new style -fprof-auto* flags
51 , flagProfLate
:: Bool
53 , flagPackageConf
:: Bool
54 -- ^ use package-conf instead of package-db
55 , flagDebugInfo
:: Bool
56 -- ^ -g flag supported
58 -- ^ -hiedir flag supported
59 , supportsDebugLevels
:: Bool
60 -- ^ supports numeric @-g@ levels
61 , supportsPkgEnvFiles
:: Bool
62 -- ^ picks up @.ghc.environment@ files
63 , flagWarnMissingHomeModules
:: Bool
64 -- ^ -Wmissing-home-modules is supported
65 , unitIdForExes
:: Bool
66 -- ^ Pass -this-unit-id flag when building executables
69 getImplInfo
:: Compiler
-> GhcImplInfo
71 case compilerFlavor comp
of
72 GHC
-> ghcVersionImplInfo
(compilerVersion comp
)
73 GHCJS
-> case compilerCompatVersion GHC comp
of
74 Just ghcVer
-> ghcjsVersionImplInfo
(compilerVersion comp
) ghcVer
77 ( "Distribution.Simple.GHC.Props.getImplProps: "
78 ++ "could not find GHC version for GHCJS compiler"
82 ( "Distribution.Simple.GHC.Props.getImplProps only works"
83 ++ "for GHC-like compilers (GHC, GHCJS)"
88 ghcVersionImplInfo
:: Version
-> GhcImplInfo
89 ghcVersionImplInfo ver
=
91 { supportsHaskell2010
= v
>= [7]
92 , supportsGHC2021
= v
>= [9, 1]
93 , supportsGHC2024
= v
>= [9, 9]
94 , reportsNoExt
= v
>= [7]
95 , alwaysNondecIndent
= v
< [7, 1]
96 , flagGhciScript
= v
>= [7, 2]
97 , flagProfAuto
= v
>= [7, 4]
98 , flagProfLate
= v
>= [9, 4]
99 , flagPackageConf
= v
< [7, 5]
100 , flagDebugInfo
= v
>= [7, 10]
101 , flagHie
= v
>= [8, 8]
102 , supportsDebugLevels
= v
>= [8, 0]
103 , supportsPkgEnvFiles
= v
>= [8, 0, 1, 20160901] -- broken in 8.0.1, fixed in 8.0.2
104 , flagWarnMissingHomeModules
= v
>= [8, 2]
105 , unitIdForExes
= v
>= [9, 2]
108 v
= versionNumbers ver
112 -- ^ The GHCJS version
116 ghcjsVersionImplInfo _ghcjsver ghcver
=
118 { supportsHaskell2010
= True
119 , supportsGHC2021
= True
120 , supportsGHC2024
= ghcv
>= [9, 9]
121 , reportsNoExt
= True
122 , alwaysNondecIndent
= False
123 , flagGhciScript
= True
124 , flagProfAuto
= True
125 , flagProfLate
= True
126 , flagPackageConf
= False
127 , flagDebugInfo
= False
128 , flagHie
= ghcv
>= [8, 8]
129 , supportsDebugLevels
= ghcv
>= [8, 0]
130 , supportsPkgEnvFiles
= ghcv
>= [8, 0, 2] -- TODO: check this works in ghcjs
131 , flagWarnMissingHomeModules
= ghcv
>= [8, 2]
132 , unitIdForExes
= ghcv
>= [9, 2]
135 ghcv
= versionNumbers ghcver