@@ -19,10 +19,11 @@ import Distribution.Types.Component
19
19
import Distribution.Types.TargetInfo
20
20
21
21
import Distribution.Simple.Build.Inputs
22
+ import Distribution.Simple.BuildPaths
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
@@ -73,7 +74,16 @@ buildCSources
73
74
buildCSources mbMainFile =
74
75
buildExtraSources
75
76
" C Sources"
76
- Internal. componentCcGhcOptions
77
+ ( \ verbosity lbi bi clbi odir filename ->
78
+ Internal. commonAdditionalGhcOptions verbosity lbi bi clbi odir filename
79
+ <> mempty
80
+ { ghcOptCcOptions = Internal. optimizationCFLags lbi ++ ccOptions bi
81
+ , ghcOptCcProgram =
82
+ maybeToFlag $
83
+ programPath
84
+ <$> lookupProgram gccProgram (withPrograms lbi)
85
+ }
86
+ )
77
87
( \ c -> do
78
88
let cFiles = cSources (componentBuildInfo c)
79
89
case c of
@@ -86,7 +96,16 @@ buildCSources mbMainFile =
86
96
buildCxxSources mbMainFile =
87
97
buildExtraSources
88
98
" C++ Sources"
89
- Internal. componentCxxGhcOptions
99
+ ( \ verbosity lbi bi clbi odir filename ->
100
+ Internal. commonAdditionalGhcOptions verbosity lbi bi clbi odir filename
101
+ <> mempty
102
+ { ghcOptCxxOptions = Internal. optimizationCFLags lbi ++ cxxOptions bi
103
+ , ghcOptCcProgram =
104
+ maybeToFlag $
105
+ programPath
106
+ <$> lookupProgram gccProgram (withPrograms lbi)
107
+ }
108
+ )
90
109
( \ c -> do
91
110
let cxxFiles = cxxSources (componentBuildInfo c)
92
111
case c of
@@ -101,7 +120,12 @@ buildJsSources _mbMainFile ghcProg buildTargetDir neededWays = do
101
120
let hasJsSupport = hostArch == JavaScript
102
121
buildExtraSources
103
122
" JS Sources"
104
- Internal. componentJsGhcOptions
123
+ ( \ verbosity lbi bi clbi odir filename ->
124
+ Internal. commonAdditionalGhcOptions verbosity lbi bi clbi odir filename
125
+ <> mempty
126
+ { ghcOptJSppOptions = jsppOptions bi
127
+ }
128
+ )
105
129
( \ c ->
106
130
if hasJsSupport
107
131
then -- JS files are C-like with GHC's JS backend: they are
@@ -117,12 +141,26 @@ buildJsSources _mbMainFile ghcProg buildTargetDir neededWays = do
117
141
buildAsmSources _mbMainFile =
118
142
buildExtraSources
119
143
" Assembler Sources"
120
- Internal. componentAsmGhcOptions
144
+ ( \ verbosity lbi bi clbi odir filename ->
145
+ Internal. commonAdditionalGhcOptions verbosity lbi bi clbi odir filename
146
+ <> mempty
147
+ { ghcOptAsmOptions = Internal. optimizationCFLags lbi ++ asmOptions bi
148
+ }
149
+ )
121
150
(asmSources . componentBuildInfo)
122
151
buildCmmSources _mbMainFile =
123
152
buildExtraSources
124
153
" C-- Sources"
125
- Internal. componentCmmGhcOptions
154
+ ( \ verbosity lbi bi clbi odir filename ->
155
+ Internal. commonAdditionalGhcOptions verbosity lbi bi clbi odir filename
156
+ <> mempty
157
+ { ghcOptCppOptions = cppOptions bi
158
+ , ghcOptCppIncludes =
159
+ toNubListR $
160
+ [autogenComponentModulesDir lbi clbi </> makeRelativePathEx cppHeaderName]
161
+ , ghcOptExtra = cmmOptions bi
162
+ }
163
+ )
126
164
(cmmSources . componentBuildInfo)
127
165
128
166
-- | Create 'PreBuildComponentRules' for a given type of extra build sources
@@ -140,9 +178,7 @@ buildExtraSources
140
178
-> GhcOptions
141
179
)
142
180
-- ^ Function to determine the @'GhcOptions'@ for the
143
- -- invocation of GHC when compiling these extra sources (e.g.
144
- -- @'Internal.componentCxxGhcOptions'@,
145
- -- @'Internal.componentCmmGhcOptions'@)
181
+ -- invocation of GHC when compiling these extra sources
146
182
-> (Component -> [SymbolicPath Pkg File ])
147
183
-- ^ View the extra sources of a component, typically from
148
184
-- the build info (e.g. @'asmSources'@, @'cSources'@).
@@ -211,14 +247,12 @@ buildExtraSources
211
247
sharedSrcOpts =
212
248
vanillaSrcOpts
213
249
`mappend` mempty
214
- { ghcOptFPic = toFlag True
215
- , ghcOptDynLinkMode = toFlag GhcDynamicOnly
250
+ { ghcOptDynLinkMode = toFlag GhcDynamicOnly
216
251
}
217
252
profSharedSrcOpts =
218
253
vanillaSrcOpts
219
254
`mappend` mempty
220
255
{ ghcOptProfilingMode = toFlag True
221
- , ghcOptFPic = toFlag True
222
256
, ghcOptDynLinkMode = toFlag GhcDynamicOnly
223
257
}
224
258
-- TODO: Placing all Haskell, C, & C++ objects in a single directory
0 commit comments