@@ -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,23 @@ 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
+ -- https://gitlab.haskell.org/ghc/ghc/-/issues/16477
82
+ -- see example in cabal-testsuite/PackageTests/FFI/ForeignOptsC
83
+ ghcOptCxxOptions =
84
+ Internal. separateGhcOptions
85
+ (mkVersion [8 , 10 ])
86
+ (compiler lbi)
87
+ (Internal. defaultGhcOptCxxOptions lbi bi)
88
+ , -- there are problems with linking with versions below 9.4,
89
+ -- that's why we need this replacement for linkGhcOptions
90
+ -- see example in cabal-testsuite/PackageTests/ShowBuildInfo/Complex
91
+ ghcOptCcProgram = Internal. defaultGhcOptCcProgram lbi
92
+ }
93
+ )
77
94
( \ c -> do
78
95
let cFiles = cSources (componentBuildInfo c)
79
96
case c of
@@ -86,7 +103,23 @@ buildCSources mbMainFile =
86
103
buildCxxSources mbMainFile =
87
104
buildExtraSources
88
105
" C++ Sources"
89
- Internal. componentCxxGhcOptions
106
+ ( \ verbosity lbi bi clbi odir filename ->
107
+ (Internal. sourcesGhcOptions verbosity lbi bi clbi odir filename)
108
+ { -- C++ compiler options: GHC >= 8.10 requires -optcxx, older requires -optc
109
+ -- we want to be able to support cxx-options and cc-options separately
110
+ -- https://gitlab.haskell.org/ghc/ghc/-/issues/16477
111
+ -- see example in cabal-testsuite/PackageTests/FFI/ForeignOptsCxx
112
+ ghcOptCcOptions =
113
+ Internal. separateGhcOptions
114
+ (mkVersion [8 , 10 ])
115
+ (compiler lbi)
116
+ (Internal. defaultGhcOptCcOptions lbi bi)
117
+ , -- there are problems with linking with versions below 9.4,
118
+ -- that's why we need this replacement for linkGhcOptions
119
+ -- see example in cabal-testsuite/PackageTests/ShowBuildInfo/Complex
120
+ ghcOptCcProgram = Internal. defaultGhcOptCcProgram lbi
121
+ }
122
+ )
90
123
( \ c -> do
91
124
let cxxFiles = cxxSources (componentBuildInfo c)
92
125
case c of
@@ -101,7 +134,7 @@ buildJsSources _mbMainFile ghcProg buildTargetDir neededWays = do
101
134
let hasJsSupport = hostArch == JavaScript
102
135
buildExtraSources
103
136
" JS Sources"
104
- Internal. componentJsGhcOptions
137
+ Internal. sourcesGhcOptions
105
138
( \ c ->
106
139
if hasJsSupport
107
140
then -- JS files are C-like with GHC's JS backend: they are
@@ -117,12 +150,12 @@ buildJsSources _mbMainFile ghcProg buildTargetDir neededWays = do
117
150
buildAsmSources _mbMainFile =
118
151
buildExtraSources
119
152
" Assembler Sources"
120
- Internal. componentAsmGhcOptions
153
+ Internal. sourcesGhcOptions
121
154
(asmSources . componentBuildInfo)
122
155
buildCmmSources _mbMainFile =
123
156
buildExtraSources
124
157
" C-- Sources"
125
- Internal. componentCmmGhcOptions
158
+ Internal. sourcesGhcOptions
126
159
(cmmSources . componentBuildInfo)
127
160
128
161
-- | Create 'PreBuildComponentRules' for a given type of extra build sources
@@ -140,9 +173,7 @@ buildExtraSources
140
173
-> GhcOptions
141
174
)
142
175
-- ^ Function to determine the @'GhcOptions'@ for the
143
- -- invocation of GHC when compiling these extra sources (e.g.
144
- -- @'Internal.componentCxxGhcOptions'@,
145
- -- @'Internal.componentCmmGhcOptions'@)
176
+ -- invocation of GHC when compiling these extra sources
146
177
-> (Component -> [SymbolicPath Pkg File ])
147
178
-- ^ View the extra sources of a component, typically from
148
179
-- the build info (e.g. @'asmSources'@, @'cSources'@).
0 commit comments