@@ -17,9 +17,10 @@ import Distribution.Utils.NubList
17
17
import Distribution.Types.BuildInfo
18
18
import Distribution.Types.Component
19
19
import Distribution.Types.TargetInfo
20
+ import Distribution.Types.Version
20
21
21
22
import Distribution.Simple.Build.Inputs
22
- import Distribution.Simple.GHC.Build.Modules
23
+ import Distribution.Simple.BuildWay
23
24
import Distribution.Simple.GHC.Build.Utils
24
25
import Distribution.Simple.LocalBuildInfo
25
26
import Distribution.Simple.Program.Types
@@ -73,7 +74,15 @@ buildCSources
73
74
buildCSources mbMainFile =
74
75
buildExtraSources
75
76
" C Sources"
76
- Internal. componentCcGhcOptions
77
+ ( \ verbosity lbi bi clbi odir filename ->
78
+ (Internal. sourcesGhcOptions verbosity lbi bi clbi odir filename)
79
+ { -- C++ compiler options: GHC >= 8.10 requires -optcxx, older requires -optc
80
+ -- we want to be able to support cxx-options and cc-options separately
81
+ ghcOptCxxOptions = Internal. separateGhcOptions (mkVersion [8 , 10 ]) (compiler lbi) (Internal. defaultGhcOptCxxOptions lbi bi)
82
+ , -- there are problems with linking with versions lower than 9.4, that's why we need this duplication
83
+ ghcOptCcProgram = Internal. defaultGhcOptCcProgram lbi
84
+ }
85
+ )
77
86
( \ c -> do
78
87
let cFiles = cSources (componentBuildInfo c)
79
88
case c of
@@ -86,7 +95,15 @@ buildCSources mbMainFile =
86
95
buildCxxSources mbMainFile =
87
96
buildExtraSources
88
97
" C++ Sources"
89
- Internal. componentCxxGhcOptions
98
+ ( \ verbosity lbi bi clbi odir filename ->
99
+ (Internal. sourcesGhcOptions verbosity lbi bi clbi odir filename)
100
+ { -- C++ compiler options: GHC >= 8.10 requires -optcxx, older requires -optc
101
+ -- we want to be able to support cxx-options and cc-options separately
102
+ ghcOptCcOptions = Internal. separateGhcOptions (mkVersion [8 , 10 ]) (compiler lbi) (Internal. defaultGhcOptCcOptions lbi bi)
103
+ , -- there are problems with linking with versions lower than 9.4, that's why we need this duplication
104
+ ghcOptCcProgram = Internal. defaultGhcOptCcProgram lbi
105
+ }
106
+ )
90
107
( \ c -> do
91
108
let cxxFiles = cxxSources (componentBuildInfo c)
92
109
case c of
@@ -101,7 +118,7 @@ buildJsSources _mbMainFile ghcProg buildTargetDir neededWays = do
101
118
let hasJsSupport = hostArch == JavaScript
102
119
buildExtraSources
103
120
" JS Sources"
104
- Internal. componentJsGhcOptions
121
+ Internal. sourcesGhcOptions
105
122
( \ c ->
106
123
if hasJsSupport
107
124
then -- JS files are C-like with GHC's JS backend: they are
@@ -117,12 +134,12 @@ buildJsSources _mbMainFile ghcProg buildTargetDir neededWays = do
117
134
buildAsmSources _mbMainFile =
118
135
buildExtraSources
119
136
" Assembler Sources"
120
- Internal. componentAsmGhcOptions
137
+ Internal. sourcesGhcOptions
121
138
(asmSources . componentBuildInfo)
122
139
buildCmmSources _mbMainFile =
123
140
buildExtraSources
124
141
" C-- Sources"
125
- Internal. componentCmmGhcOptions
142
+ Internal. sourcesGhcOptions
126
143
(cmmSources . componentBuildInfo)
127
144
128
145
-- | Create 'PreBuildComponentRules' for a given type of extra build sources
@@ -140,9 +157,7 @@ buildExtraSources
140
157
-> GhcOptions
141
158
)
142
159
-- ^ Function to determine the @'GhcOptions'@ for the
143
- -- invocation of GHC when compiling these extra sources (e.g.
144
- -- @'Internal.componentCxxGhcOptions'@,
145
- -- @'Internal.componentCmmGhcOptions'@)
160
+ -- invocation of GHC when compiling these extra sources
146
161
-> (Component -> [SymbolicPath Pkg File ])
147
162
-- ^ View the extra sources of a component, typically from
148
163
-- the build info (e.g. @'asmSources'@, @'cSources'@).
@@ -211,14 +226,12 @@ buildExtraSources
211
226
sharedSrcOpts =
212
227
vanillaSrcOpts
213
228
`mappend` mempty
214
- { ghcOptFPic = toFlag True
215
- , ghcOptDynLinkMode = toFlag GhcDynamicOnly
229
+ { ghcOptDynLinkMode = toFlag GhcDynamicOnly
216
230
}
217
231
profSharedSrcOpts =
218
232
vanillaSrcOpts
219
233
`mappend` mempty
220
234
{ ghcOptProfilingMode = toFlag True
221
- , ghcOptFPic = toFlag True
222
235
, ghcOptDynLinkMode = toFlag GhcDynamicOnly
223
236
}
224
237
-- TODO: Placing all Haskell, C, & C++ objects in a single directory
0 commit comments