@@ -19,10 +19,11 @@ import Distribution.Types.Component
1919import Distribution.Types.TargetInfo
2020
2121import Distribution.Simple.Build.Inputs
22+ import Distribution.Simple.BuildPaths
2223import Distribution.Simple.GHC.Build.Modules
2324import Distribution.Simple.GHC.Build.Utils
2425import Distribution.Simple.LocalBuildInfo
25- import Distribution.Simple.Program.Types
26+ import Distribution.Simple.Program
2627import Distribution.Simple.Setup.Common (commonSetupTempFileOptions )
2728import Distribution.System (Arch (JavaScript ), Platform (.. ))
2829import Distribution.Types.ComponentLocalBuildInfo
@@ -73,7 +74,16 @@ buildCSources
7374buildCSources mbMainFile =
7475 buildExtraSources
7576 " 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+ )
7787 ( \ c -> do
7888 let cFiles = cSources (componentBuildInfo c)
7989 case c of
@@ -86,7 +96,16 @@ buildCSources mbMainFile =
8696buildCxxSources mbMainFile =
8797 buildExtraSources
8898 " 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+ )
90109 ( \ c -> do
91110 let cxxFiles = cxxSources (componentBuildInfo c)
92111 case c of
@@ -101,7 +120,12 @@ buildJsSources _mbMainFile ghcProg buildTargetDir neededWays = do
101120 let hasJsSupport = hostArch == JavaScript
102121 buildExtraSources
103122 " 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+ )
105129 ( \ c ->
106130 if hasJsSupport
107131 then -- JS files are C-like with GHC's JS backend: they are
@@ -117,12 +141,26 @@ buildJsSources _mbMainFile ghcProg buildTargetDir neededWays = do
117141buildAsmSources _mbMainFile =
118142 buildExtraSources
119143 " 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+ )
121150 (asmSources . componentBuildInfo)
122151buildCmmSources _mbMainFile =
123152 buildExtraSources
124153 " 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+ )
126164 (cmmSources . componentBuildInfo)
127165
128166-- | Create 'PreBuildComponentRules' for a given type of extra build sources
@@ -140,9 +178,7 @@ buildExtraSources
140178 -> GhcOptions
141179 )
142180 -- ^ 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
146182 -> (Component -> [SymbolicPath Pkg File ])
147183 -- ^ View the extra sources of a component, typically from
148184 -- the build info (e.g. @'asmSources'@, @'cSources'@).
@@ -211,14 +247,12 @@ buildExtraSources
211247 sharedSrcOpts =
212248 vanillaSrcOpts
213249 `mappend` mempty
214- { ghcOptFPic = toFlag True
215- , ghcOptDynLinkMode = toFlag GhcDynamicOnly
250+ { ghcOptDynLinkMode = toFlag GhcDynamicOnly
216251 }
217252 profSharedSrcOpts =
218253 vanillaSrcOpts
219254 `mappend` mempty
220255 { ghcOptProfilingMode = toFlag True
221- , ghcOptFPic = toFlag True
222256 , ghcOptDynLinkMode = toFlag GhcDynamicOnly
223257 }
224258 -- TODO: Placing all Haskell, C, & C++ objects in a single directory
0 commit comments