diff --git a/Cabal-syntax/src/Distribution/PackageDescription/FieldGrammar.hs b/Cabal-syntax/src/Distribution/PackageDescription/FieldGrammar.hs index db6b7f7607b..a172d24aee7 100644 --- a/Cabal-syntax/src/Distribution/PackageDescription/FieldGrammar.hs +++ b/Cabal-syntax/src/Distribution/PackageDescription/FieldGrammar.hs @@ -673,6 +673,7 @@ buildInfoFieldGrammar = <*> optionsFieldGrammar <*> profOptionsFieldGrammar <*> sharedOptionsFieldGrammar + <*> profSharedOptionsFieldGrammar <*> pure mempty -- static-options ??? <*> prefixedFields "x-" L.customFieldsBI <*> monoidalFieldAla "build-depends" formatDependencyList L.targetBuildDepends @@ -738,6 +739,18 @@ sharedOptionsFieldGrammar = extract :: CompilerFlavor -> ALens' BuildInfo [String] extract flavor = L.sharedOptions . lookupLens flavor +profSharedOptionsFieldGrammar + :: (FieldGrammar c g, Applicative (g BuildInfo), c (List NoCommaFSep Token' String)) + => g BuildInfo (PerCompilerFlavor [String]) +profSharedOptionsFieldGrammar = + PerCompilerFlavor + <$> monoidalFieldAla "ghc-prof-shared-options" (alaList' NoCommaFSep Token') (extract GHC) + <*> monoidalFieldAla "ghcjs-prof-shared-options" (alaList' NoCommaFSep Token') (extract GHCJS) + where + extract :: CompilerFlavor -> ALens' BuildInfo [String] + extract flavor = L.profSharedOptions . lookupLens flavor + + lookupLens :: (Functor f, Monoid v) => CompilerFlavor -> LensLike' f (PerCompilerFlavor v) v lookupLens k f p@(PerCompilerFlavor ghc ghcjs) | k == GHC = (\n -> PerCompilerFlavor n ghcjs) <$> f ghc diff --git a/Cabal-syntax/src/Distribution/Types/BuildInfo.hs b/Cabal-syntax/src/Distribution/Types/BuildInfo.hs index da1f8aea88f..680b9bf49db 100644 --- a/Cabal-syntax/src/Distribution/Types/BuildInfo.hs +++ b/Cabal-syntax/src/Distribution/Types/BuildInfo.hs @@ -12,6 +12,7 @@ module Distribution.Types.BuildInfo , hcOptions , hcProfOptions , hcSharedOptions + , hcProfSharedOptions , hcStaticOptions ) where @@ -133,6 +134,7 @@ data BuildInfo = BuildInfo , options :: PerCompilerFlavor [String] , profOptions :: PerCompilerFlavor [String] , sharedOptions :: PerCompilerFlavor [String] + , profSharedOptions :: PerCompilerFlavor [String] , staticOptions :: PerCompilerFlavor [String] , customFieldsBI :: [(String, String)] -- ^ Custom fields starting @@ -193,6 +195,7 @@ instance Monoid BuildInfo where , options = mempty , profOptions = mempty , sharedOptions = mempty + , profSharedOptions = mempty , staticOptions = mempty , customFieldsBI = [] , targetBuildDepends = [] @@ -245,6 +248,7 @@ instance Semigroup BuildInfo where , options = combine options , profOptions = combine profOptions , sharedOptions = combine sharedOptions + , profSharedOptions = combine profSharedOptions , staticOptions = combine staticOptions , customFieldsBI = combine customFieldsBI , targetBuildDepends = combineNub targetBuildDepends @@ -295,6 +299,9 @@ hcProfOptions = lookupHcOptions profOptions hcSharedOptions :: CompilerFlavor -> BuildInfo -> [String] hcSharedOptions = lookupHcOptions sharedOptions +hcProfSharedOptions :: CompilerFlavor -> BuildInfo -> [String] +hcProfSharedOptions = lookupHcOptions profSharedOptions + hcStaticOptions :: CompilerFlavor -> BuildInfo -> [String] hcStaticOptions = lookupHcOptions staticOptions diff --git a/Cabal-syntax/src/Distribution/Types/BuildInfo/Lens.hs b/Cabal-syntax/src/Distribution/Types/BuildInfo/Lens.hs index 19453a671b9..ac99f3c65a5 100644 --- a/Cabal-syntax/src/Distribution/Types/BuildInfo/Lens.hs +++ b/Cabal-syntax/src/Distribution/Types/BuildInfo/Lens.hs @@ -195,6 +195,10 @@ class HasBuildInfo a where sharedOptions = buildInfo . sharedOptions {-# INLINE sharedOptions #-} + profSharedOptions :: Lens' a (PerCompilerFlavor [String]) + profSharedOptions = buildInfo . profSharedOptions + {-# INLINE profSharedOptions #-} + staticOptions :: Lens' a (PerCompilerFlavor [String]) staticOptions = buildInfo . staticOptions {-# INLINE staticOptions #-} @@ -341,6 +345,9 @@ instance HasBuildInfo BuildInfo where sharedOptions f s = fmap (\x -> s{T.sharedOptions = x}) (f (T.sharedOptions s)) {-# INLINE sharedOptions #-} + profSharedOptions f s = fmap (\x -> s{T.profSharedOptions = x}) (f (T.profSharedOptions s)) + {-# INLINE profSharedOptions #-} + staticOptions f s = fmap (\x -> s{T.staticOptions = x}) (f (T.staticOptions s)) {-# INLINE staticOptions #-} diff --git a/Cabal-tests/tests/ParserTests/regressions/Octree-0.5.expr b/Cabal-tests/tests/ParserTests/regressions/Octree-0.5.expr index 3d03421210b..b3494104aed 100644 --- a/Cabal-tests/tests/ParserTests/regressions/Octree-0.5.expr +++ b/Cabal-tests/tests/ParserTests/regressions/Octree-0.5.expr @@ -132,6 +132,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -238,6 +240,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -339,6 +343,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/anynone.expr b/Cabal-tests/tests/ParserTests/regressions/anynone.expr index 3191425d609..8c9c8879ab4 100644 --- a/Cabal-tests/tests/ParserTests/regressions/anynone.expr +++ b/Cabal-tests/tests/ParserTests/regressions/anynone.expr @@ -95,6 +95,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/big-version.expr b/Cabal-tests/tests/ParserTests/regressions/big-version.expr index e677de20626..d4ef82adf52 100644 --- a/Cabal-tests/tests/ParserTests/regressions/big-version.expr +++ b/Cabal-tests/tests/ParserTests/regressions/big-version.expr @@ -96,6 +96,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/common-conditional.expr b/Cabal-tests/tests/ParserTests/regressions/common-conditional.expr index f6ffe291e59..9cacba2b770 100644 --- a/Cabal-tests/tests/ParserTests/regressions/common-conditional.expr +++ b/Cabal-tests/tests/ParserTests/regressions/common-conditional.expr @@ -112,6 +112,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -187,6 +189,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -278,6 +282,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -356,6 +362,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -432,6 +440,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -501,6 +511,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -593,6 +605,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -670,6 +684,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/common.expr b/Cabal-tests/tests/ParserTests/regressions/common.expr index e0eb4a1dde7..25abadef9e7 100644 --- a/Cabal-tests/tests/ParserTests/regressions/common.expr +++ b/Cabal-tests/tests/ParserTests/regressions/common.expr @@ -110,6 +110,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -186,6 +188,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/common2.expr b/Cabal-tests/tests/ParserTests/regressions/common2.expr index b3cb004eecb..cd501d11cf2 100644 --- a/Cabal-tests/tests/ParserTests/regressions/common2.expr +++ b/Cabal-tests/tests/ParserTests/regressions/common2.expr @@ -106,6 +106,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -205,6 +207,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -285,6 +289,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -386,6 +392,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -462,6 +470,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -562,6 +572,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -639,6 +651,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -716,6 +730,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/common3.expr b/Cabal-tests/tests/ParserTests/regressions/common3.expr index 21b200baa7b..fc1fc155c09 100644 --- a/Cabal-tests/tests/ParserTests/regressions/common3.expr +++ b/Cabal-tests/tests/ParserTests/regressions/common3.expr @@ -110,6 +110,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -186,6 +188,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/elif.expr b/Cabal-tests/tests/ParserTests/regressions/elif.expr index 1315d689467..f17c1e17b88 100644 --- a/Cabal-tests/tests/ParserTests/regressions/elif.expr +++ b/Cabal-tests/tests/ParserTests/regressions/elif.expr @@ -105,6 +105,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -172,6 +174,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/elif2.expr b/Cabal-tests/tests/ParserTests/regressions/elif2.expr index 61f2177cbaa..ec01a92a79d 100644 --- a/Cabal-tests/tests/ParserTests/regressions/elif2.expr +++ b/Cabal-tests/tests/ParserTests/regressions/elif2.expr @@ -105,6 +105,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -172,6 +174,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -245,6 +249,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -312,6 +318,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -385,6 +393,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/encoding-0.8.expr b/Cabal-tests/tests/ParserTests/regressions/encoding-0.8.expr index e1b125e7a32..0d248029a31 100644 --- a/Cabal-tests/tests/ParserTests/regressions/encoding-0.8.expr +++ b/Cabal-tests/tests/ParserTests/regressions/encoding-0.8.expr @@ -114,6 +114,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/generics-sop.expr b/Cabal-tests/tests/ParserTests/regressions/generics-sop.expr index 9084371a614..25786cdfad5 100644 --- a/Cabal-tests/tests/ParserTests/regressions/generics-sop.expr +++ b/Cabal-tests/tests/ParserTests/regressions/generics-sop.expr @@ -242,6 +242,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -373,6 +375,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -457,6 +461,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -561,6 +567,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -631,6 +639,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -702,6 +712,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [ @@ -798,6 +810,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/hasktorch.expr b/Cabal-tests/tests/ParserTests/regressions/hasktorch.expr index 346af927d1b..c68fac467e1 100644 --- a/Cabal-tests/tests/ParserTests/regressions/hasktorch.expr +++ b/Cabal-tests/tests/ParserTests/regressions/hasktorch.expr @@ -322,6 +322,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -642,6 +644,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -884,6 +888,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -1084,6 +1090,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -1438,6 +1446,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -2740,6 +2750,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -2829,6 +2841,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -5072,6 +5086,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -6424,6 +6440,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -6514,6 +6532,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -8182,6 +8202,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -8670,6 +8692,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -9433,6 +9457,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -9554,6 +9580,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -9659,6 +9687,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -9764,6 +9794,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -9858,6 +9890,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -9978,6 +10012,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/hidden-main-lib.expr b/Cabal-tests/tests/ParserTests/regressions/hidden-main-lib.expr index fba99528b53..b51b4adacb2 100644 --- a/Cabal-tests/tests/ParserTests/regressions/hidden-main-lib.expr +++ b/Cabal-tests/tests/ParserTests/regressions/hidden-main-lib.expr @@ -97,6 +97,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/indentation.expr b/Cabal-tests/tests/ParserTests/regressions/indentation.expr index e5b106dc5cd..c97630ddb00 100644 --- a/Cabal-tests/tests/ParserTests/regressions/indentation.expr +++ b/Cabal-tests/tests/ParserTests/regressions/indentation.expr @@ -106,6 +106,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/indentation2.expr b/Cabal-tests/tests/ParserTests/regressions/indentation2.expr index 46f24105f0f..605cba525d1 100644 --- a/Cabal-tests/tests/ParserTests/regressions/indentation2.expr +++ b/Cabal-tests/tests/ParserTests/regressions/indentation2.expr @@ -99,6 +99,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/indentation3.expr b/Cabal-tests/tests/ParserTests/regressions/indentation3.expr index 0191d063f6e..55d0533c3fe 100644 --- a/Cabal-tests/tests/ParserTests/regressions/indentation3.expr +++ b/Cabal-tests/tests/ParserTests/regressions/indentation3.expr @@ -101,6 +101,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/issue-5055.expr b/Cabal-tests/tests/ParserTests/regressions/issue-5055.expr index 07c04ec6cb9..3b5092639e4 100644 --- a/Cabal-tests/tests/ParserTests/regressions/issue-5055.expr +++ b/Cabal-tests/tests/ParserTests/regressions/issue-5055.expr @@ -100,6 +100,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -183,6 +185,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -267,6 +271,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/issue-5846.expr b/Cabal-tests/tests/ParserTests/regressions/issue-5846.expr index 2ff7de7917e..61a7b7d2ca1 100644 --- a/Cabal-tests/tests/ParserTests/regressions/issue-5846.expr +++ b/Cabal-tests/tests/ParserTests/regressions/issue-5846.expr @@ -94,6 +94,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/issue-6083-a.expr b/Cabal-tests/tests/ParserTests/regressions/issue-6083-a.expr index 43c345dd170..c9c57785ac6 100644 --- a/Cabal-tests/tests/ParserTests/regressions/issue-6083-a.expr +++ b/Cabal-tests/tests/ParserTests/regressions/issue-6083-a.expr @@ -94,6 +94,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -189,6 +191,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -255,6 +259,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -335,6 +341,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/issue-6083-b.expr b/Cabal-tests/tests/ParserTests/regressions/issue-6083-b.expr index e6606851627..b0ed19062fc 100644 --- a/Cabal-tests/tests/ParserTests/regressions/issue-6083-b.expr +++ b/Cabal-tests/tests/ParserTests/regressions/issue-6083-b.expr @@ -94,6 +94,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -189,6 +191,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -255,6 +259,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -345,6 +351,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/issue-6083-c.expr b/Cabal-tests/tests/ParserTests/regressions/issue-6083-c.expr index 7435b0d59b4..c901eebc8ce 100644 --- a/Cabal-tests/tests/ParserTests/regressions/issue-6083-c.expr +++ b/Cabal-tests/tests/ParserTests/regressions/issue-6083-c.expr @@ -94,6 +94,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -189,6 +191,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/issue-6083-pkg-pkg.expr b/Cabal-tests/tests/ParserTests/regressions/issue-6083-pkg-pkg.expr index a221632efa4..62ed5fd2fb9 100644 --- a/Cabal-tests/tests/ParserTests/regressions/issue-6083-pkg-pkg.expr +++ b/Cabal-tests/tests/ParserTests/regressions/issue-6083-pkg-pkg.expr @@ -94,6 +94,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/issue-774.expr b/Cabal-tests/tests/ParserTests/regressions/issue-774.expr index e1ffb85dceb..2f58de4eb00 100644 --- a/Cabal-tests/tests/ParserTests/regressions/issue-774.expr +++ b/Cabal-tests/tests/ParserTests/regressions/issue-774.expr @@ -108,6 +108,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/jaeger-flamegraph.expr b/Cabal-tests/tests/ParserTests/regressions/jaeger-flamegraph.expr index c9e675ceb76..9994c9b72c1 100644 --- a/Cabal-tests/tests/ParserTests/regressions/jaeger-flamegraph.expr +++ b/Cabal-tests/tests/ParserTests/regressions/jaeger-flamegraph.expr @@ -139,6 +139,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -238,6 +240,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -403,6 +407,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/leading-comma-2.expr b/Cabal-tests/tests/ParserTests/regressions/leading-comma-2.expr index 0bb5556b2f4..99f7cddf881 100644 --- a/Cabal-tests/tests/ParserTests/regressions/leading-comma-2.expr +++ b/Cabal-tests/tests/ParserTests/regressions/leading-comma-2.expr @@ -104,6 +104,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/leading-comma.expr b/Cabal-tests/tests/ParserTests/regressions/leading-comma.expr index b1ba1b282f4..441fe75261d 100644 --- a/Cabal-tests/tests/ParserTests/regressions/leading-comma.expr +++ b/Cabal-tests/tests/ParserTests/regressions/leading-comma.expr @@ -97,6 +97,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/libpq1.expr b/Cabal-tests/tests/ParserTests/regressions/libpq1.expr index 8906a91f63b..2e0bc309f9f 100644 --- a/Cabal-tests/tests/ParserTests/regressions/libpq1.expr +++ b/Cabal-tests/tests/ParserTests/regressions/libpq1.expr @@ -190,6 +190,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -289,6 +291,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -373,6 +377,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -464,6 +470,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -529,6 +537,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -596,6 +606,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -661,6 +673,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -728,6 +742,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/libpq2.expr b/Cabal-tests/tests/ParserTests/regressions/libpq2.expr index 3c26ece45ad..b74143af0b9 100644 --- a/Cabal-tests/tests/ParserTests/regressions/libpq2.expr +++ b/Cabal-tests/tests/ParserTests/regressions/libpq2.expr @@ -195,6 +195,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -294,6 +296,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -378,6 +382,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -466,6 +472,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -531,6 +539,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -598,6 +608,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -663,6 +675,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -730,6 +744,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/mixin-1.expr b/Cabal-tests/tests/ParserTests/regressions/mixin-1.expr index de8a15f04c0..77821302ddf 100644 --- a/Cabal-tests/tests/ParserTests/regressions/mixin-1.expr +++ b/Cabal-tests/tests/ParserTests/regressions/mixin-1.expr @@ -98,6 +98,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/mixin-2.expr b/Cabal-tests/tests/ParserTests/regressions/mixin-2.expr index 3bf06bc9c3b..d8b58ff5a0b 100644 --- a/Cabal-tests/tests/ParserTests/regressions/mixin-2.expr +++ b/Cabal-tests/tests/ParserTests/regressions/mixin-2.expr @@ -98,6 +98,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/mixin-3.expr b/Cabal-tests/tests/ParserTests/regressions/mixin-3.expr index 0c0fc57a8b8..c0cbfe921ad 100644 --- a/Cabal-tests/tests/ParserTests/regressions/mixin-3.expr +++ b/Cabal-tests/tests/ParserTests/regressions/mixin-3.expr @@ -98,6 +98,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/monad-param.expr b/Cabal-tests/tests/ParserTests/regressions/monad-param.expr index 28d57c1e3b0..e450672e868 100644 --- a/Cabal-tests/tests/ParserTests/regressions/monad-param.expr +++ b/Cabal-tests/tests/ParserTests/regressions/monad-param.expr @@ -120,6 +120,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/multiple-libs-2.expr b/Cabal-tests/tests/ParserTests/regressions/multiple-libs-2.expr index a8c6b0c0c4a..aa7d6954637 100644 --- a/Cabal-tests/tests/ParserTests/regressions/multiple-libs-2.expr +++ b/Cabal-tests/tests/ParserTests/regressions/multiple-libs-2.expr @@ -97,6 +97,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -175,6 +177,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/noVersion.expr b/Cabal-tests/tests/ParserTests/regressions/noVersion.expr index 8187272c2c0..dfe79d768fb 100644 --- a/Cabal-tests/tests/ParserTests/regressions/noVersion.expr +++ b/Cabal-tests/tests/ParserTests/regressions/noVersion.expr @@ -97,6 +97,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/nothing-unicode.expr b/Cabal-tests/tests/ParserTests/regressions/nothing-unicode.expr index 2f2663733c6..2ed17f6d557 100644 --- a/Cabal-tests/tests/ParserTests/regressions/nothing-unicode.expr +++ b/Cabal-tests/tests/ParserTests/regressions/nothing-unicode.expr @@ -112,6 +112,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -179,6 +181,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/shake.expr b/Cabal-tests/tests/ParserTests/regressions/shake.expr index 8dd849d75bd..4dd37e84de0 100644 --- a/Cabal-tests/tests/ParserTests/regressions/shake.expr +++ b/Cabal-tests/tests/ParserTests/regressions/shake.expr @@ -306,6 +306,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -519,6 +521,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -586,6 +590,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -660,6 +666,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -727,6 +735,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -805,6 +815,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -982,6 +994,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -1206,6 +1220,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -1271,6 +1287,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -1335,6 +1353,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -1406,6 +1426,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -1470,6 +1492,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -1545,6 +1569,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -1764,6 +1790,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -1992,6 +2020,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -2061,6 +2091,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -2130,6 +2162,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -2198,6 +2232,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -2273,6 +2309,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -2341,6 +2379,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -2420,6 +2460,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/spdx-1.expr b/Cabal-tests/tests/ParserTests/regressions/spdx-1.expr index 2ca07bf2322..ddeaf37cbe4 100644 --- a/Cabal-tests/tests/ParserTests/regressions/spdx-1.expr +++ b/Cabal-tests/tests/ParserTests/regressions/spdx-1.expr @@ -95,6 +95,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/spdx-2.expr b/Cabal-tests/tests/ParserTests/regressions/spdx-2.expr index 9c50edd4864..b865b1f31db 100644 --- a/Cabal-tests/tests/ParserTests/regressions/spdx-2.expr +++ b/Cabal-tests/tests/ParserTests/regressions/spdx-2.expr @@ -99,6 +99,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/spdx-3.expr b/Cabal-tests/tests/ParserTests/regressions/spdx-3.expr index 944faa4c0c0..dc8f3f922b9 100644 --- a/Cabal-tests/tests/ParserTests/regressions/spdx-3.expr +++ b/Cabal-tests/tests/ParserTests/regressions/spdx-3.expr @@ -99,6 +99,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/th-lift-instances.expr b/Cabal-tests/tests/ParserTests/regressions/th-lift-instances.expr index 8f2edf09a36..5e781597f30 100644 --- a/Cabal-tests/tests/ParserTests/regressions/th-lift-instances.expr +++ b/Cabal-tests/tests/ParserTests/regressions/th-lift-instances.expr @@ -127,6 +127,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -298,6 +300,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -473,6 +477,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -577,6 +583,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/version-sets.expr b/Cabal-tests/tests/ParserTests/regressions/version-sets.expr index b134e4584ad..3244bc1cc45 100644 --- a/Cabal-tests/tests/ParserTests/regressions/version-sets.expr +++ b/Cabal-tests/tests/ParserTests/regressions/version-sets.expr @@ -121,6 +121,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/wl-pprint-indef.expr b/Cabal-tests/tests/ParserTests/regressions/wl-pprint-indef.expr index 03959b195c0..6e718e3e685 100644 --- a/Cabal-tests/tests/ParserTests/regressions/wl-pprint-indef.expr +++ b/Cabal-tests/tests/ParserTests/regressions/wl-pprint-indef.expr @@ -114,6 +114,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], @@ -202,6 +204,8 @@ GenericPackageDescription { [], sharedOptions = PerCompilerFlavor [] [], + profSharedOptions = + PerCompilerFlavor [] [], staticOptions = PerCompilerFlavor [] [], customFieldsBI = [], diff --git a/Cabal-tests/tests/UnitTests/Distribution/Utils/Structured.hs b/Cabal-tests/tests/UnitTests/Distribution/Utils/Structured.hs index 641551473e8..d0a7211fd20 100644 --- a/Cabal-tests/tests/UnitTests/Distribution/Utils/Structured.hs +++ b/Cabal-tests/tests/UnitTests/Distribution/Utils/Structured.hs @@ -33,15 +33,15 @@ md5Check proxy md5Int = structureHash proxy @?= md5FromInteger md5Int md5CheckGenericPackageDescription :: Proxy GenericPackageDescription -> Assertion md5CheckGenericPackageDescription proxy = md5Check proxy #if MIN_VERSION_base(4,19,0) - 0x4acd7857947385180d814f36dc1a759e + 0x5273459ea92067e19d7b029f239f6b1b #else - 0x3ff3fa6c3c570bcafa10b457b1208cc8 + 0x44e1a5ea34ad96191eab49ccb703ac39 #endif md5CheckLocalBuildInfo :: Proxy LocalBuildInfo -> Assertion md5CheckLocalBuildInfo proxy = md5Check proxy #if MIN_VERSION_base(4,19,0) - 0x552eca9ce2e4a34e74deff571f279fc4 + 0x4e32acf958affcdfca283c741b74d7b8 #else - 0x48497d6b3f15df06f1107b81b98febe1 + 0x61b743fd01d4b34c00052bab3f040e39 #endif diff --git a/Cabal/Cabal.cabal b/Cabal/Cabal.cabal index 829a6397c9c..e6a978234c2 100644 --- a/Cabal/Cabal.cabal +++ b/Cabal/Cabal.cabal @@ -1,4 +1,4 @@ -cabal-version: 2.2 +cabal-version: 3.0 name: Cabal version: 3.13.0.0 copyright: 2003-2024, Cabal Development Team (see AUTHORS file) diff --git a/Cabal/src/Distribution/Simple/BuildPaths.hs b/Cabal/src/Distribution/Simple/BuildPaths.hs index 4c44bd380f2..05a9c6c190f 100644 --- a/Cabal/src/Distribution/Simple/BuildPaths.hs +++ b/Cabal/src/Distribution/Simple/BuildPaths.hs @@ -32,6 +32,7 @@ module Distribution.Simple.BuildPaths , mkProfLibName , mkGenericSharedLibName , mkSharedLibName + , mkProfSharedLibName , mkStaticLibName , mkGenericSharedBundledLibName , exeExtension @@ -283,6 +284,10 @@ mkSharedLibName :: Platform -> CompilerId -> UnitId -> String mkSharedLibName platform comp lib = mkGenericSharedLibName platform comp (getHSLibraryName lib) +mkProfSharedLibName :: Platform -> CompilerId -> UnitId -> String +mkProfSharedLibName platform comp lib = + mkGenericSharedLibName platform comp (getHSLibraryName lib ++ "_p") + -- Static libs are named the same as shared libraries, only with -- a different extension. mkStaticLibName :: Platform -> CompilerId -> UnitId -> String diff --git a/Cabal/src/Distribution/Simple/Compiler.hs b/Cabal/src/Distribution/Simple/Compiler.hs index ae8d1c05136..99e00a42a9e 100644 --- a/Cabal/src/Distribution/Simple/Compiler.hs +++ b/Cabal/src/Distribution/Simple/Compiler.hs @@ -63,6 +63,7 @@ module Distribution.Simple.Compiler , unitIdSupported , coverageSupported , profilingSupported + , profilingDynamicSupported , backpackSupported , arResponseFilesSupported , arDashLSupported @@ -428,6 +429,12 @@ profilingSupported comp = GHCJS -> True _ -> False +profilingDynamicSupported :: Compiler -> Bool +profilingDynamicSupported comp = + case Map.lookup "RTS ways" (compilerProperties comp) of + Just ways -> "p_dyn" `elem` words ways + Nothing -> False + -- | Does this compiler support a package database entry with: -- "visibility"? libraryVisibilitySupported :: Compiler -> Bool diff --git a/Cabal/src/Distribution/Simple/Configure.hs b/Cabal/src/Distribution/Simple/Configure.hs index 9e561e791c6..fed442f3ccb 100644 --- a/Cabal/src/Distribution/Simple/Configure.hs +++ b/Cabal/src/Distribution/Simple/Configure.hs @@ -754,11 +754,6 @@ computeLocalBuildConfig cfg comp programDb = do withFullyStaticExe_ = fromFlag $ configFullyStaticExe cfg - when (withDynExe_ && not withSharedLib_) $ - warn verbosity $ - "Executables will use dynamic linking, but a shared library " - ++ "is not being built. Linking will fail if any executables " - ++ "depend on the library." setProfiling <- configureProfiling verbosity cfg comp @@ -792,6 +787,7 @@ computeLocalBuildConfig cfg comp programDb = do , withDynExe = withDynExe_ , withFullyStaticExe = withFullyStaticExe_ , withProfLib = False + , withProfLibShared = False , withProfLibDetail = ProfDetailNone , withProfExe = False , withProfExeDetail = ProfDetailNone @@ -807,6 +803,20 @@ computeLocalBuildConfig cfg comp programDb = do , relocatable = fromFlagOrDefault False $ configRelocatable cfg } + -- Dynamic executable, but no shared vanilla libararies + when (LBC.withDynExe buildOptions && not (LBC.withProfExe buildOptions) && not (LBC.withSharedLib buildOptions)) $ + warn verbosity $ + "Executables will use dynamic linking, but a shared library " + ++ "is not being built. Linking will fail if any executables " + ++ "depend on the library." + + -- Profiled dynamic executable, but no shared vanilla libararies + when (LBC.withDynExe buildOptions && LBC.withProfExe buildOptions && not (LBC.withProfLibShared buildOptions)) $ + warn verbosity $ + "Executables will use profiled dynamic linking, but a profiled shared library " + ++ "is not being built. Linking will fail if any executables " + ++ "depend on the library." + return $ LBC.LocalBuildConfig { extraConfigArgs = [] -- Currently configure does not @@ -1732,7 +1742,7 @@ configureCoverage verbosity cfg comp = do -- -- Note that @--enable-executable-profiling@ also affects profiling -- of benchmarks and (non-detailed) test suites. -computeEffectiveProfiling :: ConfigFlags -> (Bool {- lib -}, Bool {- exe -}) +computeEffectiveProfiling :: ConfigFlags -> (Bool {- lib vanilla-}, Bool {- lib shared -}, Bool {- exe -}) computeEffectiveProfiling cfg = -- The --profiling flag sets the default for both libs and exes, -- but can be overridden by --library-profiling, or the old deprecated @@ -1740,15 +1750,20 @@ computeEffectiveProfiling cfg = -- -- The --profiling-detail and --library-profiling-detail flags behave -- similarly - let tryExeProfiling = + let dynamicExe = fromFlagOrDefault False (configDynExe cfg) + tryExeProfiling = fromFlagOrDefault False (mappend (configProf cfg) (configProfExe cfg)) tryLibProfiling = fromFlagOrDefault - tryExeProfiling - (mappend (configProf cfg) (configProfLib cfg)) - in (tryLibProfiling, tryExeProfiling) + (tryExeProfiling && not dynamicExe) + (configProfLib cfg) + tryLibProfilingShared = + fromFlagOrDefault + (tryExeProfiling && dynamicExe) + (configProfShared cfg) + in (tryLibProfiling, tryLibProfilingShared, tryExeProfiling) -- | Select and apply profiling settings for the build based on the -- 'ConfigFlags' and 'Compiler'. @@ -1758,7 +1773,7 @@ configureProfiling -> Compiler -> IO (LBC.BuildOptions -> LBC.BuildOptions) configureProfiling verbosity cfg comp = do - let (tryLibProfiling, tryExeProfiling) = computeEffectiveProfiling cfg + let (tryLibProfiling, tryLibProfilingShared, tryExeProfiling) = computeEffectiveProfiling cfg tryExeProfileLevel = fromFlagOrDefault @@ -1797,11 +1812,33 @@ configureProfiling verbosity cfg comp = do , LBC.withProfExe = tryExeProfiling , LBC.withProfExeDetail = exeLevel } - return (tryExeProfiling && not tryLibProfiling, apply) + let compilerSupportsProfilingDynamic = profilingDynamicSupported comp + apply2 <- + if compilerSupportsProfilingDynamic + -- Case 1: We support profiled shared libraries so turn on shared profiling + -- libraries if the user asked for it. + then return $ \buildOptions -> apply buildOptions { LBC.withProfLibShared = tryLibProfilingShared } + -- Case 2: Compiler doesn't support profiling shared so turn them off + else do + -- If we wanted to enable profilng shared libraries.. tell the + -- user we couldn't. + when tryLibProfilingShared $ warn verbosity ( "The compiler " + ++ showCompilerId comp + ++ " does not support " + ++ "profiling shared objects. Static profiled objects " + ++ "will be built." + ) + return $ \buildOptions -> + let original_options = apply buildOptions + in original_options { LBC.withProfLibShared = False + , LBC.withProfLib = tryLibProfilingShared || LBC.withProfLib original_options + , LBC.withDynExe = if LBC.withProfExe original_options then False else LBC.withDynExe original_options } + return (tryExeProfiling && not (tryLibProfiling || tryLibProfilingShared) , apply2) else do let apply buildOptions = buildOptions { LBC.withProfLib = False + , LBC.withProfLibShared = False , LBC.withProfLibDetail = ProfDetailNone , LBC.withProfExe = False , LBC.withProfExeDetail = ProfDetailNone diff --git a/Cabal/src/Distribution/Simple/GHC.hs b/Cabal/src/Distribution/Simple/GHC.hs index 095e657264e..17196238cbb 100644 --- a/Cabal/src/Distribution/Simple/GHC.hs +++ b/Cabal/src/Distribution/Simple/GHC.hs @@ -98,6 +98,7 @@ import Distribution.Simple.BuildPaths import Distribution.Simple.Compiler import Distribution.Simple.Errors import qualified Distribution.Simple.GHC.Build as GHC +import Distribution.Simple.GHC.Build.Modules (BuildWay (..)) import Distribution.Simple.GHC.Build.Utils import Distribution.Simple.GHC.EnvironmentParser import Distribution.Simple.GHC.ImplInfo @@ -747,10 +748,25 @@ libAbiHash verbosity _pkg_descr lbi lib clbi = do , ghcOptObjSuffix = toFlag "p_o" , ghcOptExtra = hcProfOptions GHC libBi } + profDynArgs = + vanillaArgs + `mappend` mempty + { ghcOptProfilingMode = toFlag True + , ghcOptProfilingAuto = + Internal.profDetailLevelFlag + True + (withProfLibDetail lbi) + , ghcOptDynLinkMode = toFlag GhcDynamicOnly + , ghcOptFPic = toFlag True + , ghcOptHiSuffix = toFlag "p_dyn_hi" + , ghcOptObjSuffix = toFlag "p_dyn_o" + , ghcOptExtra = hcProfSharedOptions GHC libBi + } ghcArgs + | withProfLib lbi && withSharedLib lbi && profilingDynamicSupported (compiler lbi) = profDynArgs + | withProfLib lbi = profArgs | withVanillaLib lbi = vanillaArgs | withSharedLib lbi = sharedArgs - | withProfLib lbi = profArgs | otherwise = error "libAbiHash: Can't find an enabled library way" (ghcProg, _) <- requireProgram verbosity ghcProgram (withPrograms lbi) @@ -870,75 +886,107 @@ installLib -> ComponentLocalBuildInfo -> IO () installLib verbosity lbi targetDir dynlibTargetDir _builtDir pkg lib clbi = do + let + wantVanilla = withVanillaLib lbi + wantStatic = withStaticLib lbi + wantDynamic = withSharedLib lbi + wantProf = withProfLib lbi + wantProfDyn = withProfLibShared lbi + + let computed_wantedWays = + [ProfDynWay | wantProfDyn ] + <> [ProfWay | wantProf ] + <> [DynWay | wantDynamic && not (componentIsIndefinite clbi) ] + <> [StaticWay | wantStatic || wantVanilla ] + + wantedWays = if null computed_wantedWays then [StaticWay] else computed_wantedWays + + + + info verbosity ("Wanted install ways: " ++ show wantedWays) + + + -- copy .hi files over: - whenVanilla $ copyModuleFiles $ Suffix "hi" - whenProf $ copyModuleFiles $ Suffix "p_hi" - whenShared $ copyModuleFiles $ Suffix "dyn_hi" +-- whenVanilla $ copyModuleFiles $ Suffix "hi" +-- whenProf $ copyModuleFiles $ Suffix "p_hi" +-- whenShared $ copyModuleFiles $ Suffix "dyn_hi" + forM_ wantedWays $ \w -> case w of + StaticWay -> copyModuleFiles (Suffix "hi") + DynWay -> copyModuleFiles (Suffix "dyn_hi") + ProfWay -> copyModuleFiles (Suffix "p_hi") + ProfDynWay -> copyModuleFiles (Suffix "p_dyn_hi") -- copy extra compilation artifacts that ghc plugins may produce copyDirectoryIfExists extraCompilationArtifacts -- copy the built library files over: - whenHasCode $ do - whenVanilla $ do - sequence_ - [ installOrdinary + when (has_code && hasLib) $ do + forM_ wantedWays $ \w -> case w of + StaticWay -> do + sequence_ + [ installOrdinary + builtDir + targetDir + (mkGenericStaticLibName (l ++ f)) + | l <- + getHSLibraryName + (componentUnitId clbi) + : (extraBundledLibs (libBuildInfo lib)) + , f <- "" : extraLibFlavours (libBuildInfo lib) + ] + whenGHCi $ installOrdinary builtDir targetDir ghciLibName + ProfWay -> do + installOrdinary builtDir targetDir profileLibName + whenGHCi $ installOrdinary builtDir targetDir ghciProfLibName + ProfDynWay -> do + installShared builtDir - targetDir - (mkGenericStaticLibName (l ++ f)) - | l <- - getHSLibraryName - (componentUnitId clbi) - : (extraBundledLibs (libBuildInfo lib)) - , f <- "" : extraLibFlavours (libBuildInfo lib) - ] - whenGHCi $ installOrdinary builtDir targetDir ghciLibName - whenProf $ do - installOrdinary builtDir targetDir profileLibName - whenGHCi $ installOrdinary builtDir targetDir ghciProfLibName - whenShared $ - if - -- The behavior for "extra-bundled-libraries" changed in version 2.5.0. - -- See ghc issue #15837 and Cabal PR #5855. - | specVersion pkg < CabalSpecV3_0 -> do - sequence_ - [ installShared - builtDir - dynlibTargetDir - (mkGenericSharedLibName platform compiler_id (l ++ f)) - | l <- getHSLibraryName uid : extraBundledLibs (libBuildInfo lib) - , f <- "" : extraDynLibFlavours (libBuildInfo lib) - ] - | otherwise -> do - sequence_ - [ installShared - builtDir - dynlibTargetDir - ( mkGenericSharedLibName - platform - compiler_id - (getHSLibraryName uid ++ f) - ) - | f <- "" : extraDynLibFlavours (libBuildInfo lib) - ] - sequence_ - [ do - files <- getDirectoryContents (i builtDir) - let l' = - mkGenericSharedBundledLibName - platform - compiler_id - l - forM_ files $ \file -> - when (l' `isPrefixOf` file) $ do - isFile <- doesFileExist (i $ builtDir makeRelativePathEx file) - when isFile $ do - installShared - builtDir - dynlibTargetDir - file - | l <- extraBundledLibs (libBuildInfo lib) - ] + dynlibTargetDir + (mkProfSharedLibName platform compiler_id uid) + DynWay -> do + if + -- The behavior for "extra-bundled-libraries" changed in version 2.5.0. + -- See ghc issue #15837 and Cabal PR #5855. + | specVersion pkg < CabalSpecV3_0 -> do + sequence_ + [ installShared + builtDir + dynlibTargetDir + (mkGenericSharedLibName platform compiler_id (l ++ f)) + | l <- getHSLibraryName uid : extraBundledLibs (libBuildInfo lib) + , f <- "" : extraDynLibFlavours (libBuildInfo lib) + ] + | otherwise -> do + sequence_ + [ installShared + builtDir + dynlibTargetDir + ( mkGenericSharedLibName + platform + compiler_id + (getHSLibraryName uid ++ f) + ) + | f <- "" : extraDynLibFlavours (libBuildInfo lib) + ] + sequence_ + [ do + files <- getDirectoryContents (i builtDir) + let l' = + mkGenericSharedBundledLibName + platform + compiler_id + l + forM_ files $ \file -> + when (l' `isPrefixOf` file) $ do + isFile <- doesFileExist (i $ builtDir makeRelativePathEx file) + when isFile $ do + installShared + builtDir + dynlibTargetDir + file + | l <- extraBundledLibs (libBuildInfo lib) + ] where -- See Note [Symbolic paths] in Distribution.Utils.Path i = interpretSymbolicPathLBI lbi @@ -997,11 +1045,11 @@ installLib verbosity lbi targetDir dynlibTargetDir _builtDir pkg lib clbi = do Platform JavaScript _ -> True _ -> False has_code = not (componentIsIndefinite clbi) - whenHasCode = when has_code - whenVanilla = when (hasLib && withVanillaLib lbi) - whenProf = when (hasLib && withProfLib lbi && has_code) + -- whenHasCode = when has_code + -- whenVanilla = when (hasLib && withVanillaLib lbi) + -- whenProf = when (hasLib && withProfLib lbi && has_code) whenGHCi = when (hasLib && withGHCiLib lbi && has_code) - whenShared = when (hasLib && withSharedLib lbi && has_code) + -- whenShared = when (hasLib && withSharedLib lbi && has_code) -- ----------------------------------------------------------------------------- -- Registering diff --git a/Cabal/src/Distribution/Simple/GHC/Build.hs b/Cabal/src/Distribution/Simple/GHC/Build.hs index 51f7d650338..c0df1ef766c 100644 --- a/Cabal/src/Distribution/Simple/GHC/Build.hs +++ b/Cabal/src/Distribution/Simple/GHC/Build.hs @@ -115,7 +115,7 @@ build numJobs pkg_descr pbci = do wantVanilla = if isLib then withVanillaLib lbi else False -- Arguably, wantStatic should be "withFullyStaticExe lbi" for executables, -- but it was not before the refactor. - wantStatic = if isLib then withStaticLib lbi else not (wantDynamic || wantProf) + wantStatic = if isLib then withStaticLib lbi else not wantDynamic wantDynamic = case component of CLib{} -> withSharedLib lbi CFLib flib -> withDynFLib flib @@ -123,22 +123,33 @@ build numJobs pkg_descr pbci = do CTest{} -> withDynExe lbi CBench{} -> withDynExe lbi wantProf = if isLib then withProfLib lbi else withProfExe lbi + wantProfShared = if isLib then withProfLibShared lbi else (withProfExe lbi && wantDynamic) + + --enable-profiling (enable (static profiling way)) .p_o + --enable-shared (enabled dynamic way) .dyn_o + --enable-profiling-shared (enable dyanmic profilng way) .p_dyn_o + --enable-library-vanilla (enable vanilla way) .o -- See also Note [Building Haskell Modules accounting for TH] in Distribution.Simple.GHC.Build.Modules -- We build static by default if no other way is wanted. -- For executables and foreign libraries, there should only be one wanted way. - wantedWays = - Set.fromList $ + calculatedWantedWays = -- If building a library, we accumulate all the ways, -- otherwise, we take just one. (if isLib then id else take 1) $ - [ProfWay | wantProf] + [ProfDynWay | wantProfShared ] + <> [ProfWay | wantProf ] -- I don't see why we shouldn't build with dynamic -- indefinite components. <> [DynWay | wantDynamic && not (componentIsIndefinite clbi)] - <> [StaticWay | wantStatic || wantVanilla || not (wantDynamic || wantProf)] + <> [StaticWay | wantStatic || wantVanilla ] + + -- If for some reason the logic above returns an empty list + wantedWays = + Set.fromList (if null calculatedWantedWays then [StaticWay] else calculatedWantedWays) + - liftIO $ info verbosity ("Wanted build ways: " ++ show (Set.toList wantedWays)) + liftIO $ info verbosity ("Wanted build ways(" ++ show isLib ++ "): " ++ show (Set.toList wantedWays)) -- We need a separate build and link phase, and C sources must be compiled -- after Haskell modules, because C sources may depend on stub headers diff --git a/Cabal/src/Distribution/Simple/GHC/Build/ExtraSources.hs b/Cabal/src/Distribution/Simple/GHC/Build/ExtraSources.hs index fc204cda30a..47b25d4ad6b 100644 --- a/Cabal/src/Distribution/Simple/GHC/Build/ExtraSources.hs +++ b/Cabal/src/Distribution/Simple/GHC/Build/ExtraSources.hs @@ -206,6 +206,13 @@ buildExtraSources description componentSourceGhcOptions wantDyn viewSources ghcP { ghcOptFPic = toFlag True , ghcOptDynLinkMode = toFlag GhcDynamicOnly } + profSharedSrcOpts = + vanillaSrcOpts + `mappend` mempty + { ghcOptProfilingMode = toFlag True + , ghcOptFPic = toFlag True + , ghcOptDynLinkMode = toFlag GhcDynamicOnly + } -- TODO: Placing all Haskell, C, & C++ objects in a single directory -- Has the potential for file collisions. In general we would -- consider this a user error. However, we should strive to @@ -232,12 +239,16 @@ buildExtraSources description componentSourceGhcOptions wantDyn viewSources ghcP compileIfNeeded vanillaSrcOpts when (wantDyn && (forceSharedLib || withSharedLib lbi)) $ compileIfNeeded sharedSrcOpts{ghcOptObjSuffix = toFlag "dyn_o"} - when (withProfLib lbi) $ + when (withProfLib lbi) $ do compileIfNeeded profSrcOpts{ghcOptObjSuffix = toFlag "p_o"} + when (wantDyn && (forceSharedLib || withSharedLib lbi)) $ + compileIfNeeded profSharedSrcOpts{ghcOptObjSuffix = toFlag "p_dyn_o"} -- For foreign libraries, we determine with which options to build the -- objects (vanilla vs shared vs profiled) CFLib flib + | withProfExe lbi && withDynFLib flib && wantDyn -> + compileIfNeeded profSharedSrcOpts | withProfExe lbi -> -- It doesn't sound right to query "ProfExe" for a foreign library... compileIfNeeded profSrcOpts | withDynFLib flib && wantDyn -> @@ -248,6 +259,8 @@ buildExtraSources description componentSourceGhcOptions wantDyn viewSources ghcP -- determine with which options to build the objects (vanilla vs shared vs -- profiled), but predicate is the same for the three kinds. _exeLike + | withProfExe lbi && withDynExe lbi && wantDyn -> + compileIfNeeded profSharedSrcOpts | withProfExe lbi -> compileIfNeeded profSrcOpts | withDynExe lbi && wantDyn -> diff --git a/Cabal/src/Distribution/Simple/GHC/Build/Link.hs b/Cabal/src/Distribution/Simple/GHC/Build/Link.hs index 9f454e0ea5f..52d5d0bb81a 100644 --- a/Cabal/src/Distribution/Simple/GHC/Build/Link.hs +++ b/Cabal/src/Distribution/Simple/GHC/Build/Link.hs @@ -142,6 +142,7 @@ linkOrLoadComponent ghcProg pkg_descr extraSources (buildTargetDir, targetDir) ( , ghcOptNoLink = Flag False , ghcOptRPaths = rpaths } + case what of BuildRepl replFlags -> liftIO $ do let @@ -156,8 +157,6 @@ linkOrLoadComponent ghcProg pkg_descr extraSources (buildTargetDir, targetDir) ( Internal.filterGhciFlags (ghcOptExtra staticOpts) <> replOptionsFlags (replReplOptions replFlags) - , ghcOptInputModules = replNoLoad (replReplOptions replFlags) (ghcOptInputModules staticOpts) - , ghcOptInputFiles = replNoLoad (replReplOptions replFlags) (ghcOptInputFiles staticOpts) } -- For a normal compile we do separate invocations of ghc for -- compiling as for linking. But for repl we have to do just @@ -173,13 +172,18 @@ linkOrLoadComponent ghcProg pkg_descr extraSources (buildTargetDir, targetDir) ( { ghcOptMode = toFlag GhcModeInteractive , ghcOptOptimisation = toFlag GhcNoOptimisation } + replOpts_final = replOpts + { + ghcOptInputModules = replNoLoad (replReplOptions replFlags) (ghcOptInputModules replOpts) + , ghcOptInputFiles = replNoLoad (replReplOptions replFlags) (ghcOptInputFiles replOpts) + } -- TODO: problem here is we need the .c files built first, so we can load them -- with ghci, but .c files can depend on .h files generated by ghc by ffi -- exports. when (case component of CLib lib -> null (allLibModules lib clbi); _ -> False) $ warn verbosity "No exposed modules" - runReplOrWriteFlags ghcProg lbi replFlags replOpts (pkgName (PD.package pkg_descr)) target + runReplOrWriteFlags ghcProg lbi replFlags replOpts_final (pkgName (PD.package pkg_descr)) target _otherwise -> let runGhcProg = runGHC verbosity ghcProg comp platform mbWorkDir @@ -237,6 +241,9 @@ linkLibrary buildTargetDir cleanedExtraLibDirs pkg_descr verbosity runGhcProg li sharedLibFilePath = buildTargetDir makeRelativePathEx (mkSharedLibName (hostPlatform lbi) compiler_id uid) + profSharedLibFilePath = + buildTargetDir + makeRelativePathEx (mkProfSharedLibName (hostPlatform lbi) compiler_id uid) staticLibFilePath = buildTargetDir makeRelativePathEx (mkStaticLibName (hostPlatform lbi) compiler_id uid) @@ -252,6 +259,9 @@ linkLibrary buildTargetDir cleanedExtraLibDirs pkg_descr verbosity runGhcProg li sharedLibInstallPath = libInstallPath mkSharedLibName (hostPlatform lbi) compiler_id uid + profSharedLibInstallPath = + libInstallPath + mkProfSharedLibName (hostPlatform lbi) compiler_id uid getObjFiles :: BuildWay -> IO [SymbolicPath Pkg File] getObjFiles way = @@ -358,6 +368,32 @@ linkLibrary buildTargetDir cleanedExtraLibDirs pkg_descr verbosity runGhcProg li toNubListR $ PD.extraFrameworkDirs libBi , ghcOptRPaths = rpaths } + ghcProfSharedLinkArgs pdynObjectFiles = + ghcBaseLinkArgs + { ghcOptShared = toFlag True + , ghcOptProfilingMode = toFlag True + , ghcOptProfilingAuto = + Internal.profDetailLevelFlag + True + (withProfLibDetail lbi) + , ghcOptDynLinkMode = toFlag GhcDynamicOnly + , ghcOptInputFiles = toNubListR pdynObjectFiles + , ghcOptOutputFile = toFlag profSharedLibFilePath + , -- For dynamic libs, Mac OS/X needs to know the install location + -- at build time. This only applies to GHC < 7.8 - see the + -- discussion in #1660. + ghcOptDylibName = + if hostOS == OSX + && ghcVersion < mkVersion [7, 8] + then toFlag profSharedLibInstallPath + else mempty + , ghcOptLinkLibs = extraLibs libBi + , ghcOptLinkLibPath = toNubListR $ cleanedExtraLibDirs + , ghcOptLinkFrameworks = toNubListR $ map getSymbolicPath $ PD.frameworks libBi + , ghcOptLinkFrameworkDirs = + toNubListR $ PD.extraFrameworkDirs libBi + , ghcOptRPaths = rpaths + } ghcStaticLinkArgs staticObjectFiles = ghcBaseLinkArgs { ghcOptStaticLib = toFlag True @@ -371,6 +407,7 @@ linkLibrary buildTargetDir cleanedExtraLibDirs pkg_descr verbosity runGhcProg li staticObjectFiles <- getObjFiles StaticWay profObjectFiles <- getObjFiles ProfWay dynamicObjectFiles <- getObjFiles DynWay + profDynamicObjectFiles <- getObjFiles ProfDynWay let linkWay = \case @@ -384,6 +421,8 @@ linkLibrary buildTargetDir cleanedExtraLibDirs pkg_descr verbosity runGhcProg li ldProg ghciProfLibFilePath profObjectFiles + ProfDynWay -> do + runGhcProg $ ghcProfSharedLinkArgs profDynamicObjectFiles DynWay -> do runGhcProg $ ghcSharedLinkArgs dynamicObjectFiles StaticWay -> do diff --git a/Cabal/src/Distribution/Simple/GHC/Build/Modules.hs b/Cabal/src/Distribution/Simple/GHC/Build/Modules.hs index 9c9e55a03bf..59bfad4f72d 100644 --- a/Cabal/src/Distribution/Simple/GHC/Build/Modules.hs +++ b/Cabal/src/Distribution/Simple/GHC/Build/Modules.hs @@ -200,6 +200,18 @@ buildHaskellModules numJobs ghcProg pkg_descr buildTargetDir wantedWays pbci = d (if isLib then True else False) ((if isLib then withProfLibDetail else withProfExeDetail) lbi) } + profDynOpts = + (baseOpts ProfDynWay) + { ghcOptDynLinkMode = toFlag GhcDynamicOnly -- use -dynamic + , -- TODO: Does it hurt to set -fPIC for executables? + ghcOptFPic = toFlag True -- use -fPIC + , ghcOptProfilingMode = toFlag True + , ghcOptProfilingAuto = + Internal.profDetailLevelFlag + (if isLib then True else False) + ((if isLib then withProfLibDetail else withProfExeDetail) lbi) + } + -- Options for building both static and dynamic way at the same time, using -- the GHC flag -static and -dynamic-too dynTooOpts = @@ -212,14 +224,36 @@ buildHaskellModules numJobs ghcProg pkg_descr buildTargetDir wantedWays pbci = d -- (Note that `baseOtps StaticWay = hcStaticOptions`, not hcSharedOpts) } + profDynTooOpts = + (baseOpts ProfWay) + { ghcOptDynLinkMode = toFlag GhcStaticAndDynamic -- use -dynamic-too + , -- TODO: Does it hurt to set -fPIC for executables? + ghcOptFPic = toFlag True -- use -fPIC + , ghcOptProfilingMode = toFlag True + , ghcOptProfilingAuto = + Internal.profDetailLevelFlag + (if isLib then True else False) + ((if isLib then withProfLibDetail else withProfExeDetail) lbi) + , ghcOptDynHiSuffix = toFlag (buildWayPrefix ProfDynWay ++ "hi") + , ghcOptDynObjSuffix = toFlag (buildWayPrefix ProfDynWay ++ "o") + , ghcOptHPCDir = hpcdir Hpc.ProfDyn + -- Should we pass hcSharedOpts in the -dynamic-too ghc invocation? + -- (Note that `baseOtps StaticWay = hcStaticOptions`, not hcSharedOpts) + } + -- Determines how to build for each way, also serves as the base options -- for loading modules in 'linkOrLoadComponent' buildOpts way = case way of StaticWay -> staticOpts DynWay -> dynOpts ProfWay -> profOpts + ProfDynWay -> profDynOpts - defaultGhcWay = if isDynamic comp then DynWay else StaticWay + -- IWKIM: TODO: we should get the compiler capability of profiling and dynamic. + defaultGhcWay + | ProfDynWay `Set.member` wantedWays = ProfDynWay + | isDynamic comp = DynWay + | otherwise = StaticWay -- If there aren't modules, or if we're loading the modules in repl, don't build. unless (forRepl || (null inputFiles && null inputModules)) $ liftIO $ do @@ -240,17 +274,32 @@ buildHaskellModules numJobs ghcProg pkg_descr buildTargetDir wantedWays pbci = d && supportsDynamicToo comp && null (hcSharedOptions GHC bi) + useProfDynamicToo = + ProfWay `Set.member` neededWays + && ProfDynWay `Set.member` neededWays + && supportsDynamicToo comp + && null (hcSharedOptions GHC bi) + + order w + | w == defaultGhcWay = 0 + | otherwise = fromEnum w + 1 + -- The ways we'll build, in order orderedBuilds -- If we can use dynamic-too, do it first. The default GHC way can only -- be static or dynamic, so, if we build both right away, any modules -- possibly needed by TH later (e.g. if building profiled) are already built. - | useDynamicToo = + | useProfDynamicToo && useDynamicToo = + [buildProfAndProfDynamicToo, buildStaticAndDynamicToo] + | useProfDynamicToo && not useDynamicToo = + [buildProfAndProfDynamicToo] + ++ (runGhcProg . buildOpts <$> Set.toList neededWays \\ [ProfDynWay, ProfWay]) + | useDynamicToo && not (ProfDynWay `Set.member` neededWays) = [buildStaticAndDynamicToo] ++ (runGhcProg . buildOpts <$> Set.toList neededWays \\ [StaticWay, DynWay]) -- Otherwise, we need to ensure the defaultGhcWay is built first | otherwise = - runGhcProg . buildOpts <$> sortOn (\w -> if w == defaultGhcWay then 0 else fromEnum w + 1) (Set.toList neededWays) + runGhcProg . buildOpts <$> sortOn order (Set.toList neededWays) buildStaticAndDynamicToo = do runGhcProg dynTooOpts @@ -264,13 +313,27 @@ buildHaskellModules numJobs ghcProg pkg_descr buildTargetDir wantedWays pbci = d -- both ways. copyDirectoryRecursive verbosity (i dynDir) (i vanillaDir) _ -> return () + + buildProfAndProfDynamicToo = do + runGhcProg profDynTooOpts + case (hpcdir Hpc.ProfDyn, hpcdir Hpc.Prof) of + (Flag profDynDir, Flag profDir) -> + -- When the vanilla and shared library builds are done + -- in one pass, only one set of HPC module interfaces + -- are generated. This set should suffice for both + -- static and dynamically linked executables. We copy + -- the modules interfaces so they are available under + -- both ways. + copyDirectoryRecursive verbosity (i profDynDir) (i profDir) + _ -> return () + in -- REVIEW:ADD? info verbosity "Building Haskell Sources..." sequence_ orderedBuilds return buildOpts -data BuildWay = StaticWay | DynWay | ProfWay - deriving (Eq, Ord, Show, Enum) +data BuildWay = StaticWay | DynWay | ProfWay | ProfDynWay + deriving (Eq, Ord, Show, Read, Enum) -- | Returns the object/interface extension prefix for the given build way (e.g. "dyn_" for 'DynWay') buildWayPrefix :: BuildWay -> String @@ -278,6 +341,7 @@ buildWayPrefix = \case StaticWay -> "" ProfWay -> "p_" DynWay -> "dyn_" + ProfDynWay -> "p_dyn_" -- | Returns the corresponding 'Hpc.Way' for a 'BuildWay' buildWayHpcWay :: BuildWay -> Hpc.Way @@ -285,6 +349,7 @@ buildWayHpcWay = \case StaticWay -> Hpc.Vanilla ProfWay -> Hpc.Prof DynWay -> Hpc.Dyn + ProfDynWay -> Hpc.Dyn -- | Returns a function to extract the extra haskell compiler options from a -- 'BuildInfo' and 'CompilerFlavor' @@ -293,6 +358,7 @@ buildWayExtraHcOptions = \case StaticWay -> hcStaticOptions ProfWay -> hcProfOptions DynWay -> hcSharedOptions + ProfDynWay -> hcProfSharedOptions -- | Returns a pair of the Haskell input files and Haskell modules of the -- component being built. diff --git a/Cabal/src/Distribution/Simple/Hpc.hs b/Cabal/src/Distribution/Simple/Hpc.hs index ea1c1368057..4198d7a66ba 100644 --- a/Cabal/src/Distribution/Simple/Hpc.hs +++ b/Cabal/src/Distribution/Simple/Hpc.hs @@ -58,7 +58,7 @@ import System.Directory (createDirectoryIfMissing, doesFileExist) -- ------------------------------------------------------------------------- -- Haskell Program Coverage -data Way = Vanilla | Prof | Dyn +data Way = Vanilla | Prof | Dyn | ProfDyn deriving (Bounded, Enum, Eq, Read, Show) hpcDir @@ -73,6 +73,7 @@ hpcDir distPref way = distPref makeRelativePathEx ("hpc" wayDir) Vanilla -> "vanilla" Prof -> "prof" Dyn -> "dyn" + ProfDyn -> "prof_dyn" mixDir :: SymbolicPath Pkg (Dir Dist) diff --git a/Cabal/src/Distribution/Simple/Setup/Config.hs b/Cabal/src/Distribution/Simple/Setup/Config.hs index 14e76c7d769..d45d2bb3e70 100644 --- a/Cabal/src/Distribution/Simple/Setup/Config.hs +++ b/Cabal/src/Distribution/Simple/Setup/Config.hs @@ -127,6 +127,8 @@ data ConfigFlags = ConfigFlags , configProf :: Flag Bool -- ^ Enable profiling in the library -- and executables. + , configProfShared :: Flag Bool + -- ^ Enable shared profiling objects , configProfDetail :: Flag ProfDetailLevel -- ^ Profiling detail level -- in the library and executables. @@ -286,6 +288,7 @@ instance Eq ConfigFlags where && equal configProfExe && equal configProf && equal configProfDetail + && equal configProfShared && equal configProfLibDetail && equal configConfigureArgs && equal configOptimization @@ -518,6 +521,13 @@ configureOptions showOrParseArgs = configProf (\v flags -> flags{configProf = v}) (boolOpt [] []) + , option + "" + ["profiling-shared"] + "Enable profiling for shared objects, implies `--enable-profiling`" + configProfShared + (\v flags -> flags{configProfShared = v}) + (boolOpt [] []) , option "" ["executable-profiling"] diff --git a/Cabal/src/Distribution/Types/LocalBuildConfig.hs b/Cabal/src/Distribution/Types/LocalBuildConfig.hs index 9126d92f1eb..ce9064b2f43 100644 --- a/Cabal/src/Distribution/Types/LocalBuildConfig.hs +++ b/Cabal/src/Distribution/Types/LocalBuildConfig.hs @@ -151,6 +151,8 @@ data BuildOptions = BuildOptions { withVanillaLib :: Bool -- ^ Whether to build normal libs. , withProfLib :: Bool + -- ^ Whether to build normal libs. + , withProfLibShared :: Bool -- ^ Whether to build profiling versions of libs. , withSharedLib :: Bool -- ^ Whether to build shared versions of libs. @@ -211,6 +213,7 @@ buildOptionsConfigFlags (BuildOptions{..}) = , configGHCiLib = toFlag $ withGHCiLib , configProfExe = toFlag $ withProfExe , configProfLib = toFlag $ withProfLib + , configProfShared = toFlag $ withProfLibShared , configProf = mempty , -- configProfDetail is for exe+lib, but overridden by configProfLibDetail -- so we specify both so we can specify independently diff --git a/Cabal/src/Distribution/Types/LocalBuildInfo.hs b/Cabal/src/Distribution/Types/LocalBuildInfo.hs index a5706fff09a..56db5d00fcc 100644 --- a/Cabal/src/Distribution/Types/LocalBuildInfo.hs +++ b/Cabal/src/Distribution/Types/LocalBuildInfo.hs @@ -28,11 +28,12 @@ module Distribution.Types.LocalBuildInfo , withPackageDB , withVanillaLib , withProfLib - , withSharedLib - , withStaticLib + , withProfLibShared , withDynExe , withFullyStaticExe , withProfExe + , withSharedLib + , withStaticLib , withProfLibDetail , withProfExeDetail , withOptimization @@ -168,6 +169,7 @@ pattern LocalBuildInfo -> Bool -> Bool -> Bool + -> Bool -> ProfDetailLevel -> ProfDetailLevel -> OptimisationLevel @@ -200,6 +202,7 @@ pattern LocalBuildInfo , withPackageDB , withVanillaLib , withProfLib + , withProfLibShared , withSharedLib , withStaticLib , withDynExe @@ -251,6 +254,7 @@ pattern LocalBuildInfo LBC.BuildOptions { withVanillaLib , withProfLib + , withProfLibShared , withSharedLib , withStaticLib , withDynExe diff --git a/cabal-install-solver/src/Distribution/Solver/Types/ConstraintSource.hs b/cabal-install-solver/src/Distribution/Solver/Types/ConstraintSource.hs index 3fdf64bde89..55b35212d3c 100644 --- a/cabal-install-solver/src/Distribution/Solver/Types/ConstraintSource.hs +++ b/cabal-install-solver/src/Distribution/Solver/Types/ConstraintSource.hs @@ -41,6 +41,10 @@ data ConstraintSource = -- from Cabal >= 3.11 | ConstraintSourceMultiRepl + | ConstraintSourceProfiledDynamic + -- | Constraint introduced by --enable-profiling-shared, which requires features + -- from Cabal >= 3.13 + -- | The source of the constraint is not specified. | ConstraintSourceUnknown @@ -72,6 +76,8 @@ showConstraintSource ConstraintSourceConfigFlagOrTarget = "config file, command line flag, or user target" showConstraintSource ConstraintSourceMultiRepl = "--enable-multi-repl" +showConstraintSource ConstraintSourceProfiledDynamic = + "--enable-profiling-shared" showConstraintSource ConstraintSourceUnknown = "unknown source" showConstraintSource ConstraintSetupCabalMinVersion = "minimum version of Cabal used by Setup.hs" diff --git a/cabal-install/src/Distribution/Client/Config.hs b/cabal-install/src/Distribution/Client/Config.hs index fd9bd5af432..c6eec97668b 100644 --- a/cabal-install/src/Distribution/Client/Config.hs +++ b/cabal-install/src/Distribution/Client/Config.hs @@ -490,6 +490,7 @@ instance Semigroup SavedConfig where , configVanillaLib = combine configVanillaLib , configProfLib = combine configProfLib , configProf = combine configProf + , configProfShared = combine configProfShared , configSharedLib = combine configSharedLib , configStaticLib = combine configStaticLib , configDynExe = combine configDynExe diff --git a/cabal-install/src/Distribution/Client/Dependency.hs b/cabal-install/src/Distribution/Client/Dependency.hs index 66a0a103c23..8c1d8f056a8 100644 --- a/cabal-install/src/Distribution/Client/Dependency.hs +++ b/cabal-install/src/Distribution/Client/Dependency.hs @@ -64,6 +64,7 @@ module Distribution.Client.Dependency , addDefaultSetupDependencies , addSetupCabalMinVersionConstraint , addSetupCabalMaxVersionConstraint + , addSetupCabalProfiledDynamic ) where import Distribution.Client.Compat.Prelude @@ -670,6 +671,22 @@ addSetupCabalMaxVersionConstraint maxVersion = where cabalPkgname = mkPackageName "Cabal" +-- | Add an upper bound on @setup.Cabal@ labeled with 'ConstraintSourceProfiledDynamic' +addSetupCabalProfiledDynamic + :: DepResolverParams + -> DepResolverParams +addSetupCabalProfiledDynamic = + addConstraints + [ LabeledPackageConstraint + ( PackageConstraint + (ScopeAnySetupQualifier cabalPkgname) + (PackagePropertyVersion $ orLaterVersion (mkVersion [3,13,0])) + ) + ConstraintSourceProfiledDynamic + ] + where + cabalPkgname = mkPackageName "Cabal" + upgradeDependencies :: DepResolverParams -> DepResolverParams upgradeDependencies = setPreferenceDefault PreferAllLatest diff --git a/cabal-install/src/Distribution/Client/ProjectConfig.hs b/cabal-install/src/Distribution/Client/ProjectConfig.hs index 99dde932037..fbf3a6e66fb 100644 --- a/cabal-install/src/Distribution/Client/ProjectConfig.hs +++ b/cabal-install/src/Distribution/Client/ProjectConfig.hs @@ -103,10 +103,9 @@ import Distribution.Client.Types import Distribution.Client.Utils.Parsec (renderParseError) import Distribution.Solver.Types.PackageConstraint - ( PackageProperty (..) - ) import Distribution.Solver.Types.Settings import Distribution.Solver.Types.SourcePackage +import Distribution.Solver.Types.ConstraintSource import Distribution.Client.Errors import Distribution.Client.Setup @@ -136,11 +135,6 @@ import Distribution.Fields , showPWarning ) import Distribution.Package - ( PackageId - , PackageName - , UnitId - , packageId - ) import Distribution.PackageDescription.Parsec ( parseGenericPackageDescription ) @@ -195,8 +189,7 @@ import Distribution.Verbosity , verbose ) import Distribution.Version - ( Version - ) +import Distribution.Client.Targets import qualified Codec.Archive.Tar as Tar import qualified Codec.Archive.Tar.Entry as Tar @@ -317,9 +310,24 @@ resolveSolverSettings where -- TODO: [required eventually] some of these settings need validation, e.g. -- the flag assignments need checking. + cabalPkgname = mkPackageName "Cabal" + + pc = UserConstraint + (UserAnySetupQualifier cabalPkgname) + (PackagePropertyVersion $ orLaterVersion (mkVersion [3,13,0])) + + pc' pn = UserConstraint + (UserQualified (UserQualSetup pn) cabalPkgname) + (PackagePropertyVersion $ orLaterVersion (mkVersion [3,13,0])) + + + solverCabalLibConstraints = + [ (pc, ConstraintSourceProfiledDynamic) | fromFlagOrDefault False (packageConfigProfShared projectConfigLocalPackages) ] + ++ [ (pc' pn, ConstraintSourceProfiledDynamic) | (pn, ppc) <- Map.toList (getMapMappend projectConfigSpecificPackage), fromFlagOrDefault False (packageConfigProfShared ppc) ] + solverSettingRemoteRepos = fromNubList projectConfigRemoteRepos solverSettingLocalNoIndexRepos = fromNubList projectConfigLocalNoIndexRepos - solverSettingConstraints = projectConfigConstraints + solverSettingConstraints = solverCabalLibConstraints ++ projectConfigConstraints solverSettingPreferences = projectConfigPreferences solverSettingFlagAssignment = packageConfigFlagAssignment projectConfigLocalPackages solverSettingFlagAssignments = diff --git a/cabal-install/src/Distribution/Client/ProjectConfig/Legacy.hs b/cabal-install/src/Distribution/Client/ProjectConfig/Legacy.hs index fe2e86d8ccc..2d91e6ae0e4 100644 --- a/cabal-install/src/Distribution/Client/ProjectConfig/Legacy.hs +++ b/cabal-install/src/Distribution/Client/ProjectConfig/Legacy.hs @@ -768,6 +768,7 @@ convertLegacyPerPackageFlags , configFullyStaticExe = packageConfigFullyStaticExe , configProfExe = packageConfigProfExe , configProf = packageConfigProf + , configProfShared = packageConfigProfShared , configProfDetail = packageConfigProfDetail , configProfLibDetail = packageConfigProfLibDetail , configConfigureArgs = packageConfigConfigureArgs @@ -1074,6 +1075,7 @@ convertToLegacyAllPackageConfig , configFullyStaticExe = mempty , configProfExe = mempty , configProf = mempty + , configProfShared = mempty , configProfDetail = mempty , configProfLibDetail = mempty , configConfigureArgs = mempty @@ -1150,6 +1152,7 @@ convertToLegacyPerPackageConfig PackageConfig{..} = , configFullyStaticExe = packageConfigFullyStaticExe , configProfExe = packageConfigProfExe , configProf = packageConfigProf + , configProfShared = packageConfigProfShared , configProfDetail = packageConfigProfDetail , configProfLibDetail = packageConfigProfLibDetail , configConfigureArgs = packageConfigConfigureArgs @@ -1545,11 +1548,13 @@ legacyPackageConfigFieldDescrs = , "program-suffix" , "library-vanilla" , "library-profiling" + , "library-vanilla" , "shared" , "static" , "executable-dynamic" , "executable-static" , "profiling" + , "profiling-shared" , "executable-profiling" , "profiling-detail" , "library-profiling-detail" diff --git a/cabal-install/src/Distribution/Client/ProjectConfig/Types.hs b/cabal-install/src/Distribution/Client/ProjectConfig/Types.hs index 3e8e3ba1b07..81e3d2a2704 100644 --- a/cabal-install/src/Distribution/Client/ProjectConfig/Types.hs +++ b/cabal-install/src/Distribution/Client/ProjectConfig/Types.hs @@ -265,6 +265,7 @@ data PackageConfig = PackageConfig , packageConfigFullyStaticExe :: Flag Bool , packageConfigProf :: Flag Bool -- TODO: [code cleanup] sort out , packageConfigProfLib :: Flag Bool -- this duplication + , packageConfigProfShared :: Flag Bool , packageConfigProfExe :: Flag Bool -- and consistency , packageConfigProfDetail :: Flag ProfDetailLevel , packageConfigProfLibDetail :: Flag ProfDetailLevel diff --git a/cabal-install/src/Distribution/Client/ProjectOrchestration.hs b/cabal-install/src/Distribution/Client/ProjectOrchestration.hs index 2d963b0e07f..7f26ac12382 100644 --- a/cabal-install/src/Distribution/Client/ProjectOrchestration.hs +++ b/cabal-install/src/Distribution/Client/ProjectOrchestration.hs @@ -1061,7 +1061,7 @@ printPlan nubFlag x (Setup.Flag x') | x == x' = Setup.NoFlag nubFlag _ f = f - (tryLibProfiling, tryExeProfiling) = + (tryLibProfiling, tryLibProfilingShared, tryExeProfiling) = computeEffectiveProfiling fullConfigureFlags partialConfigureFlags = @@ -1072,7 +1072,8 @@ printPlan nubFlag tryExeProfiling (configProfExe fullConfigureFlags) , configProfLib = nubFlag tryLibProfiling (configProfLib fullConfigureFlags) - -- Maybe there are more we can add + , configProfShared = + nubFlag tryLibProfilingShared (configProfShared fullConfigureFlags) } in -- Not necessary to "escape" it, it's just for user output unwords . ("" :) $ diff --git a/cabal-install/src/Distribution/Client/ProjectPlanning.hs b/cabal-install/src/Distribution/Client/ProjectPlanning.hs index ea4fae8ab8c..8c6a5bbef5f 100644 --- a/cabal-install/src/Distribution/Client/ProjectPlanning.hs +++ b/cabal-install/src/Distribution/Client/ProjectPlanning.hs @@ -2203,6 +2203,7 @@ elaborateInstallPlan , withGHCiLib = perPkgOptionFlag pkgid False packageConfigGHCiLib -- TODO: [required feature] needs to default to enabled on windows still , withProfExe = perPkgOptionFlag pkgid False packageConfigProf , withProfLib = pkgid `Set.member` pkgsUseProfilingLibrary + , withProfLibShared = pkgid `Set.member` pkgsUseProfilingLibraryShared , exeCoverage = perPkgOptionFlag pkgid False packageConfigCoverage , libCoverage = perPkgOptionFlag pkgid False packageConfigCoverage , withOptimization = perPkgOptionFlag pkgid NormalOptimisation packageConfigOptimization @@ -2390,6 +2391,17 @@ elaborateInstallPlan pkgid = packageId pkg profBothFlag = lookupPerPkgOption pkgid packageConfigProf profLibFlag = lookupPerPkgOption pkgid packageConfigProfLib + + pkgsUseProfilingLibraryShared :: Set PackageId + pkgsUseProfilingLibraryShared = + packagesWithLibDepsDownwardClosedProperty needsProfilingLibShared + where + needsProfilingLibShared pkg = + fromFlagOrDefault False profLibSharedFlag + where + pkgid = packageId pkg + profLibSharedFlag = lookupPerPkgOption pkgid packageConfigProfShared + -- TODO: [code cleanup] unused: the old deprecated packageConfigProfExe libDepGraph = @@ -3821,7 +3833,7 @@ setupHsConfigureFlags sanityCheckElaboratedConfiguredPackage sharedConfig elab - (Cabal.ConfigFlags{..}) + Cabal.ConfigFlags{..} where Cabal.ConfigFlags { configVanillaLib @@ -3832,6 +3844,7 @@ setupHsConfigureFlags , configGHCiLib , -- , configProfExe -- overridden configProfLib + , configProfShared , -- , configProf -- overridden configProfDetail , configProfLibDetail diff --git a/cabal-install/src/Distribution/Client/Setup.hs b/cabal-install/src/Distribution/Client/Setup.hs index ae21e7f3799..41f4ecc855f 100644 --- a/cabal-install/src/Distribution/Client/Setup.hs +++ b/cabal-install/src/Distribution/Client/Setup.hs @@ -679,7 +679,7 @@ filterConfigureFlags' :: ConfigFlags -> Version -> ConfigFlags filterConfigureFlags' flags cabalLibVersion -- NB: we expect the latest version to be the most common case, -- so test it first. - | cabalLibVersion >= mkVersion [3, 11, 0] = flags_latest + | cabalLibVersion >= mkVersion [3, 13, 0] = flags_latest -- The naming convention is that flags_version gives flags with -- all flags *introduced* in version eliminated. -- It is NOT the latest version of Cabal library that @@ -701,6 +701,7 @@ filterConfigureFlags' flags cabalLibVersion | cabalLibVersion < mkVersion [2, 5, 0] = flags_2_5_0 | cabalLibVersion < mkVersion [3, 7, 0] = flags_3_7_0 | cabalLibVersion < mkVersion [3, 11, 0] = flags_3_11_0 + | cabalLibVersion < mkVersion [3, 13, 0] = flags_3_13_0 | otherwise = error "the impossible just happened" -- see first guard where flags_latest = @@ -712,18 +713,26 @@ filterConfigureFlags' flags cabalLibVersion configConstraints = [] } - flags_3_11_0 = + flags_3_13_0 = + -- Earlier Cabal versions don't understand about .. flags_latest + { -- Building profiled shared libraries + configProfShared = NoFlag + } + + + flags_3_11_0 = + flags_3_13_0 { -- It's too late to convert configPromisedDependencies to anything -- meaningful, so we just assert that it's empty. -- We add a Cabal>=3.11 constraint before solving when multi-repl is -- enabled, so this should never trigger. configPromisedDependencies = assert (null $ configPromisedDependencies flags) [] - , -- Cabal < 3.11 does not understand '--coverage-for', which is OK + -- Cabal < 3.11 does not understand '--coverage-for', which is OK -- because previous versions of Cabal using coverage implied -- whole-package builds (cuz_coverage), and determine the path to -- libraries mix dirs from the testsuite root with a small hack. - configCoverageFor = NoFlag + , configCoverageFor = NoFlag } flags_3_7_0 = @@ -783,7 +792,7 @@ filterConfigureFlags' flags cabalLibVersion -- Cabal < 1.23 doesn't know about '--profiling-detail'. -- Cabal < 1.23 has a hacked up version of 'enable-profiling' -- which we shouldn't use. - (tryLibProfiling, tryExeProfiling) = computeEffectiveProfiling flags + (tryLibProfiling, _tryLibProfilingShared, tryExeProfiling) = computeEffectiveProfiling flags flags_1_23_0 = flags_1_25_0 { configProfDetail = NoFlag diff --git a/cabal-install/tests/UnitTests/Distribution/Client/ProjectConfig.hs b/cabal-install/tests/UnitTests/Distribution/Client/ProjectConfig.hs index abdc1e79390..a2d7e2b0635 100644 --- a/cabal-install/tests/UnitTests/Distribution/Client/ProjectConfig.hs +++ b/cabal-install/tests/UnitTests/Distribution/Client/ProjectConfig.hs @@ -683,6 +683,7 @@ instance Arbitrary PackageConfig where <*> arbitrary <*> arbitrary <*> arbitrary + <*> arbitrary <*> shortListOf 5 arbitraryShortToken <*> arbitrary <*> arbitrary @@ -751,6 +752,7 @@ instance Arbitrary PackageConfig where , packageConfigFullyStaticExe = x50 , packageConfigProf = x07 , packageConfigProfLib = x08 + , packageConfigProfShared = x08_1 , packageConfigProfExe = x09 , packageConfigProfDetail = x10 , packageConfigProfLibDetail = x11 @@ -814,6 +816,7 @@ instance Arbitrary PackageConfig where , packageConfigFullyStaticExe = x50' , packageConfigProf = x07' , packageConfigProfLib = x08' + , packageConfigProfShared = x08_1' , packageConfigProfExe = x09' , packageConfigProfDetail = x10' , packageConfigProfLibDetail = x11' @@ -866,7 +869,7 @@ instance Arbitrary PackageConfig where , packageConfigBenchmarkOptions = x52' } | ( ( (x00', x01', x02', x03', x04') - , (x05', x42', x06', x50', x07', x08', x09') + , (x05', x42', x06', x50', x07', x08', x08_1', x09') , (x10', x11', x12', x13', x14') , (x15', x16', x53', x17', x18', x19') ) @@ -883,7 +886,7 @@ instance Arbitrary PackageConfig where shrink ( ( (preShrink_Paths x00, preShrink_Args x01, x02, x03, x04) - , (x05, x42, x06, x50, x07, x08, x09) + , (x05, x42, x06, x50, x07, x08, x08_1, x09) , (x10, x11, map NonEmpty x12, x13, x14) , ( x15 diff --git a/cabal-testsuite/PackageTests/ProfShared/Lib.hs b/cabal-testsuite/PackageTests/ProfShared/Lib.hs new file mode 100644 index 00000000000..516d174a825 --- /dev/null +++ b/cabal-testsuite/PackageTests/ProfShared/Lib.hs @@ -0,0 +1,3 @@ +module Lib where + +lib = 10 diff --git a/cabal-testsuite/PackageTests/ProfShared/exe/Prof.hs b/cabal-testsuite/PackageTests/ProfShared/exe/Prof.hs new file mode 100644 index 00000000000..200915ffefa --- /dev/null +++ b/cabal-testsuite/PackageTests/ProfShared/exe/Prof.hs @@ -0,0 +1,5 @@ +module Main where + +import Lib + +main = print lib diff --git a/cabal-testsuite/PackageTests/ProfShared/profShared.cabal b/cabal-testsuite/PackageTests/ProfShared/profShared.cabal new file mode 100644 index 00000000000..ef348cfecc6 --- /dev/null +++ b/cabal-testsuite/PackageTests/ProfShared/profShared.cabal @@ -0,0 +1,13 @@ +Cabal-Version: 3.8 +Name: prof-shared +Version: 0.1 +Build-Type: Simple + +library + exposed-modules: Lib + Build-Depends: base + +executable Prof + main-is: Prof.hs + hs-source-dirs: exe + build-depends: base, prof-shared diff --git a/cabal-testsuite/PackageTests/ProfSharedWarning/Lib.hs b/cabal-testsuite/PackageTests/ProfSharedWarning/Lib.hs new file mode 100644 index 00000000000..516d174a825 --- /dev/null +++ b/cabal-testsuite/PackageTests/ProfSharedWarning/Lib.hs @@ -0,0 +1,3 @@ +module Lib where + +lib = 10 diff --git a/cabal-testsuite/PackageTests/ProfSharedWarning/cabal.project b/cabal-testsuite/PackageTests/ProfSharedWarning/cabal.project new file mode 100644 index 00000000000..e6fdbadb439 --- /dev/null +++ b/cabal-testsuite/PackageTests/ProfSharedWarning/cabal.project @@ -0,0 +1 @@ +packages: . diff --git a/cabal-testsuite/PackageTests/ProfSharedWarning/exe/Prof.hs b/cabal-testsuite/PackageTests/ProfSharedWarning/exe/Prof.hs new file mode 100644 index 00000000000..200915ffefa --- /dev/null +++ b/cabal-testsuite/PackageTests/ProfSharedWarning/exe/Prof.hs @@ -0,0 +1,5 @@ +module Main where + +import Lib + +main = print lib diff --git a/cabal-testsuite/PackageTests/ProfSharedWarning/profShared.cabal b/cabal-testsuite/PackageTests/ProfSharedWarning/profShared.cabal new file mode 100644 index 00000000000..ef348cfecc6 --- /dev/null +++ b/cabal-testsuite/PackageTests/ProfSharedWarning/profShared.cabal @@ -0,0 +1,13 @@ +Cabal-Version: 3.8 +Name: prof-shared +Version: 0.1 +Build-Type: Simple + +library + exposed-modules: Lib + Build-Depends: base + +executable Prof + main-is: Prof.hs + hs-source-dirs: exe + build-depends: base, prof-shared diff --git a/cabal-testsuite/PackageTests/ProfSharedWarning/setup.out b/cabal-testsuite/PackageTests/ProfSharedWarning/setup.out new file mode 100644 index 00000000000..66512712837 --- /dev/null +++ b/cabal-testsuite/PackageTests/ProfSharedWarning/setup.out @@ -0,0 +1,3 @@ +# Setup configure +Configuring prof-shared-0.1... +Warning: Executables will use dynamic linking, but a shared library is not being built. Linking will fail if any executables depend on the library. diff --git a/cabal-testsuite/PackageTests/ProfSharedWarning/setup_prof.out b/cabal-testsuite/PackageTests/ProfSharedWarning/setup_prof.out new file mode 100644 index 00000000000..ad201b3b391 --- /dev/null +++ b/cabal-testsuite/PackageTests/ProfSharedWarning/setup_prof.out @@ -0,0 +1,4 @@ +# Setup configure +Configuring prof-shared-0.1... +Warning: The flag --enable-executable-profiling is deprecated. Please use --enable-profiling instead. +Warning: Executables will use profiled dynamic linking, but a profiled shared library is not being built. Linking will fail if any executables depend on the library. diff --git a/cabal-testsuite/src/Test/Cabal/Prelude.hs b/cabal-testsuite/src/Test/Cabal/Prelude.hs index 8a0aaff928b..664ba3d6e27 100644 --- a/cabal-testsuite/src/Test/Cabal/Prelude.hs +++ b/cabal-testsuite/src/Test/Cabal/Prelude.hs @@ -840,17 +840,21 @@ hasSharedLibraries = do shared_libs_were_removed <- isGhcVersion ">= 7.8" return (not (buildOS == Windows && shared_libs_were_removed)) -hasProfiledLibraries :: TestM Bool -hasProfiledLibraries = do +testCompilerWithArgs :: [String] -> TestM Bool +testCompilerWithArgs args = do env <- getTestEnv ghc_path <- programPathM ghcProgram let prof_test_hs = testWorkDir env "Prof.hs" liftIO $ writeFile prof_test_hs "module Prof where" r <- liftIO $ run (testVerbosity env) (Just $ testCurrentDir env) - (testEnvironment env) ghc_path ["-prof", "-c", prof_test_hs] + (testEnvironment env) ghc_path (["-c", prof_test_hs] ++ args) Nothing return (resultExitCode r == ExitSuccess) +hasProfiledLibraries, hasProfiledSharedLibraries :: TestM Bool +hasProfiledLibraries = testCompilerWithArgs ["-prof"] +hasProfiledSharedLibraries = testCompilerWithArgs ["-prof", "-dynamic"] + -- | Check if the GHC that is used for compiling package tests has -- a shared library of the cabal library under test in its database. -- diff --git a/doc/setup-commands.rst b/doc/setup-commands.rst index 20bdafabfae..5ed8077f46b 100644 --- a/doc/setup-commands.rst +++ b/doc/setup-commands.rst @@ -795,10 +795,21 @@ Miscellaneous options Build shared library. This implies a separate compiler run to generate position independent code as required on most platforms. + ``--enable-shared`` is enabled automatically if GHC is dynamically linked or + you request to build dynamic executables. + .. option:: --disable-shared (default) Do not build shared library. +.. option:: --enable-profiling-shared + + Build a profiling shared library. + +.. option:: --disable-profiling-shared + + (default) Do not built a profiling shared library. + .. option:: --enable-static Build a static library. This passes ``-staticlib`` to GHC (available