@@ -22,12 +22,14 @@ import Distribution.Simple.Build.Inputs
2222import  Distribution.Simple.GHC.Build.Modules 
2323import  Distribution.Simple.GHC.Build.Utils 
2424import  Distribution.Simple.LocalBuildInfo 
25- import  Distribution.Simple.Program.Types  
25+ import  Distribution.Simple.Program 
2626import  Distribution.Simple.Setup.Common  (commonSetupTempFileOptions )
2727import  Distribution.System  (Arch  (JavaScript ), Platform  (.. ))
2828import  Distribution.Types.ComponentLocalBuildInfo 
2929import  Distribution.Utils.Path 
3030import  Distribution.Verbosity  (Verbosity )
31+ import  Distribution.Version 
32+ import  Distribution.Simple.Compiler 
3133
3234--  |  An action that builds all the extra build sources of a component, i.e. C, 
3335--  C++, Js, Asm, C-- sources. 
@@ -73,7 +75,7 @@ buildCSources
7375buildCSources mbMainFile = 
7476  buildExtraSources
7577    " C Sources" 
76-     Internal. componentCcGhcOptions 
78+     Internal. sourcesGhcOptions 
7779    ( \ c ->  do 
7880        let  cFiles =  cSources (componentBuildInfo c)
7981        case  c of 
@@ -86,7 +88,16 @@ buildCSources mbMainFile =
8688buildCxxSources mbMainFile = 
8789  buildExtraSources
8890    " C++ Sources" 
89-     Internal. componentCxxGhcOptions
91+     ( \ verbosity lbi bi clbi odir filename -> 
92+         (Internal. sourcesGhcOptions verbosity lbi bi clbi odir filename)
93+           { ghcOptCcOptions =  (case  compilerCompatVersion GHC  (compiler lbi) of 
94+                 Just  v
95+                   |  v >=  mkVersion [8 , 10 ] ->  Internal. defaultGhcOptCcOptions lbi bi
96+                 Just  _ ->  [] 
97+                 Nothing  ->  [] 
98+              )
99+           }
100+     )
90101    ( \ c ->  do 
91102        let  cxxFiles =  cxxSources (componentBuildInfo c)
92103        case  c of 
@@ -101,7 +112,7 @@ buildJsSources _mbMainFile ghcProg buildTargetDir neededWays = do
101112  let  hasJsSupport =  hostArch ==  JavaScript 
102113  buildExtraSources
103114    " JS Sources" 
104-     Internal. componentJsGhcOptions 
115+     Internal. sourcesGhcOptions 
105116    ( \ c -> 
106117        if  hasJsSupport
107118          then  --  JS files are C-like with GHC's JS backend: they are
@@ -117,12 +128,12 @@ buildJsSources _mbMainFile ghcProg buildTargetDir neededWays = do
117128buildAsmSources _mbMainFile = 
118129  buildExtraSources
119130    " Assembler Sources" 
120-     Internal. componentAsmGhcOptions 
131+     Internal. sourcesGhcOptions 
121132    (asmSources .  componentBuildInfo)
122133buildCmmSources _mbMainFile = 
123134  buildExtraSources
124135    " C-- Sources" 
125-     Internal. componentCmmGhcOptions 
136+     Internal. sourcesGhcOptions 
126137    (cmmSources .  componentBuildInfo)
127138
128139--  |  Create 'PreBuildComponentRules' for a given type of extra build sources 
@@ -140,9 +151,7 @@ buildExtraSources
140151       ->  GhcOptions 
141152     )
142153  --  ^  Function to determine the @'GhcOptions'@ for the 
143-   --  invocation of GHC when compiling these extra sources (e.g.
144-   --  @'Internal.componentCxxGhcOptions'@,
145-   --  @'Internal.componentCmmGhcOptions'@)
154+   --  invocation of GHC when compiling these extra sources
146155  ->  (Component  ->  [SymbolicPath  Pkg  File ])
147156  --  ^  View the extra sources of a component, typically from 
148157  --  the build info (e.g. @'asmSources'@, @'cSources'@).
@@ -211,14 +220,12 @@ buildExtraSources
211220              sharedSrcOpts = 
212221                vanillaSrcOpts
213222                  `mappend`  mempty 
214-                     { ghcOptFPic =  toFlag True 
215-                     , ghcOptDynLinkMode =  toFlag GhcDynamicOnly 
223+                     { ghcOptDynLinkMode =  toFlag GhcDynamicOnly 
216224                    }
217225              profSharedSrcOpts = 
218226                vanillaSrcOpts
219227                  `mappend`  mempty 
220228                    { ghcOptProfilingMode =  toFlag True 
221-                     , ghcOptFPic =  toFlag True 
222229                    , ghcOptDynLinkMode =  toFlag GhcDynamicOnly 
223230                    }
224231              --  TODO: Placing all Haskell, C, & C++ objects in a single directory
0 commit comments