Jana Chadt pushed to branch wip/VeryMilkyJoe/no-mod-loc-pat at Glasgow Haskell Compiler / GHC

Commits:

9 changed files:

Changes:

  • compiler/GHC.hs
    ... ... @@ -79,7 +79,13 @@ module GHC (
    79 79
             ModuleGraph, emptyMG, mapMG, mkModuleGraph, mgModSummaries,
    
    80 80
             mgLookupModule,
    
    81 81
             ModSummary(..), ms_mod_name, ModLocation(..),
    
    82
    -        pattern ModLocation,
    
    82
    +        ml_hs_file,
    
    83
    +        ml_hi_file,
    
    84
    +        ml_dyn_hi_file,
    
    85
    +        ml_obj_file,
    
    86
    +        ml_dyn_obj_file,
    
    87
    +        ml_hie_file,
    
    88
    +        ml_bytecode_file,
    
    83 89
             getModSummary,
    
    84 90
             getModuleGraph,
    
    85 91
             isLoaded,
    
    ... ... @@ -457,6 +463,7 @@ import System.Environment ( getEnv, getProgName )
    457 463
     import System.Exit      ( exitWith, ExitCode(..) )
    
    458 464
     import System.FilePath
    
    459 465
     import System.IO.Error  ( isDoesNotExistError )
    
    466
    +import GHC.Data.OsPath (OsPath)
    
    460 467
     
    
    461 468
     #if defined(HAVE_INTERNAL_INTERPRETER)
    
    462 469
     import Foreign.C
    
    ... ... @@ -1575,7 +1582,7 @@ pprParenSymName a = parenSymOcc (getOccName a) (ppr (getName a))
    1575 1582
     -- a module by using 'getModSummary'
    
    1576 1583
     --
    
    1577 1584
     -- XXX: Explain pre-conditions
    
    1578
    -getModuleSourceAndFlags :: ModSummary -> IO (String, StringBuffer, DynFlags)
    
    1585
    +getModuleSourceAndFlags :: ModSummary -> IO (FilePath, StringBuffer, DynFlags)
    
    1579 1586
     getModuleSourceAndFlags m = do
    
    1580 1587
       case ml_hs_file $ ms_location m of
    
    1581 1588
         Nothing -> throwIO $ mkApiErr (ms_hspp_opts m) (text "No source available for module " <+> ppr (ms_mod m))
    

  • compiler/GHC/CoreToStg/AddImplicitBinds.hs
    ... ... @@ -10,7 +10,7 @@ import GHC.Prelude
    10 10
     
    
    11 11
     import GHC.CoreToStg.Prep( CorePrepPgmConfig(..) )
    
    12 12
     
    
    13
    -import GHC.Unit( ModLocation(..) )
    
    13
    +import GHC.Unit( ModLocation(..), ml_hs_file )
    
    14 14
     
    
    15 15
     import GHC.Core
    
    16 16
     import GHC.Core.DataCon( DataCon, dataConWorkId, dataConWrapId )
    

  • compiler/GHC/Data/StringBuffer.hs
    ... ... @@ -56,17 +56,19 @@ module GHC.Data.StringBuffer
    56 56
     import GHC.Prelude
    
    57 57
     
    
    58 58
     import GHC.Data.FastString
    
    59
    +import GHC.Data.OsPath (OsPath)
    
    60
    +import GHC.Fingerprint
    
    59 61
     import GHC.Utils.Encoding
    
    62
    +import GHC.Utils.Exception (bracket_)
    
    60 63
     import GHC.Utils.IO.Unsafe
    
    61 64
     import GHC.Utils.Panic.Plain
    
    62
    -import GHC.Utils.Exception      ( bracket_ )
    
    63
    -import GHC.Fingerprint
    
    64 65
     
    
    65 66
     import Data.Maybe
    
    67
    +import GHC.IO.Encoding.Failure (CodingFailureMode (IgnoreCodingFailure))
    
    68
    +import GHC.IO.Encoding.UTF8 (mkUTF8)
    
    69
    +import System.File.OsPath qualified as FileIO
    
    66 70
     import System.IO
    
    67
    -import System.IO.Unsafe         ( unsafePerformIO )
    
    68
    -import GHC.IO.Encoding.UTF8     ( mkUTF8 )
    
    69
    -import GHC.IO.Encoding.Failure  ( CodingFailureMode(IgnoreCodingFailure) )
    
    71
    +import System.IO.Unsafe (unsafePerformIO)
    
    70 72
     
    
    71 73
     import qualified Data.ByteString.Internal as BS
    
    72 74
     import qualified Data.ByteString as BS
    

  • compiler/GHC/Unit/Module/Location.hs
    ... ... @@ -2,22 +2,19 @@
    2 2
     {-# LANGUAGE ViewPatterns #-}
    
    3 3
     -- | Module location
    
    4 4
     module GHC.Unit.Module.Location
    
    5
    -   ( ModLocation
    
    6
    -    ( ..
    
    7
    -    , ml_hs_file
    
    8
    -    , ml_hi_file
    
    9
    -    , ml_dyn_hi_file
    
    10
    -    , ml_obj_file
    
    11
    -    , ml_dyn_obj_file
    
    12
    -    , ml_hie_file
    
    13
    -    , ml_bytecode_file
    
    14
    -    )
    
    15
    -   , pattern ModLocation
    
    5
    +   ( ModLocation(..)
    
    16 6
        , addBootSuffix
    
    17 7
        , addBootSuffixLocn
    
    18 8
        , addBootSuffixLocnOut
    
    19 9
        , removeBootSuffix
    
    20 10
        , mkFileSrcSpan
    
    11
    +   , ml_hs_file
    
    12
    +   , ml_hi_file
    
    13
    +   , ml_dyn_hi_file
    
    14
    +   , ml_obj_file
    
    15
    +   , ml_dyn_obj_file
    
    16
    +   , ml_hie_file
    
    17
    +   , ml_bytecode_file
    
    21 18
        )
    
    22 19
     where
    
    23 20
     
    
    ... ... @@ -128,33 +125,30 @@ mkFileSrcSpan mod_loc
    128 125
     -- Helpers for backwards compatibility
    
    129 126
     -- ----------------------------------------------------------------------------
    
    130 127
     
    
    131
    -{-# COMPLETE ModLocation #-}
    
    132
    -
    
    133
    -pattern ModLocation :: Maybe FilePath -> FilePath -> FilePath -> FilePath -> FilePath -> FilePath -> FilePath -> ModLocation
    
    134
    -pattern ModLocation
    
    135
    -  { ml_hs_file
    
    136
    -  , ml_hi_file
    
    137
    -  , ml_dyn_hi_file
    
    138
    -  , ml_obj_file
    
    139
    -  , ml_dyn_obj_file
    
    140
    -  , ml_hie_file
    
    141
    -  , ml_bytecode_file
    
    142
    -  } <- OsPathModLocation
    
    143
    -    { ml_hs_file_ospath = (fmap unsafeDecodeUtf -> ml_hs_file)
    
    144
    -    , ml_hi_file_ospath = (unsafeDecodeUtf -> ml_hi_file)
    
    145
    -    , ml_dyn_hi_file_ospath = (unsafeDecodeUtf -> ml_dyn_hi_file)
    
    146
    -    , ml_obj_file_ospath = (unsafeDecodeUtf -> ml_obj_file)
    
    147
    -    , ml_dyn_obj_file_ospath = (unsafeDecodeUtf -> ml_dyn_obj_file)
    
    148
    -    , ml_hie_file_ospath = (unsafeDecodeUtf -> ml_hie_file)
    
    149
    -    , ml_bytecode_file_ospath = (unsafeDecodeUtf -> ml_bytecode_file)
    
    150
    -    } where
    
    151
    -      ModLocation ml_hs_file ml_hi_file ml_dyn_hi_file ml_obj_file ml_dyn_obj_file ml_hie_file ml_bytecode_file
    
    152
    -        = OsPathModLocation
    
    153
    -          { ml_hs_file_ospath = fmap unsafeEncodeUtf ml_hs_file
    
    154
    -          , ml_hi_file_ospath = unsafeEncodeUtf ml_hi_file
    
    155
    -          , ml_dyn_hi_file_ospath = unsafeEncodeUtf ml_dyn_hi_file
    
    156
    -          , ml_obj_file_ospath = unsafeEncodeUtf ml_obj_file
    
    157
    -          , ml_dyn_obj_file_ospath = unsafeEncodeUtf ml_dyn_obj_file
    
    158
    -          , ml_hie_file_ospath = unsafeEncodeUtf ml_hie_file
    
    159
    -          , ml_bytecode_file_ospath = unsafeEncodeUtf ml_bytecode_file
    
    160
    -          }
    128
    +ml_hs_file :: ModLocation -> Maybe FilePath
    
    129
    +{-# INLINE ml_hs_file #-}
    
    130
    +ml_hs_file = fmap unsafeDecodeUtf . ml_hs_file_ospath
    
    131
    +
    
    132
    +ml_hi_file :: ModLocation -> FilePath
    
    133
    +{-# INLINE ml_hi_file #-}
    
    134
    +ml_hi_file = unsafeDecodeUtf . ml_hi_file_ospath
    
    135
    +
    
    136
    +ml_dyn_hi_file :: ModLocation -> FilePath
    
    137
    +{-# INLINE ml_dyn_hi_file #-}
    
    138
    +ml_dyn_hi_file = unsafeDecodeUtf . ml_dyn_hi_file_ospath
    
    139
    +
    
    140
    +ml_obj_file :: ModLocation -> FilePath
    
    141
    +{-# INLINE ml_obj_file #-}
    
    142
    +ml_obj_file = unsafeDecodeUtf . ml_obj_file_ospath
    
    143
    +
    
    144
    +ml_dyn_obj_file :: ModLocation -> FilePath
    
    145
    +{-# INLINE ml_dyn_obj_file #-}
    
    146
    +ml_dyn_obj_file = unsafeDecodeUtf . ml_dyn_obj_file_ospath
    
    147
    +
    
    148
    +ml_hie_file :: ModLocation -> FilePath
    
    149
    +{-# INLINE ml_hie_file #-}
    
    150
    +ml_hie_file = unsafeDecodeUtf . ml_hie_file_ospath
    
    151
    +
    
    152
    +ml_bytecode_file :: ModLocation -> FilePath
    
    153
    +{-# INLINE ml_bytecode_file #-}
    
    154
    +ml_bytecode_file = unsafeDecodeUtf . ml_bytecode_file_ospath

  • compiler/GHC/Unit/Module/ModSummary.hs
    ... ... @@ -46,7 +46,7 @@ import GHC.Types.PkgQual
    46 46
     import GHC.Types.Basic
    
    47 47
     
    
    48 48
     import GHC.Data.Maybe
    
    49
    -import GHC.Data.OsPath (OsPath)
    
    49
    +import GHC.Data.OsPath ( OsPath )
    
    50 50
     import GHC.Data.StringBuffer ( StringBuffer )
    
    51 51
     
    
    52 52
     import GHC.Utils.Fingerprint
    

  • compiler/ghc.cabal.in
    ... ... @@ -125,6 +125,7 @@ Library
    125 125
                        containers >= 0.6.2.1 && < 0.9,
    
    126 126
                        array      >= 0.1 && < 0.6,
    
    127 127
                        filepath   >= 1.5 && < 1.6,
    
    128
    +                   file-io    >= 0.1.5 && < 0.3,
    
    128 129
                        os-string  >= 2.0.1 && < 2.1,
    
    129 130
                        hpc        >= 0.6 && < 0.8,
    
    130 131
                        transformers >= 0.5 && < 0.7,
    

  • hadrian/cabal.project.local
    1
    +ignore-project: False
    
    2
    +with-compiler: ghc-9.10.3

  • testsuite/tests/ghc-api/fixed-nodes/FixedNodes.hs
    ... ... @@ -31,7 +31,7 @@ convertToFixed (ModuleNodeCompile ms) =
    31 31
       -- with the module summary information
    
    32 32
       let modName = ms_mod_name ms
    
    33 33
           modLoc = ms_location ms
    
    34
    -  in ModuleNodeFixed (msKey ms) (ms_location ms) { ml_hs_file = Nothing}
    
    34
    +  in ModuleNodeFixed (msKey ms) (ms_location ms) { ml_hs_file_ospath = Nothing }
    
    35 35
     
    
    36 36
     
    
    37 37
     -- | Load a module graph and report the result
    

  • testsuite/tests/ghc-api/fixed-nodes/ModuleGraphInvariants.hs
    ... ... @@ -29,7 +29,7 @@ convertToFixed :: ModuleNodeInfo -> ModuleNodeInfo
    29 29
     convertToFixed (ModuleNodeCompile ms) =
    
    30 30
       let modName = ms_mod_name ms
    
    31 31
           modLoc = ms_location ms
    
    32
    -  in ModuleNodeFixed (msKey ms) (ms_location ms) { ml_hs_file = Nothing}
    
    32
    +  in ModuleNodeFixed (msKey ms) (ms_location ms) { ml_hs_file_ospath = Nothing }
    
    33 33
     
    
    34 34
     -- | Test a module graph and report if it matches expected invariant violations
    
    35 35
     testModuleGraph :: String -> ModuleGraph -> [ModuleGraphInvariantError] -> Ghc ()