@@ -19,15 +19,17 @@ import Distribution.Types.Component
19
19
import Distribution.Types.TargetInfo
20
20
21
21
import Distribution.Simple.Build.Inputs
22
+ import Distribution.Simple.Compiler
22
23
import Distribution.Simple.GHC.Build.Modules
23
24
import Distribution.Simple.GHC.Build.Utils
24
25
import Distribution.Simple.LocalBuildInfo
25
- import Distribution.Simple.Program.Types
26
+ import Distribution.Simple.Program
26
27
import Distribution.Simple.Setup.Common (commonSetupTempFileOptions )
27
28
import Distribution.System (Arch (JavaScript ), Platform (.. ))
28
29
import Distribution.Types.ComponentLocalBuildInfo
29
30
import Distribution.Utils.Path
30
31
import Distribution.Verbosity (Verbosity )
32
+ import Distribution.Version
31
33
32
34
-- | An action that builds all the extra build sources of a component, i.e. C,
33
35
-- C++, Js, Asm, C-- sources.
@@ -73,7 +75,21 @@ buildCSources
73
75
buildCSources mbMainFile =
74
76
buildExtraSources
75
77
" C Sources"
76
- Internal. componentCcGhcOptions
78
+ ( \ verbosity lbi bi clbi odir filename ->
79
+ (Internal. sourcesGhcOptions verbosity lbi bi clbi odir filename)
80
+ { ghcOptCxxOptions =
81
+ ( case compilerCompatVersion GHC (compiler lbi) of
82
+ Just v
83
+ | v >= mkVersion [8 , 10 ] -> Internal. defaultGhcOptCxxOptions lbi bi
84
+ Just _ -> []
85
+ Nothing -> []
86
+ )
87
+ , ghcOptCcProgram =
88
+ maybeToFlag $
89
+ programPath
90
+ <$> lookupProgram gccProgram (withPrograms lbi)
91
+ }
92
+ )
77
93
( \ c -> do
78
94
let cFiles = cSources (componentBuildInfo c)
79
95
case c of
@@ -86,7 +102,21 @@ buildCSources mbMainFile =
86
102
buildCxxSources mbMainFile =
87
103
buildExtraSources
88
104
" C++ Sources"
89
- Internal. componentCxxGhcOptions
105
+ ( \ verbosity lbi bi clbi odir filename ->
106
+ (Internal. sourcesGhcOptions verbosity lbi bi clbi odir filename)
107
+ { ghcOptCcOptions =
108
+ ( case compilerCompatVersion GHC (compiler lbi) of
109
+ Just v
110
+ | v >= mkVersion [8 , 10 ] -> Internal. defaultGhcOptCcOptions lbi bi
111
+ Just _ -> []
112
+ Nothing -> []
113
+ )
114
+ , ghcOptCcProgram =
115
+ maybeToFlag $
116
+ programPath
117
+ <$> lookupProgram gccProgram (withPrograms lbi)
118
+ }
119
+ )
90
120
( \ c -> do
91
121
let cxxFiles = cxxSources (componentBuildInfo c)
92
122
case c of
@@ -101,7 +131,7 @@ buildJsSources _mbMainFile ghcProg buildTargetDir neededWays = do
101
131
let hasJsSupport = hostArch == JavaScript
102
132
buildExtraSources
103
133
" JS Sources"
104
- Internal. componentJsGhcOptions
134
+ Internal. sourcesGhcOptions
105
135
( \ c ->
106
136
if hasJsSupport
107
137
then -- JS files are C-like with GHC's JS backend: they are
@@ -117,12 +147,12 @@ buildJsSources _mbMainFile ghcProg buildTargetDir neededWays = do
117
147
buildAsmSources _mbMainFile =
118
148
buildExtraSources
119
149
" Assembler Sources"
120
- Internal. componentAsmGhcOptions
150
+ Internal. sourcesGhcOptions
121
151
(asmSources . componentBuildInfo)
122
152
buildCmmSources _mbMainFile =
123
153
buildExtraSources
124
154
" C-- Sources"
125
- Internal. componentCmmGhcOptions
155
+ Internal. sourcesGhcOptions
126
156
(cmmSources . componentBuildInfo)
127
157
128
158
-- | Create 'PreBuildComponentRules' for a given type of extra build sources
@@ -140,9 +170,7 @@ buildExtraSources
140
170
-> GhcOptions
141
171
)
142
172
-- ^ Function to determine the @'GhcOptions'@ for the
143
- -- invocation of GHC when compiling these extra sources (e.g.
144
- -- @'Internal.componentCxxGhcOptions'@,
145
- -- @'Internal.componentCmmGhcOptions'@)
173
+ -- invocation of GHC when compiling these extra sources
146
174
-> (Component -> [SymbolicPath Pkg File ])
147
175
-- ^ View the extra sources of a component, typically from
148
176
-- the build info (e.g. @'asmSources'@, @'cSources'@).
@@ -211,14 +239,12 @@ buildExtraSources
211
239
sharedSrcOpts =
212
240
vanillaSrcOpts
213
241
`mappend` mempty
214
- { ghcOptFPic = toFlag True
215
- , ghcOptDynLinkMode = toFlag GhcDynamicOnly
242
+ { ghcOptDynLinkMode = toFlag GhcDynamicOnly
216
243
}
217
244
profSharedSrcOpts =
218
245
vanillaSrcOpts
219
246
`mappend` mempty
220
247
{ ghcOptProfilingMode = toFlag True
221
- , ghcOptFPic = toFlag True
222
248
, ghcOptDynLinkMode = toFlag GhcDynamicOnly
223
249
}
224
250
-- TODO: Placing all Haskell, C, & C++ objects in a single directory
0 commit comments