Skip to content

Commit 016e3ef

Browse files
committed
Merging all resource flags.
All resource options now use base options. Add test for FFI/ForeignOptsCapi. Update test ShowBuildInfo/Complex. Add ghcOptCcProgram to componentGhcOptions.
1 parent 824735d commit 016e3ef

File tree

18 files changed

+348
-284
lines changed

18 files changed

+348
-284
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: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import Distribution.Simple.Build.Inputs
2222
import Distribution.Simple.GHC.Build.Modules
2323
import Distribution.Simple.GHC.Build.Utils
2424
import Distribution.Simple.LocalBuildInfo
25-
import Distribution.Simple.Program.Types
25+
import Distribution.Simple.Program
2626
import Distribution.Simple.Setup.Common (commonSetupTempFileOptions)
2727
import Distribution.System (Arch (JavaScript), Platform (..))
2828
import Distribution.Types.ComponentLocalBuildInfo
@@ -73,7 +73,11 @@ buildCSources
7373
buildCSources mbMainFile =
7474
buildExtraSources
7575
"C Sources"
76-
Internal.componentCcGhcOptions
76+
( \verbosity lbi bi clbi odir filename ->
77+
(Internal.sourcesGhcOptions verbosity lbi bi clbi odir filename)
78+
{ ghcOptCxxOptions = Internal.separateGhcOptions (compiler lbi) (Internal.defaultGhcOptCxxOptions lbi bi)
79+
}
80+
)
7781
( \c -> do
7882
let cFiles = cSources (componentBuildInfo c)
7983
case c of
@@ -86,7 +90,11 @@ buildCSources mbMainFile =
8690
buildCxxSources mbMainFile =
8791
buildExtraSources
8892
"C++ Sources"
89-
Internal.componentCxxGhcOptions
93+
( \verbosity lbi bi clbi odir filename ->
94+
(Internal.sourcesGhcOptions verbosity lbi bi clbi odir filename)
95+
{ ghcOptCcOptions = Internal.separateGhcOptions (compiler lbi) (Internal.defaultGhcOptCcOptions lbi bi)
96+
}
97+
)
9098
( \c -> do
9199
let cxxFiles = cxxSources (componentBuildInfo c)
92100
case c of
@@ -101,7 +109,7 @@ buildJsSources _mbMainFile ghcProg buildTargetDir neededWays = do
101109
let hasJsSupport = hostArch == JavaScript
102110
buildExtraSources
103111
"JS Sources"
104-
Internal.componentJsGhcOptions
112+
Internal.sourcesGhcOptions
105113
( \c ->
106114
if hasJsSupport
107115
then -- JS files are C-like with GHC's JS backend: they are
@@ -117,12 +125,12 @@ buildJsSources _mbMainFile ghcProg buildTargetDir neededWays = do
117125
buildAsmSources _mbMainFile =
118126
buildExtraSources
119127
"Assembler Sources"
120-
Internal.componentAsmGhcOptions
128+
Internal.sourcesGhcOptions
121129
(asmSources . componentBuildInfo)
122130
buildCmmSources _mbMainFile =
123131
buildExtraSources
124132
"C-- Sources"
125-
Internal.componentCmmGhcOptions
133+
Internal.sourcesGhcOptions
126134
(cmmSources . componentBuildInfo)
127135

128136
-- | Create 'PreBuildComponentRules' for a given type of extra build sources
@@ -140,9 +148,7 @@ buildExtraSources
140148
-> GhcOptions
141149
)
142150
-- ^ Function to determine the @'GhcOptions'@ for the
143-
-- invocation of GHC when compiling these extra sources (e.g.
144-
-- @'Internal.componentCxxGhcOptions'@,
145-
-- @'Internal.componentCmmGhcOptions'@)
151+
-- invocation of GHC when compiling these extra sources
146152
-> (Component -> [SymbolicPath Pkg File])
147153
-- ^ View the extra sources of a component, typically from
148154
-- the build info (e.g. @'asmSources'@, @'cSources'@).
@@ -211,14 +217,12 @@ buildExtraSources
211217
sharedSrcOpts =
212218
vanillaSrcOpts
213219
`mappend` mempty
214-
{ ghcOptFPic = toFlag True
215-
, ghcOptDynLinkMode = toFlag GhcDynamicOnly
220+
{ ghcOptDynLinkMode = toFlag GhcDynamicOnly
216221
}
217222
profSharedSrcOpts =
218223
vanillaSrcOpts
219224
`mappend` mempty
220225
{ ghcOptProfilingMode = toFlag True
221-
, ghcOptFPic = toFlag True
222226
, ghcOptDynLinkMode = toFlag GhcDynamicOnly
223227
}
224228
-- TODO: Placing all Haskell, C, & C++ objects in a single directory

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

Lines changed: 12 additions & 36 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
@@ -341,44 +340,20 @@ linkLibrary buildTargetDir cleanedExtraLibDirs pkg_descr verbosity runGhcProg li
341340
--
342341
-- Right now, instead, we pass the path to each object file.
343342
ghcBaseLinkArgs =
344-
mempty
345-
{ -- TODO: This basically duplicates componentGhcOptions.
346-
-- I think we want to do the same as we do for executables: re-use the
347-
-- base options, and link by module names, not object paths.
348-
ghcOptExtra = hcStaticOptions GHC libBi
349-
, ghcOptHideAllPackages = toFlag True
350-
, ghcOptNoAutoLinkPackages = toFlag True
351-
, ghcOptPackageDBs = withPackageDB lbi
352-
, ghcOptThisUnitId = case clbi of
353-
LibComponentLocalBuildInfo{componentCompatPackageKey = pk} ->
354-
toFlag pk
355-
_ -> mempty
356-
, ghcOptThisComponentId = case clbi of
357-
LibComponentLocalBuildInfo
358-
{ componentInstantiatedWith = insts
359-
} ->
360-
if null insts
361-
then mempty
362-
else toFlag (componentComponentId clbi)
363-
_ -> mempty
364-
, ghcOptInstantiatedWith = case clbi of
365-
LibComponentLocalBuildInfo
366-
{ componentInstantiatedWith = insts
367-
} ->
368-
insts
369-
_ -> []
370-
, ghcOptPackages =
371-
toNubListR $
372-
Internal.mkGhcOptPackages mempty clbi
373-
}
343+
Internal.linkGhcOptions verbosity lbi libBi clbi
344+
<> mempty
345+
{ ghcOptExtra = hcStaticOptions GHC libBi
346+
, ghcOptNoAutoLinkPackages = toFlag True
347+
}
374348

375349
-- After the relocation lib is created we invoke ghc -shared
376350
-- with the dependencies spelled out as -package arguments
377351
-- and ghc invokes the linker with the proper library paths
378352
ghcSharedLinkArgs :: [SymbolicPath Pkg File] -> GhcOptions
379353
ghcSharedLinkArgs dynObjectFiles =
380354
ghcBaseLinkArgs
381-
{ ghcOptShared = toFlag True
355+
{ ghcOptFPic = toFlag True
356+
, ghcOptShared = toFlag True
382357
, ghcOptDynLinkMode = toFlag GhcDynamicOnly
383358
, ghcOptInputFiles = toNubListR $ map coerceSymbolicPath dynObjectFiles
384359
, ghcOptOutputFile = toFlag sharedLibFilePath
@@ -399,7 +374,8 @@ linkLibrary buildTargetDir cleanedExtraLibDirs pkg_descr verbosity runGhcProg li
399374
}
400375
ghcProfSharedLinkArgs pdynObjectFiles =
401376
ghcBaseLinkArgs
402-
{ ghcOptShared = toFlag True
377+
{ ghcOptFPic = toFlag True
378+
, ghcOptShared = toFlag True
403379
, ghcOptProfilingMode = toFlag True
404380
, ghcOptProfilingAuto =
405381
Internal.profDetailLevelFlag

0 commit comments

Comments
 (0)