@@ -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,7 @@ buildCSources
73
75
buildCSources mbMainFile =
74
76
buildExtraSources
75
77
" C Sources"
76
- Internal. componentCcGhcOptions
78
+ Internal. sourcesGhcOptions
77
79
( \ c -> do
78
80
let cFiles = cSources (componentBuildInfo c)
79
81
case c of
@@ -86,7 +88,17 @@ buildCSources mbMainFile =
86
88
buildCxxSources mbMainFile =
87
89
buildExtraSources
88
90
" C++ Sources"
89
- Internal. componentCxxGhcOptions
91
+ ( \ verbosity lbi bi clbi odir filename ->
92
+ (Internal. sourcesGhcOptions verbosity lbi bi clbi odir filename)
93
+ { ghcOptCcOptions =
94
+ ( case compilerCompatVersion GHC (compiler lbi) of
95
+ Just v
96
+ | v >= mkVersion [8 , 10 ] -> Internal. defaultGhcOptCcOptions lbi bi
97
+ Just _ -> []
98
+ Nothing -> []
99
+ )
100
+ }
101
+ )
90
102
( \ c -> do
91
103
let cxxFiles = cxxSources (componentBuildInfo c)
92
104
case c of
@@ -101,7 +113,7 @@ buildJsSources _mbMainFile ghcProg buildTargetDir neededWays = do
101
113
let hasJsSupport = hostArch == JavaScript
102
114
buildExtraSources
103
115
" JS Sources"
104
- Internal. componentJsGhcOptions
116
+ Internal. sourcesGhcOptions
105
117
( \ c ->
106
118
if hasJsSupport
107
119
then -- JS files are C-like with GHC's JS backend: they are
@@ -117,12 +129,12 @@ buildJsSources _mbMainFile ghcProg buildTargetDir neededWays = do
117
129
buildAsmSources _mbMainFile =
118
130
buildExtraSources
119
131
" Assembler Sources"
120
- Internal. componentAsmGhcOptions
132
+ Internal. sourcesGhcOptions
121
133
(asmSources . componentBuildInfo)
122
134
buildCmmSources _mbMainFile =
123
135
buildExtraSources
124
136
" C-- Sources"
125
- Internal. componentCmmGhcOptions
137
+ Internal. sourcesGhcOptions
126
138
(cmmSources . componentBuildInfo)
127
139
128
140
-- | Create 'PreBuildComponentRules' for a given type of extra build sources
@@ -140,9 +152,7 @@ buildExtraSources
140
152
-> GhcOptions
141
153
)
142
154
-- ^ Function to determine the @'GhcOptions'@ for the
143
- -- invocation of GHC when compiling these extra sources (e.g.
144
- -- @'Internal.componentCxxGhcOptions'@,
145
- -- @'Internal.componentCmmGhcOptions'@)
155
+ -- invocation of GHC when compiling these extra sources
146
156
-> (Component -> [SymbolicPath Pkg File ])
147
157
-- ^ View the extra sources of a component, typically from
148
158
-- the build info (e.g. @'asmSources'@, @'cSources'@).
@@ -211,14 +221,12 @@ buildExtraSources
211
221
sharedSrcOpts =
212
222
vanillaSrcOpts
213
223
`mappend` mempty
214
- { ghcOptFPic = toFlag True
215
- , ghcOptDynLinkMode = toFlag GhcDynamicOnly
224
+ { ghcOptDynLinkMode = toFlag GhcDynamicOnly
216
225
}
217
226
profSharedSrcOpts =
218
227
vanillaSrcOpts
219
228
`mappend` mempty
220
229
{ ghcOptProfilingMode = toFlag True
221
- , ghcOptFPic = toFlag True
222
230
, ghcOptDynLinkMode = toFlag GhcDynamicOnly
223
231
}
224
232
-- TODO: Placing all Haskell, C, & C++ objects in a single directory
0 commit comments