Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC

Commits:

25 changed files:

Changes:

  • compiler/GHC/CmmToAsm/X86/CodeGen.hs
    ... ... @@ -2,6 +2,8 @@
    2 2
     {-# LANGUAGE MultiWayIf #-}
    
    3 3
     {-# LANGUAGE ParallelListComp #-}
    
    4 4
     {-# LANGUAGE NondecreasingIndentation #-}
    
    5
    +{-# LANGUAGE DeriveGeneric #-}
    
    6
    +{-# LANGUAGE DerivingVia #-}
    
    5 7
     
    
    6 8
     -----------------------------------------------------------------------------
    
    7 9
     --
    
    ... ... @@ -72,6 +74,8 @@ import GHC.Cmm.CLabel
    72 74
     import GHC.Types.Tickish ( GenTickish(..) )
    
    73 75
     import GHC.Types.SrcLoc  ( srcSpanFile, srcSpanStartLine, srcSpanStartCol )
    
    74 76
     
    
    77
    +import GHC.Generics (Generic, Generically(..))
    
    78
    +
    
    75 79
     -- The rest:
    
    76 80
     import GHC.Data.Maybe ( expectJust )
    
    77 81
     import GHC.Types.ForeignCall ( CCallConv(..) )
    
    ... ... @@ -429,7 +433,7 @@ getRegisterReg _ (CmmLocal lreg) = getLocalRegReg lreg
    429 433
     
    
    430 434
     getRegisterReg platform  (CmmGlobal mid)
    
    431 435
       = case globalRegMaybe platform $ globalRegUse_reg mid of
    
    432
    -        Just reg -> RegReal $ reg
    
    436
    +        Just reg -> RegReal reg
    
    433 437
             Nothing  -> pprPanic "getRegisterReg-memory" (ppr $ CmmGlobal mid)
    
    434 438
             -- By this stage, the only MagicIds remaining should be the
    
    435 439
             -- ones which map to a real machine register on this
    
    ... ... @@ -4776,11 +4780,8 @@ data LoadArgs
    4776 4780
       -- | The code to assign arguments to registers used for argument passing.
    
    4777 4781
       , assignArgsCode :: InstrBlock
    
    4778 4782
       }
    
    4779
    -instance Semigroup LoadArgs where
    
    4780
    -  LoadArgs a1 d1 r1 j1 <> LoadArgs a2 d2 r2 j2
    
    4781
    -    = LoadArgs (a1 ++ a2) (d1 ++ d2) (r1 ++ r2) (j1 S.<> j2)
    
    4782
    -instance Monoid LoadArgs where
    
    4783
    -  mempty = LoadArgs [] [] [] nilOL
    
    4783
    +  deriving (Generic)
    
    4784
    +  deriving (Semigroup, Monoid) via Generically LoadArgs
    
    4784 4785
     
    
    4785 4786
     -- | An argument passed on the stack, either directly or by reference.
    
    4786 4787
     --
    

  • compiler/GHC/CmmToLlvm/CodeGen.hs
    1 1
     {-# LANGUAGE CPP #-}
    
    2 2
     {-# LANGUAGE MultiWayIf #-}
    
    3 3
     {-# OPTIONS_GHC -fno-warn-type-defaults #-}
    
    4
    +{-# LANGUAGE DeriveGeneric #-}
    
    5
    +{-# LANGUAGE DerivingVia #-}
    
    4 6
     
    
    5 7
     -- | Handle conversion of CmmProc to LLVM code.
    
    6 8
     module GHC.CmmToLlvm.CodeGen ( genLlvmProc ) where
    
    ... ... @@ -29,6 +31,8 @@ import GHC.Data.FastString
    29 31
     import GHC.Data.Maybe (expectJust)
    
    30 32
     import GHC.Data.OrdList
    
    31 33
     
    
    34
    +import GHC.Generics (Generic, Generically(..))
    
    35
    +
    
    32 36
     import GHC.Types.ForeignCall
    
    33 37
     import GHC.Types.Unique.DSM
    
    34 38
     import GHC.Types.Unique
    
    ... ... @@ -2445,14 +2449,8 @@ getTBAARegMeta = getTBAAMeta . getTBAA
    2445 2449
     
    
    2446 2450
     -- | A more convenient way of accumulating LLVM statements and declarations.
    
    2447 2451
     data LlvmAccum = LlvmAccum LlvmStatements [LlvmCmmDecl]
    
    2448
    -
    
    2449
    -instance Semigroup LlvmAccum where
    
    2450
    -  LlvmAccum stmtsA declsA <> LlvmAccum stmtsB declsB =
    
    2451
    -        LlvmAccum (stmtsA Semigroup.<> stmtsB) (declsA Semigroup.<> declsB)
    
    2452
    -
    
    2453
    -instance Monoid LlvmAccum where
    
    2454
    -    mempty = LlvmAccum nilOL []
    
    2455
    -    mappend = (Semigroup.<>)
    
    2452
    +  deriving (Generic)
    
    2453
    +  deriving (Monoid, Semigroup) via Generically LlvmAccum
    
    2456 2454
     
    
    2457 2455
     liftExprData :: LlvmM ExprData -> WriterT LlvmAccum LlvmM LlvmVar
    
    2458 2456
     liftExprData action = do
    

  • compiler/GHC/Data/Pair.hs
    1
    +{-# LANGUAGE DeriveGeneric #-}
    
    2
    +{-# LANGUAGE DerivingVia #-}
    
    3
    +
    
    1 4
     {-
    
    2 5
     A simple homogeneous pair type with useful Functor, Applicative, and
    
    3 6
     Traversable instances.
    
    ... ... @@ -20,8 +23,12 @@ import GHC.Prelude
    20 23
     import GHC.Utils.Outputable
    
    21 24
     import qualified Data.Semigroup as Semi
    
    22 25
     
    
    26
    +import GHC.Generics (Generic, Generically(..))
    
    27
    +
    
    23 28
     data Pair a = Pair { pFst :: a, pSnd :: a }
    
    24
    -  deriving (Foldable, Functor, Traversable)
    
    29
    +  deriving (Foldable, Functor, Traversable, Generic)
    
    30
    +  deriving (Semigroup, Monoid) via Generically (Pair a)
    
    31
    +
    
    25 32
     -- Note that Pair is a *unary* type constructor
    
    26 33
     -- whereas (,) is binary
    
    27 34
     
    
    ... ... @@ -33,13 +40,6 @@ instance Applicative Pair where
    33 40
       pure x = Pair x x
    
    34 41
       (Pair f g) <*> (Pair x y) = Pair (f x) (g y)
    
    35 42
     
    
    36
    -instance Semi.Semigroup a => Semi.Semigroup (Pair a) where
    
    37
    -  Pair a1 b1 <> Pair a2 b2 =  Pair (a1 Semi.<> a2) (b1 Semi.<> b2)
    
    38
    -
    
    39
    -instance (Semi.Semigroup a, Monoid a) => Monoid (Pair a) where
    
    40
    -  mempty = Pair mempty mempty
    
    41
    -  mappend = (Semi.<>)
    
    42
    -
    
    43 43
     instance Outputable a => Outputable (Pair a) where
    
    44 44
       ppr (Pair a b) = ppr a <+> char '~' <+> ppr b
    
    45 45
     
    

  • compiler/GHC/Hs/Type.hs
    1 1
     {-# LANGUAGE TypeFamilies #-}
    
    2
    -{-# LANGUAGE ViewPatterns #-}
    
    3 2
     {-# LANGUAGE UndecidableInstances #-} -- Wrinkle in Note [Trees That Grow]
    
    4 3
                                            -- in module Language.Haskell.Syntax.Extension
    
    5
    -
    
    4
    +{-# LANGUAGE DeriveGeneric #-}
    
    5
    +{-# LANGUAGE DerivingVia #-}
    
    6 6
     {-# OPTIONS_GHC -Wno-orphans #-} -- NamedThing, Outputable, OutputableBndrId
    
    7 7
     
    
    8 8
     {-
    
    ... ... @@ -116,6 +116,7 @@ import GHC.Core.Ppr ( pprOccWithTick)
    116 116
     import GHC.Core.Type
    
    117 117
     import GHC.Core.Multiplicity( pprArrowWithMultiplicity )
    
    118 118
     import GHC.Hs.Doc
    
    119
    +import GHC.Generics (Generic, Generically(..))
    
    119 120
     import GHC.Types.Basic
    
    120 121
     import GHC.Types.SrcLoc
    
    121 122
     import GHC.Utils.Outputable
    
    ... ... @@ -231,6 +232,8 @@ data HsTyPatRnBuilder =
    231 232
         hstpb_imp_tvs :: Bag Name,
    
    232 233
         hstpb_exp_tvs :: Bag Name
    
    233 234
       }
    
    235
    +  deriving (Generic)
    
    236
    +  deriving (Semigroup, Monoid) via Generically HsTyPatRnBuilder
    
    234 237
     
    
    235 238
     tpBuilderExplicitTV :: Name -> HsTyPatRnBuilder
    
    236 239
     tpBuilderExplicitTV name = mempty {hstpb_exp_tvs = unitBag name}
    
    ... ... @@ -242,16 +245,6 @@ tpBuilderPatSig HsPSRn {hsps_nwcs, hsps_imp_tvs} =
    242 245
         hstpb_imp_tvs = listToBag hsps_imp_tvs
    
    243 246
       }
    
    244 247
     
    
    245
    -instance Semigroup HsTyPatRnBuilder where
    
    246
    -  HsTPRnB nwcs1 imp_tvs1 exptvs1 <> HsTPRnB nwcs2 imp_tvs2 exptvs2 =
    
    247
    -    HsTPRnB
    
    248
    -      (nwcs1    `unionBags` nwcs2)
    
    249
    -      (imp_tvs1 `unionBags` imp_tvs2)
    
    250
    -      (exptvs1  `unionBags` exptvs2)
    
    251
    -
    
    252
    -instance Monoid HsTyPatRnBuilder where
    
    253
    -  mempty = HsTPRnB emptyBag emptyBag emptyBag
    
    254
    -
    
    255 248
     buildHsTyPatRn :: HsTyPatRnBuilder -> HsTyPatRn
    
    256 249
     buildHsTyPatRn HsTPRnB {hstpb_nwcs, hstpb_imp_tvs, hstpb_exp_tvs} =
    
    257 250
       HsTPRn {
    

  • compiler/GHC/HsToCore/Pmc.hs
    1
    +{-# LANGUAGE DeriveGeneric #-}
    
    2
    +{-# LANGUAGE DerivingVia #-}
    
    3
    +
    
    1 4
     -- | This module coverage checks pattern matches. It finds
    
    2 5
     --
    
    3 6
     --     * Uncovered patterns, certifying non-exhaustivity
    
    ... ... @@ -61,6 +64,7 @@ import {-# SOURCE #-} GHC.HsToCore.Expr (dsLExpr)
    61 64
     import GHC.HsToCore.Monad
    
    62 65
     import GHC.Data.Bag
    
    63 66
     import GHC.Data.OrdList
    
    67
    +import GHC.Generics (Generic, Generically(..))
    
    64 68
     
    
    65 69
     import Control.Monad (when, unless, forM_)
    
    66 70
     import qualified Data.Semigroup as Semi
    
    ... ... @@ -442,13 +446,8 @@ data CIRB
    442 446
       , cirb_red   :: !(OrdList SrcInfo) -- ^ Redundant clauses
    
    443 447
       , cirb_bangs :: !(OrdList SrcInfo) -- ^ Redundant bang patterns
    
    444 448
       }
    
    445
    -
    
    446
    -instance Semigroup CIRB where
    
    447
    -  CIRB a b c d <> CIRB e f g h = CIRB (a <> e) (b <> f) (c <> g) (d <> h)
    
    448
    -    where (<>) = (Semi.<>)
    
    449
    -
    
    450
    -instance Monoid CIRB where
    
    451
    -  mempty = CIRB mempty mempty mempty mempty
    
    449
    +  deriving (Generic)
    
    450
    +  deriving (Semigroup, Monoid) via Generically CIRB
    
    452 451
     
    
    453 452
     -- See Note [Determining inaccessible clauses]
    
    454 453
     ensureOneNotRedundant :: CIRB -> CIRB
    

  • compiler/GHC/HsToCore/Pmc/Solver/Types.hs
    ... ... @@ -2,6 +2,8 @@
    2 2
     {-# LANGUAGE ViewPatterns        #-}
    
    3 3
     {-# LANGUAGE MultiWayIf          #-}
    
    4 4
     {-# LANGUAGE TypeFamilies        #-}
    
    5
    +{-# LANGUAGE DeriveGeneric       #-}
    
    6
    +{-# LANGUAGE DerivingVia         #-}
    
    5 7
     
    
    6 8
     -- | Domain types used in "GHC.HsToCore.Pmc.Solver".
    
    7 9
     -- The ultimate goal is to define 'Nabla', which models normalised refinement
    
    ... ... @@ -68,6 +70,7 @@ import GHC.Types.CompleteMatch
    68 70
     import GHC.Types.SourceText (SourceText(..), mkFractionalLit, FractionalLit
    
    69 71
                                 , fractionalLitFromRational
    
    70 72
                                 , FractionalExponentBase(..))
    
    73
    +import GHC.Generics (Generic, Generically(..))
    
    71 74
     
    
    72 75
     import Numeric (fromRat)
    
    73 76
     import Data.Ratio
    
    ... ... @@ -104,19 +107,13 @@ instance Outputable Nabla where
    104 107
     
    
    105 108
     -- | A disjunctive bag of 'Nabla's, representing a refinement type.
    
    106 109
     newtype Nablas = MkNablas (Bag Nabla)
    
    110
    +  -- deriving 'Outputable' removes `MkNablas` label
    
    111
    +  deriving (Generic, Outputable)
    
    112
    +  deriving (Semigroup, Monoid) via Generically Nablas
    
    107 113
     
    
    108 114
     initNablas :: Nablas
    
    109 115
     initNablas = MkNablas (unitBag initNabla)
    
    110 116
     
    
    111
    -instance Outputable Nablas where
    
    112
    -  ppr (MkNablas nablas) = ppr nablas
    
    113
    -
    
    114
    -instance Semigroup Nablas where
    
    115
    -  MkNablas l <> MkNablas r = MkNablas (l `unionBags` r)
    
    116
    -
    
    117
    -instance Monoid Nablas where
    
    118
    -  mempty = MkNablas emptyBag
    
    119
    -
    
    120 117
     -- | The type oracle state. An 'GHC.Tc.Solver.Monad.InertSet' that we
    
    121 118
     -- incrementally add local type constraints to, together with a sequence
    
    122 119
     -- number that counts the number of times we extended it with new facts.
    

  • compiler/GHC/Linker/MacOS.hs
    ... ... @@ -19,9 +19,9 @@ import GHC.SysTools.Tasks
    19 19
     
    
    20 20
     import GHC.Runtime.Interpreter
    
    21 21
     
    
    22
    +import GHC.Utils.CliOption
    
    22 23
     import GHC.Utils.Exception
    
    23 24
     import GHC.Utils.Logger
    
    24
    -import GHC.Driver.Session
    
    25 25
     
    
    26 26
     import Data.List (isPrefixOf, nub, sort, intersperse, intercalate)
    
    27 27
     import Data.Char
    

  • compiler/GHC/Parser/PostProcess/Haddock.hs
    1 1
     {-# LANGUAGE ApplicativeDo              #-}
    
    2
    +{-# LANGUAGE DeriveGeneric              #-}
    
    2 3
     {-# LANGUAGE DerivingVia                #-}
    
    3 4
     {-# LANGUAGE TypeFamilies               #-}
    
    4 5
     
    
    ... ... @@ -61,6 +62,7 @@ import {-# SOURCE #-} GHC.Parser (parseIdentifier)
    61 62
     import GHC.Parser.Lexer
    
    62 63
     import GHC.Parser.HaddockLex
    
    63 64
     import GHC.Parser.Errors.Types
    
    65
    +import GHC.Generics (Generic, Generically(..))
    
    64 66
     import GHC.Utils.Misc (mergeListsBy, filterOut, (<&&>))
    
    65 67
     import qualified GHC.Data.Strict as Strict
    
    66 68
     
    
    ... ... @@ -1347,13 +1349,8 @@ data LocRange =
    1347 1349
         { loc_range_from :: !LowerLocBound,
    
    1348 1350
           loc_range_to   :: !UpperLocBound,
    
    1349 1351
           loc_range_col  :: !ColumnBound }
    
    1350
    -
    
    1351
    -instance Semigroup LocRange where
    
    1352
    -  LocRange from1 to1 col1 <> LocRange from2 to2 col2 =
    
    1353
    -    LocRange (from1 <> from2) (to1 <> to2) (col1 <> col2)
    
    1354
    -
    
    1355
    -instance Monoid LocRange where
    
    1356
    -  mempty = LocRange mempty mempty mempty
    
    1352
    +  deriving (Generic)
    
    1353
    +  deriving (Semigroup, Monoid) via Generically LocRange
    
    1357 1354
     
    
    1358 1355
     -- The location range from the specified position to the end of the file.
    
    1359 1356
     locRangeFrom :: Strict.Maybe BufPos -> LocRange
    

  • compiler/GHC/Tc/Utils/TcMType.hs
    1 1
     {-# LANGUAGE DuplicateRecordFields #-}
    
    2 2
     {-# LANGUAGE MultiWayIf            #-}
    
    3 3
     {-# LANGUAGE RecursiveDo           #-}
    
    4
    +{-# LANGUAGE DeriveGeneric         #-}
    
    5
    +{-# LANGUAGE DerivingVia           #-}
    
    4 6
     
    
    5 7
     {-# OPTIONS_GHC -Wno-incomplete-record-updates #-}
    
    6 8
     {-
    
    ... ... @@ -145,6 +147,8 @@ import GHC.Utils.Outputable
    145 147
     import GHC.Utils.Panic
    
    146 148
     import GHC.Utils.Constants (debugIsOn)
    
    147 149
     
    
    150
    +import GHC.Generics (Generic, Generically(..))
    
    151
    +
    
    148 152
     import Control.Monad
    
    149 153
     import Data.IORef
    
    150 154
     import GHC.Data.Maybe
    
    ... ... @@ -1267,17 +1271,8 @@ data CandidatesQTvs
    1267 1271
              -- These are covars. Included only so that we don't repeatedly
    
    1268 1272
              -- look at covars' kinds in accumulator. Not used by quantifyTyVars.
    
    1269 1273
         }
    
    1270
    -
    
    1271
    -instance Semi.Semigroup CandidatesQTvs where
    
    1272
    -   (DV { dv_kvs = kv1, dv_tvs = tv1, dv_cvs = cv1 })
    
    1273
    -     <> (DV { dv_kvs = kv2, dv_tvs = tv2, dv_cvs = cv2 })
    
    1274
    -          = DV { dv_kvs = kv1 `unionDVarSet` kv2
    
    1275
    -               , dv_tvs = tv1 `unionDVarSet` tv2
    
    1276
    -               , dv_cvs = cv1 `unionVarSet` cv2 }
    
    1277
    -
    
    1278
    -instance Monoid CandidatesQTvs where
    
    1279
    -   mempty = DV { dv_kvs = emptyDVarSet, dv_tvs = emptyDVarSet, dv_cvs = emptyVarSet }
    
    1280
    -   mappend = (Semi.<>)
    
    1274
    +  deriving (Generic)
    
    1275
    +  deriving (Semigroup, Monoid) via Generically CandidatesQTvs
    
    1281 1276
     
    
    1282 1277
     instance Outputable CandidatesQTvs where
    
    1283 1278
       ppr (DV {dv_kvs = kvs, dv_tvs = tvs, dv_cvs = cvs })
    

  • compiler/GHC/Types/Unique/DSet.hs
    ... ... @@ -44,6 +44,7 @@ import GHC.Types.Unique
    44 44
     
    
    45 45
     import Data.Coerce
    
    46 46
     import Data.Data
    
    47
    +import Data.Semigroup
    
    47 48
     
    
    48 49
     -- See Note [UniqSet invariant] in GHC.Types.Unique.Set for why we want a newtype here.
    
    49 50
     -- Beyond preserving invariants, we may also want to 'override' typeclass
    
    ... ... @@ -154,3 +155,9 @@ instance Outputable a => Outputable (UniqDSet a) where
    154 155
     
    
    155 156
     pprUniqDSet :: (a -> SDoc) -> UniqDSet a -> SDoc
    
    156 157
     pprUniqDSet f = braces . pprWithCommas f . uniqDSetToList
    
    158
    +
    
    159
    +instance Semigroup (UniqDSet a) where
    
    160
    +  (<>) = unionUniqDSets
    
    161
    +
    
    162
    +instance Monoid (UniqDSet a) where
    
    163
    +  mempty = emptyUniqDSet

  • compiler/GHC/Utils/Binary.hs
    ... ... @@ -150,6 +150,7 @@ import qualified Data.ByteString.Lazy as LBS
    150 150
     import qualified Data.ByteString.Internal as BS
    
    151 151
     import qualified Data.ByteString.Unsafe   as BS
    
    152 152
     import qualified Data.ByteString.Short.Internal as SBS
    
    153
    +import qualified Data.Text.Internal as T
    
    153 154
     import Data.IORef
    
    154 155
     import Data.Char                ( ord, chr )
    
    155 156
     import Data.List.NonEmpty       ( NonEmpty(..))
    
    ... ... @@ -1816,13 +1817,19 @@ putSBS :: WriteBinHandle -> SBS.ShortByteString -> IO ()
    1816 1817
     putSBS bh sbs = do
    
    1817 1818
       let l = SBS.length sbs
    
    1818 1819
       put_ bh l
    
    1819
    -  putPrim bh l (\p -> SBS.copyToPtr sbs 0 p l)
    
    1820
    +  putSBSOffLen bh sbs 0 l
    
    1820 1821
     
    
    1822
    +putSBSOffLen :: WriteBinHandle -> SBS.ShortByteString -> Int -> Int -> IO ()
    
    1823
    +putSBSOffLen bh sbs off len =
    
    1824
    +  putPrim bh len $ \p -> SBS.copyToPtr sbs off p len
    
    1821 1825
     
    
    1822 1826
     getSBS :: ReadBinHandle -> IO SBS.ShortByteString
    
    1823 1827
     getSBS bh = do
    
    1824 1828
       l <- get bh :: IO Int
    
    1825
    -  getPrim bh l (\src -> SBS.createFromPtr src l)
    
    1829
    +  getSBSLen bh l
    
    1830
    +
    
    1831
    +getSBSLen :: ReadBinHandle -> Int -> IO SBS.ShortByteString
    
    1832
    +getSBSLen bh len = getPrim bh len $ \src -> SBS.createFromPtr src len
    
    1826 1833
     
    
    1827 1834
     putBS :: WriteBinHandle -> ByteString -> IO ()
    
    1828 1835
     putBS bh bs =
    
    ... ... @@ -1856,6 +1863,16 @@ instance Binary LBS.ByteString where
    1856 1863
     
    
    1857 1864
       get bh = LBS.fromStrict <$> get bh
    
    1858 1865
     
    
    1866
    +instance Binary T.Text where
    
    1867
    +  put_ bh (T.Text ba off len) = do
    
    1868
    +    put_ bh len
    
    1869
    +    putSBSOffLen bh (SBS.ShortByteString ba) off len
    
    1870
    +
    
    1871
    +  get bh = do
    
    1872
    +    len <- get bh
    
    1873
    +    SBS.ShortByteString ba <- getSBSLen bh len
    
    1874
    +    pure $ T.Text ba 0 len
    
    1875
    +
    
    1859 1876
     instance Binary FastString where
    
    1860 1877
       put_ bh f =
    
    1861 1878
         case findUserDataWriter (Proxy :: Proxy FastString) bh of
    

  • compiler/GHC/Utils/Ppr/Colour.hs
    1
    +{-# LANGUAGE DeriveGeneric #-}
    
    2
    +{-# LANGUAGE DerivingVia #-}
    
    3
    +
    
    1 4
     module GHC.Utils.Ppr.Colour where
    
    2 5
     import GHC.Prelude.Basic
    
    3 6
     
    
    4 7
     import Data.Maybe (fromMaybe)
    
    5 8
     import GHC.Data.Bool
    
    6
    -import Data.Semigroup as Semi
    
    9
    +import GHC.Generics (Generic, Generically(..))
    
    7 10
     
    
    8 11
     -- | A colour\/style for use with 'coloured'.
    
    9 12
     newtype PprColour = PprColour { renderColour :: String }
    
    10
    -
    
    11
    -instance Semi.Semigroup PprColour where
    
    12
    -  PprColour s1 <> PprColour s2 = PprColour (s1 <> s2)
    
    13
    -
    
    14
    --- | Allow colours to be combined (e.g. bold + red);
    
    15
    ---   In case of conflict, right side takes precedence.
    
    16
    -instance Monoid PprColour where
    
    17
    -  mempty = PprColour mempty
    
    18
    -  mappend = (<>)
    
    13
    +  deriving (Generic)
    
    14
    +  deriving (Semigroup, Monoid) via Generically PprColour
    
    19 15
     
    
    20 16
     renderColourAfresh :: PprColour -> String
    
    21 17
     renderColourAfresh c = renderColour (colReset `mappend` c)
    

  • compiler/ghc.cabal.in
    ... ... @@ -120,6 +120,7 @@ Library
    120 120
                        process    >= 1   && < 1.7,
    
    121 121
                        bytestring >= 0.11 && < 0.13,
    
    122 122
                        binary     == 0.8.*,
    
    123
    +                   text       >= 2.0 && < 2.2,
    
    123 124
                        time       >= 1.4 && < 1.16,
    
    124 125
                        containers >= 0.6.2.1 && < 0.9,
    
    125 126
                        array      >= 0.1 && < 0.6,
    

  • configure.ac
    ... ... @@ -671,8 +671,8 @@ FP_CC_IGNORE_UNUSED_ARGS([$CC], [CONF_CC_OPTS_STAGE2])
    671 671
     
    
    672 672
     # CPP, CPPFLAGS
    
    673 673
     # --with-cpp/-with-cpp-flags
    
    674
    -dnl Note that we must do this after setting and using the C99 CPPFLAGS, or
    
    675
    -dnl otherwise risk trying to configure the C99 and LD flags using -E as a CPPFLAG
    
    674
    +dnl Note that we must do this after setting and using the C11 CPPFLAGS, or
    
    675
    +dnl otherwise risk trying to configure the C11 and LD flags using -E as a CPPFLAG
    
    676 676
     FP_CPP_CMD_WITH_ARGS([$CC_STAGE0],[CPPCmd_STAGE0],[CONF_CPP_OPTS_STAGE0])
    
    677 677
     FP_CPP_CMD_WITH_ARGS([$CC],[CPPCmd],[CONF_CPP_OPTS_STAGE1])
    
    678 678
     FP_CPP_CMD_WITH_ARGS([$CC],[CPPCmd],[CONF_CPP_OPTS_STAGE2])
    

  • distrib/configure.ac.in
    ... ... @@ -313,8 +313,8 @@ FP_CC_IGNORE_UNUSED_ARGS([$CC], [CONF_CC_OPTS_STAGE2])
    313 313
     
    
    314 314
     # CPP, CPPFLAGS
    
    315 315
     # --with-cpp/-with-cpp-flags
    
    316
    -dnl Note that we must do this after setting and using the C99 CPPFLAGS, or
    
    317
    -dnl otherwise risk trying to configure the C99 and LD flags using -E as a CPPFLAG
    
    316
    +dnl Note that we must do this after setting and using the C11 CPPFLAGS, or
    
    317
    +dnl otherwise risk trying to configure the C11 and LD flags using -E as a CPPFLAG
    
    318 318
     FP_CPP_CMD_WITH_ARGS([$CC_STAGE0],[CPPCmd_STAGE0],[CONF_CPP_OPTS_STAGE0])
    
    319 319
     FP_CPP_CMD_WITH_ARGS([$CC],[CPPCmd],[CONF_CPP_OPTS_STAGE1])
    
    320 320
     FP_CPP_CMD_WITH_ARGS([$CC],[CPPCmd],[CONF_CPP_OPTS_STAGE2])
    

  • ghc/GHCi/UI/Info.hs
    ... ... @@ -46,6 +46,8 @@ import GHC.Utils.Outputable
    46 46
     import           GHC.Types.SrcLoc
    
    47 47
     import           GHC.Types.Var
    
    48 48
     import qualified GHC.Data.Strict as Strict
    
    49
    +import           GHC.Runtime.Loader (initializePlugins)
    
    50
    +import           Data.Containers.ListUtils (nubOrd)
    
    49 51
     
    
    50 52
     import           GHCi.UI.Exception
    
    51 53
     
    
    ... ... @@ -301,6 +303,13 @@ srcFilePath modSum = fromMaybe obj_fp src_fp
    301 303
     getModInfo :: (GhcMonad m) => Module -> m ModInfo
    
    302 304
     getModInfo m = do
    
    303 305
         mod_summary <- getModSummary m
    
    306
    +
    
    307
    +    -- Update the session plugins from the module summary
    
    308
    +    -- and initialize them (#23110).
    
    309
    +    modifySession $ hscUpdateFlags $ \dynFlags -> dynFlags
    
    310
    +      { pluginModNames = nubOrd $ pluginModNames dynFlags ++ pluginModNames (ms_hspp_opts mod_summary) }
    
    311
    +    modifySessionM (liftIO . initializePlugins)
    
    312
    +
    
    304 313
         p <- parseModule mod_summary
    
    305 314
         typechecked <- typecheckModule p
    
    306 315
         let allTypes = processAllTypeCheckedModule typechecked
    

  • m4/fp_cmm_cpp_cmd_with_args.m4
    ... ... @@ -56,6 +56,27 @@ else
    56 56
       AC_MSG_RESULT([no])
    
    57 57
     fi
    
    58 58
     
    
    59
    +AC_MSG_CHECKING([the C-- preprocessor for C11 support])
    
    60
    +cat > conftest.c <<EOF
    
    61
    +#include <stdio.h>
    
    62
    +#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112L
    
    63
    +# error "Compiler does not advertise C11 conformance"
    
    64
    +#endif
    
    65
    +EOF
    
    66
    +if "$CMM_CPP_CMD" $CMM_CPP_ARGS conftest.c -o conftest -g0 >/dev/null 2>&1; then
    
    67
    +  AC_MSG_RESULT([yes])
    
    68
    +else
    
    69
    +    # Try -std=gnu11
    
    70
    +    if "$CMM_CPP_CMD" -std=gnu11 $CMM_CPP_ARGS conftest.c -o conftest -g0 >/dev/null 2>&1; then
    
    71
    +      $3="-std=gnu11 $$3"
    
    72
    +      AC_MSG_RESULT([needs -std=gnu11])
    
    73
    +    else
    
    74
    +      AC_MSG_ERROR([C11-compatible compiler needed])
    
    75
    +    fi
    
    76
    +fi
    
    77
    +rm -f conftest.c conftest.o conftest
    
    78
    +
    
    79
    +
    
    59 80
     $2="$CMM_CPP_CMD"
    
    60 81
     $3="$$3 $CMM_CPP_ARGS"
    
    61 82
     
    

  • rts/include/Stg.h
    ... ... @@ -31,8 +31,8 @@
    31 31
     #define __STDC_VERSION__ 0
    
    32 32
     #endif
    
    33 33
     
    
    34
    -#if !(__STDC_VERSION__ >= 199901L) && !(__cplusplus >= 201103L)
    
    35
    -# error __STDC_VERSION__ does not advertise C99, C++11 or later
    
    34
    +#if !(__STDC_VERSION__ >= 201112L) && !(__cplusplus >= 201103L)
    
    35
    +# error __STDC_VERSION__ does not advertise C11, C++11 or later
    
    36 36
     #endif
    
    37 37
     
    
    38 38
     /*
    
    ... ... @@ -49,10 +49,6 @@
    49 49
     #if !defined(IN_STG_CODE)
    
    50 50
     # define IN_STG_CODE 1
    
    51 51
     
    
    52
    -// Turn on C99 for .hc code.  This gives us the INFINITY and NAN
    
    53
    -// constants from math.h, which we occasionally need to use in .hc (#1861)
    
    54
    -# define _ISOC99_SOURCE
    
    55
    -
    
    56 52
     // We need _BSD_SOURCE so that math.h defines things like gamma
    
    57 53
     // on Linux
    
    58 54
     # define _BSD_SOURCE
    

  • testsuite/tests/ffi/should_run/all.T
    ... ... @@ -103,7 +103,7 @@ test('T2276_ghci', [ only_ghci,
    103 103
                          pre_cmd('$MAKE -s --no-print-directory T2276_ghci_setup ghciWayFlags=' + config.ghci_way_flags) ],
    
    104 104
                        compile_and_run, ['-fobject-code T2276_ghci_c.o'])
    
    105 105
     
    
    106
    -test('T2469', normal, compile_and_run, ['-optc-std=gnu99'])
    
    106
    +test('T2469', normal, compile_and_run, ['-optc-std=gnu11'])
    
    107 107
     
    
    108 108
     test('T2594', [req_c], compile_and_run, ['T2594_c.c'])
    
    109 109
     
    

  • testsuite/tests/plugins/T23110.hs
    1
    +{-# OPTIONS_GHC -fplugin=Simple.SourcePlugin #-}
    
    2
    +
    
    3
    +module Main where
    
    4
    +
    
    5
    +main :: IO ()
    
    6
    +main = return ()

  • testsuite/tests/plugins/T23110.script
    1
    +:set +c
    
    2
    +:load T23110.hs
    
    3
    +-- The key thing is that plugins should be run AFTER "Collecting type info..."

  • testsuite/tests/plugins/T23110.stdout
    1
    +parsePlugin()
    
    2
    +typeCheckPlugin (rn)
    
    3
    +interfacePlugin: GHC.Internal.Tuple
    
    4
    +interfacePlugin: GHC.Internal.Stack.Types
    
    5
    +interfacePlugin: GHC.Internal.Exception.Context
    
    6
    +interfacePlugin: GHC.Internal.TopHandler
    
    7
    +typeCheckPlugin (tc)
    
    8
    +Collecting type info for 1 module(s) ... 
    
    9
    +parsePlugin()
    
    10
    +typeCheckPlugin (rn)
    
    11
    +typeCheckPlugin (tc)

  • testsuite/tests/plugins/all.T
    ... ... @@ -332,6 +332,19 @@ test('T20803b',
    332 332
          compile_fail,
    
    333 333
          ['-package-db T20803-plugin/pkg.T20803b/local.package.conf -fplugin AddErrorPlugin -package T20803-plugin ' + config.plugin_way_flags])
    
    334 334
     
    
    335
    +# Check that we run the plugins for set +c.
    
    336
    +# The .stdout file should contain a call to 'parsePlugin' AFTER
    
    337
    +# the line 'Collecting type info...'
    
    338
    +test('T23110'
    
    339
    +    , [ extra_files([ 'simple-plugin/'])
    
    340
    +      , only_ways(['ghci'])
    
    341
    +      , pre_cmd('$MAKE -s --no-print-directory -C simple-plugin package.simpleplug TOP={top}')
    
    342
    +      , extra_hc_opts('-package-db simple-plugin/pkg.simpleplug/local.package.conf')
    
    343
    +      ]
    
    344
    +    , ghci_script
    
    345
    +    , [ 'T23110.script' ]
    
    346
    +    )
    
    347
    +
    
    335 348
     test('test-echo-in-turn',
    
    336 349
          [extra_files(['echo-plugin/']),
    
    337 350
           pre_cmd('$MAKE -s --no-print-directory -C echo-plugin package.test-echo-in-turn TOP={top}')],
    

  • utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cc.hs
    ... ... @@ -11,6 +11,7 @@ module GHC.Toolchain.Tools.Cc
    11 11
         , compileC
    
    12 12
         , compileAsm
    
    13 13
         , addPlatformDepCcFlags
    
    14
    +    , checkC11Support
    
    14 15
         ) where
    
    15 16
     
    
    16 17
     import Control.Monad
    
    ... ... @@ -50,8 +51,12 @@ findCc archOs llvmTarget progOpt = do
    50 51
         cc1 <- ignoreUnusedArgs cc0
    
    51 52
         cc2 <- ccSupportsTarget archOs llvmTarget cc1
    
    52 53
         checking "whether Cc works" $ checkCcWorks cc2
    
    53
    -    checkCcSupportsExtraViaCFlags cc2
    
    54
    -    return cc2
    
    54
    +    cc3 <- oneOf "cc doesn't support C11" $ map checkC11Support
    
    55
    +        [ cc2
    
    56
    +        , cc2 & _ccFlags %++ "-std=gnu11"
    
    57
    +        ]
    
    58
    +    checkCcSupportsExtraViaCFlags cc3
    
    59
    +    return cc3
    
    55 60
     
    
    56 61
     checkCcWorks :: Cc -> M ()
    
    57 62
     checkCcWorks cc = withTempDir $ \dir -> do
    
    ... ... @@ -83,6 +88,17 @@ ccSupportsTarget archOs target cc =
    83 88
         checking "whether Cc supports --target" $
    
    84 89
         supportsTarget archOs _ccProgram checkCcWorks target cc
    
    85 90
     
    
    91
    +checkC11Support :: Cc -> M Cc
    
    92
    +checkC11Support cc = checking "for C11 support" $ withTempDir $ \dir -> do
    
    93
    +    let test_o = dir </> "test.o"
    
    94
    +    compileC cc test_o $ unlines
    
    95
    +        [ "#include <stdio.h>"
    
    96
    +        , "#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112L"
    
    97
    +        , "# error \"Compiler does not advertise C11 conformance\""
    
    98
    +        , "#endif"
    
    99
    +        ]
    
    100
    +    return cc
    
    101
    +
    
    86 102
     checkCcSupportsExtraViaCFlags :: Cc -> M ()
    
    87 103
     checkCcSupportsExtraViaCFlags cc = checking "whether cc supports extra via-c flags" $ withTempDir $ \dir -> do
    
    88 104
       let test_o = dir </> "test.o"
    

  • utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cpp.hs
    ... ... @@ -19,7 +19,7 @@ import GHC.Toolchain.Prelude
    19 19
     import GHC.Toolchain.Program
    
    20 20
     
    
    21 21
     import GHC.Toolchain.Tools.Cc
    
    22
    -import GHC.Toolchain.Utils (withTempDir, expectFileExists)
    
    22
    +import GHC.Toolchain.Utils (withTempDir, oneOf, expectFileExists)
    
    23 23
     
    
    24 24
     newtype Cpp = Cpp { cppProgram :: Program
    
    25 25
                         }
    
    ... ... @@ -160,7 +160,13 @@ findJsCpp progOpt cc = checking "for JavaScript C preprocessor" $ do
    160 160
     findCmmCpp :: ProgOpt -> Cc -> M CmmCpp
    
    161 161
     findCmmCpp progOpt cc = checking "for a Cmm preprocessor" $ do
    
    162 162
       -- Use the specified CPP or try to use the c compiler
    
    163
    -  cpp <- findProgram "Cmm preprocessor" progOpt [] <|> pure (programFromOpt progOpt (prgPath $ ccProgram cc) [])
    
    163
    +  foundCppProg <- findProgram "Cmm preprocessor" progOpt [] <|> pure (programFromOpt progOpt (prgPath $ ccProgram cc) [])
    
    164
    +  -- Check whether the C preprocessor needs -std=gnu11 (only very old toolchains need this)
    
    165
    +  Cc cpp <- oneOf "cc doesn't support C11" $ map checkC11Support
    
    166
    +        [ Cc foundCppProg
    
    167
    +        , Cc (foundCppProg & _prgFlags %++ "-std=gnu11")
    
    168
    +        ]
    
    169
    +
    
    164 170
       cmmCppSupportsG0 <- withTempDir $ \dir -> do
    
    165 171
         let conftest = dir </> "conftest.c"
    
    166 172
         writeFile conftest "int main(void) {}"
    
    ... ... @@ -175,9 +181,14 @@ findCmmCpp progOpt cc = checking "for a Cmm preprocessor" $ do
    175 181
     findCpp :: ProgOpt -> Cc -> M Cpp
    
    176 182
     findCpp progOpt cc = checking "for C preprocessor" $ do
    
    177 183
       -- Use the specified CPP or try to use the c compiler
    
    178
    -  cpp <- findProgram "C preprocessor" progOpt [] <|> pure (programFromOpt progOpt (prgPath $ ccProgram cc) [])
    
    184
    +  foundCppProg <- findProgram "C preprocessor" progOpt [] <|> pure (programFromOpt progOpt (prgPath $ ccProgram cc) [])
    
    185
    +  -- Check whether the C preprocessor needs -std=gnu11 (only very old toolchains need this)
    
    186
    +  Cc cpp2 <- oneOf "cc doesn't support C11" $ map checkC11Support
    
    187
    +        [ Cc foundCppProg
    
    188
    +        , Cc (foundCppProg & _prgFlags %++ "-std=gnu11")
    
    189
    +        ]
    
    179 190
       -- Always add the -E flag to the CPP, regardless of the user options
    
    180
    -  let cppProgram = addFlagIfNew "-E" cpp
    
    191
    +  let cppProgram = addFlagIfNew "-E" cpp2
    
    181 192
       return Cpp{cppProgram}
    
    182 193
     
    
    183 194
     --------------------------------------------------------------------------------