Skip to content

Commit 879010c

Browse files
committed
Merging all resource flags.
All resource options now use base options. Add test for FFI/ForeignOptsCapi. Update test ShowBuildInfo/Complex.
1 parent 824735d commit 879010c

File tree

15 files changed

+160
-202
lines changed

15 files changed

+160
-202
lines changed

Cabal/src/Distribution/Simple/GHC.hs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ module Distribution.Simple.GHC
5858
, hcPkgInfo
5959
, registerPackage
6060
, Internal.componentGhcOptions
61-
, Internal.componentCcGhcOptions
6261
, getGhcAppDir
6362
, getLibDir
6463
, compilerBuildWay
@@ -744,7 +743,7 @@ libAbiHash verbosity _pkg_descr lbi lib clbi = do
744743
, ghcOptFPic = toFlag True
745744
, ghcOptHiSuffix = toFlag "dyn_hi"
746745
, ghcOptObjSuffix = toFlag "dyn_o"
747-
, ghcOptExtra = hcOptions GHC libBi ++ hcSharedOptions GHC libBi
746+
, ghcOptExtra = hcSharedOptions GHC libBi
748747
}
749748
profArgs =
750749
vanillaArgs
@@ -756,7 +755,7 @@ libAbiHash verbosity _pkg_descr lbi lib clbi = do
756755
(withProfLibDetail lbi)
757756
, ghcOptHiSuffix = toFlag "p_hi"
758757
, ghcOptObjSuffix = toFlag "p_o"
759-
, ghcOptExtra = hcOptions GHC libBi ++ hcProfOptions GHC libBi
758+
, ghcOptExtra = hcProfOptions GHC libBi
760759
}
761760
profDynArgs =
762761
vanillaArgs
@@ -770,7 +769,7 @@ libAbiHash verbosity _pkg_descr lbi lib clbi = do
770769
, ghcOptFPic = toFlag True
771770
, ghcOptHiSuffix = toFlag "p_dyn_hi"
772771
, ghcOptObjSuffix = toFlag "p_dyn_o"
773-
, ghcOptExtra = hcOptions GHC libBi ++ hcProfSharedOptions GHC libBi
772+
, ghcOptExtra = hcProfSharedOptions GHC libBi
774773
}
775774
ghcArgs =
776775
let (libWays, _, _) = buildWays lbi

Cabal/src/Distribution/Simple/GHC/Build/ExtraSources.hs

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,17 @@ import Distribution.Types.Component
1919
import Distribution.Types.TargetInfo
2020

2121
import Distribution.Simple.Build.Inputs
22+
import Distribution.Simple.Compiler
2223
import Distribution.Simple.GHC.Build.Modules
2324
import Distribution.Simple.GHC.Build.Utils
2425
import Distribution.Simple.LocalBuildInfo
25-
import Distribution.Simple.Program.Types
26+
import Distribution.Simple.Program
2627
import Distribution.Simple.Setup.Common (commonSetupTempFileOptions)
2728
import Distribution.System (Arch (JavaScript), Platform (..))
2829
import Distribution.Types.ComponentLocalBuildInfo
2930
import Distribution.Utils.Path
3031
import Distribution.Verbosity (Verbosity)
32+
import Distribution.Version
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,21 @@ buildCSources
7375
buildCSources mbMainFile =
7476
buildExtraSources
7577
"C Sources"
76-
Internal.componentCcGhcOptions
78+
( \verbosity lbi bi clbi odir filename ->
79+
(Internal.sourcesGhcOptions verbosity lbi bi clbi odir filename)
80+
{ ghcOptCxxOptions =
81+
( case compilerCompatVersion GHC (compiler lbi) of
82+
Just v
83+
| v >= mkVersion [8, 10] -> Internal.defaultGhcOptCxxOptions lbi bi
84+
Just _ -> []
85+
Nothing -> []
86+
)
87+
, ghcOptCcProgram =
88+
maybeToFlag $
89+
programPath
90+
<$> lookupProgram gccProgram (withPrograms lbi)
91+
}
92+
)
7793
( \c -> do
7894
let cFiles = cSources (componentBuildInfo c)
7995
case c of
@@ -86,7 +102,21 @@ buildCSources mbMainFile =
86102
buildCxxSources mbMainFile =
87103
buildExtraSources
88104
"C++ Sources"
89-
Internal.componentCxxGhcOptions
105+
( \verbosity lbi bi clbi odir filename ->
106+
(Internal.sourcesGhcOptions verbosity lbi bi clbi odir filename)
107+
{ ghcOptCcOptions =
108+
( case compilerCompatVersion GHC (compiler lbi) of
109+
Just v
110+
| v >= mkVersion [8, 10] -> Internal.defaultGhcOptCcOptions lbi bi
111+
Just _ -> []
112+
Nothing -> []
113+
)
114+
, ghcOptCcProgram =
115+
maybeToFlag $
116+
programPath
117+
<$> lookupProgram gccProgram (withPrograms lbi)
118+
}
119+
)
90120
( \c -> do
91121
let cxxFiles = cxxSources (componentBuildInfo c)
92122
case c of
@@ -101,7 +131,7 @@ buildJsSources _mbMainFile ghcProg buildTargetDir neededWays = do
101131
let hasJsSupport = hostArch == JavaScript
102132
buildExtraSources
103133
"JS Sources"
104-
Internal.componentJsGhcOptions
134+
Internal.sourcesGhcOptions
105135
( \c ->
106136
if hasJsSupport
107137
then -- JS files are C-like with GHC's JS backend: they are
@@ -117,12 +147,12 @@ buildJsSources _mbMainFile ghcProg buildTargetDir neededWays = do
117147
buildAsmSources _mbMainFile =
118148
buildExtraSources
119149
"Assembler Sources"
120-
Internal.componentAsmGhcOptions
150+
Internal.sourcesGhcOptions
121151
(asmSources . componentBuildInfo)
122152
buildCmmSources _mbMainFile =
123153
buildExtraSources
124154
"C-- Sources"
125-
Internal.componentCmmGhcOptions
155+
Internal.sourcesGhcOptions
126156
(cmmSources . componentBuildInfo)
127157

128158
-- | Create 'PreBuildComponentRules' for a given type of extra build sources
@@ -140,9 +170,7 @@ buildExtraSources
140170
-> GhcOptions
141171
)
142172
-- ^ Function to determine the @'GhcOptions'@ for the
143-
-- invocation of GHC when compiling these extra sources (e.g.
144-
-- @'Internal.componentCxxGhcOptions'@,
145-
-- @'Internal.componentCmmGhcOptions'@)
173+
-- invocation of GHC when compiling these extra sources
146174
-> (Component -> [SymbolicPath Pkg File])
147175
-- ^ View the extra sources of a component, typically from
148176
-- the build info (e.g. @'asmSources'@, @'cSources'@).
@@ -211,14 +239,12 @@ buildExtraSources
211239
sharedSrcOpts =
212240
vanillaSrcOpts
213241
`mappend` mempty
214-
{ ghcOptFPic = toFlag True
215-
, ghcOptDynLinkMode = toFlag GhcDynamicOnly
242+
{ ghcOptDynLinkMode = toFlag GhcDynamicOnly
216243
}
217244
profSharedSrcOpts =
218245
vanillaSrcOpts
219246
`mappend` mempty
220247
{ ghcOptProfilingMode = toFlag True
221-
, ghcOptFPic = toFlag True
222248
, ghcOptDynLinkMode = toFlag GhcDynamicOnly
223249
}
224250
-- TODO: Placing all Haskell, C, & C++ objects in a single directory

Cabal/src/Distribution/Simple/GHC/Build/Link.hs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,9 @@ linkOrLoadComponent
118118
linkerOpts rpaths =
119119
mempty
120120
{ ghcOptLinkOptions =
121-
PD.ldOptions bi
122-
++ [ "-static"
123-
| withFullyStaticExe lbi
124-
]
121+
[ "-static"
122+
| withFullyStaticExe lbi
123+
]
125124
-- Pass extra `ld-options` given
126125
-- through to GHC's linker.
127126
++ maybe

0 commit comments

Comments
 (0)