Torsten Schmits pushed to branch wip/torsten.schmits/worker-debug at Glasgow Haskell Compiler / GHC

Commits:

4 changed files:

Changes:

  • compiler/GHC/Driver/Backpack.hs
    ... ... @@ -91,6 +91,7 @@ import Data.Map (Map)
    91 91
     import qualified Data.Map as Map
    
    92 92
     import qualified Data.Set as Set
    
    93 93
     import GHC.Types.Error (mkUnknownDiagnostic)
    
    94
    +import System.OsPath (unsafeEncodeUtf)
    
    94 95
     
    
    95 96
     -- | Entry point to compile a Backpack file.
    
    96 97
     doBackpack :: [FilePath] -> Ghc ()
    
    ... ... @@ -433,7 +434,7 @@ addUnit u = do
    433 434
             Nothing  -> panic "addUnit: called too early"
    
    434 435
             Just dbs ->
    
    435 436
              let newdb = UnitDatabase
    
    436
    -               { unitDatabasePath  = "(in memory " ++ showSDoc dflags0 (ppr (unitId u)) ++ ")"
    
    437
    +               { unitDatabasePath  = unsafeEncodeUtf $ "(in memory " ++ showSDoc dflags0 (ppr (unitId u)) ++ ")"
    
    437 438
                    , unitDatabaseUnits = [u]
    
    438 439
                    }
    
    439 440
              in return (dbs ++ [newdb]) -- added at the end because ordering matters
    

  • compiler/GHC/Driver/DynFlags.hs
    ... ... @@ -134,6 +134,7 @@ import System.IO.Error (catchIOError)
    134 134
     import System.Environment (lookupEnv)
    
    135 135
     import System.FilePath (normalise, (</>))
    
    136 136
     import System.Directory
    
    137
    +import System.OsPath (OsPath)
    
    137 138
     import GHC.Foreign (withCString, peekCString)
    
    138 139
     
    
    139 140
     import qualified Data.Set as Set
    
    ... ... @@ -948,7 +949,7 @@ setDynamicNow dflags0 =
    948 949
     data PkgDbRef
    
    949 950
       = GlobalPkgDb
    
    950 951
       | UserPkgDb
    
    951
    -  | PkgDbPath FilePath
    
    952
    +  | PkgDbPath OsPath
    
    952 953
       deriving Eq
    
    953 954
     
    
    954 955
     -- | Used to differentiate the scope an include needs to apply to.
    

  • compiler/GHC/Driver/Session.hs
    ... ... @@ -278,6 +278,7 @@ import qualified Data.Map as Map
    278 278
     import qualified Data.Set as Set
    
    279 279
     import Data.Word
    
    280 280
     import System.FilePath
    
    281
    +import System.OsPath (unsafeEncodeUtf)
    
    281 282
     import Text.ParserCombinators.ReadP hiding (char)
    
    282 283
     import Text.ParserCombinators.ReadP as R
    
    283 284
     
    
    ... ... @@ -1962,7 +1963,7 @@ package_flags_deps :: [(Deprecation, Flag (CmdLineP DynFlags))]
    1962 1963
     package_flags_deps = [
    
    1963 1964
             ------- Packages ----------------------------------------------------
    
    1964 1965
         make_ord_flag defFlag "package-db"
    
    1965
    -      (HasArg (addPkgDbRef . PkgDbPath))
    
    1966
    +      (HasArg (addPkgDbRef . PkgDbPath . unsafeEncodeUtf))
    
    1966 1967
       , make_ord_flag defFlag "clear-package-db"      (NoArg clearPkgDb)
    
    1967 1968
       , make_ord_flag defFlag "no-global-package-db"  (NoArg removeGlobalPkgDb)
    
    1968 1969
       , make_ord_flag defFlag "no-user-package-db"    (NoArg removeUserPkgDb)
    
    ... ... @@ -1972,7 +1973,7 @@ package_flags_deps = [
    1972 1973
           (NoArg (addPkgDbRef UserPkgDb))
    
    1973 1974
         -- backwards compat with GHC<=7.4 :
    
    1974 1975
       , make_dep_flag defFlag "package-conf"
    
    1975
    -      (HasArg $ addPkgDbRef . PkgDbPath) "Use -package-db instead"
    
    1976
    +      (HasArg $ addPkgDbRef . PkgDbPath . unsafeEncodeUtf) "Use -package-db instead"
    
    1976 1977
       , make_dep_flag defFlag "no-user-package-conf"
    
    1977 1978
           (NoArg removeUserPkgDb)              "Use -no-user-package-db instead"
    
    1978 1979
       , make_ord_flag defGhcFlag "package-name"       (HasArg $ \name ->
    
    ... ... @@ -3377,7 +3378,7 @@ parseEnvFile :: FilePath -> String -> DynP ()
    3377 3378
     parseEnvFile envfile = mapM_ parseEntry . lines
    
    3378 3379
       where
    
    3379 3380
         parseEntry str = case words str of
    
    3380
    -      ("package-db": _)     -> addPkgDbRef (PkgDbPath (envdir </> db))
    
    3381
    +      ("package-db": _)     -> addPkgDbRef (PkgDbPath (unsafeEncodeUtf (envdir </> db)))
    
    3381 3382
             -- relative package dbs are interpreted relative to the env file
    
    3382 3383
             where envdir = takeDirectory envfile
    
    3383 3384
                   db     = drop 11 str
    

  • compiler/GHC/Unit/State.hs
    ... ... @@ -109,6 +109,8 @@ import GHC.Utils.Exception
    109 109
     
    
    110 110
     import System.Directory
    
    111 111
     import System.FilePath as FilePath
    
    112
    +import System.OsPath (OsPath, decodeUtf, unsafeEncodeUtf)
    
    113
    +import qualified System.OsPath as OsPath
    
    112 114
     import Control.Monad
    
    113 115
     import Data.Graph (stronglyConnComp, SCC(..))
    
    114 116
     import Data.Char ( toUpper )
    
    ... ... @@ -405,7 +407,7 @@ initUnitConfig dflags cached_dbs home_units =
    405 407
     
    
    406 408
       where
    
    407 409
         offsetPackageDb :: Maybe FilePath -> PackageDBFlag -> PackageDBFlag
    
    408
    -    offsetPackageDb (Just offset) (PackageDB (PkgDbPath p)) | isRelative p = PackageDB (PkgDbPath (offset </> p))
    
    410
    +    offsetPackageDb (Just offset) (PackageDB (PkgDbPath p)) | OsPath.isRelative p = PackageDB (PkgDbPath (OsPath.unsafeEncodeUtf offset OsPath.</> p))
    
    409 411
         offsetPackageDb _ p = p
    
    410 412
     
    
    411 413
     
    
    ... ... @@ -500,12 +502,12 @@ emptyUnitState = UnitState {
    500 502
     
    
    501 503
     -- | Unit database
    
    502 504
     data UnitDatabase unit = UnitDatabase
    
    503
    -   { unitDatabasePath  :: FilePath
    
    505
    +   { unitDatabasePath  :: OsPath
    
    504 506
        , unitDatabaseUnits :: [GenUnitInfo unit]
    
    505 507
        }
    
    506 508
     
    
    507 509
     instance Outputable u => Outputable (UnitDatabase u) where
    
    508
    -  ppr (UnitDatabase fp _u) = text "DB:" <+> text fp
    
    510
    +  ppr (UnitDatabase fp _u) = text "DB:" <+> text (fromMaybe "invalid path" (decodeUtf fp))
    
    509 511
     
    
    510 512
     type UnitInfoMap = UniqMap UnitId UnitInfo
    
    511 513
     
    
    ... ... @@ -720,9 +722,9 @@ getUnitDbRefs cfg = do
    720 722
             Left _ -> system_conf_refs
    
    721 723
             Right path
    
    722 724
              | Just (xs, x) <- snocView path, isSearchPathSeparator x
    
    723
    -         -> map PkgDbPath (splitSearchPath xs) ++ system_conf_refs
    
    725
    +         -> map (PkgDbPath . unsafeEncodeUtf) (splitSearchPath xs) ++ system_conf_refs
    
    724 726
              | otherwise
    
    725
    -         -> map PkgDbPath (splitSearchPath path)
    
    727
    +         -> map (PkgDbPath . unsafeEncodeUtf) (splitSearchPath path)
    
    726 728
     
    
    727 729
       -- Apply the package DB-related flags from the command line to get the
    
    728 730
       -- final list of package DBs.
    
    ... ... @@ -758,7 +760,7 @@ resolveUnitDatabase cfg UserPkgDb = runMaybeT $ do
    758 760
       let pkgconf = dir </> unitConfigDBName cfg
    
    759 761
       exist <- tryMaybeT $ doesDirectoryExist pkgconf
    
    760 762
       if exist then return pkgconf else mzero
    
    761
    -resolveUnitDatabase _ (PkgDbPath name) = return $ Just name
    
    763
    +resolveUnitDatabase _ (PkgDbPath name) = return $ Just (fromMaybe undefined (decodeUtf name))
    
    762 764
     
    
    763 765
     readUnitDatabase :: Logger -> UnitConfig -> FilePath -> IO (UnitDatabase UnitId)
    
    764 766
     readUnitDatabase logger cfg conf_file = do
    
    ... ... @@ -790,7 +792,7 @@ readUnitDatabase logger cfg conf_file = do
    790 792
           pkg_configs1 = map (mungeUnitInfo top_dir pkgroot . mapUnitInfo (\(UnitKey x) -> UnitId x) . mkUnitKeyInfo)
    
    791 793
                              proto_pkg_configs
    
    792 794
       --
    
    793
    -  return $ UnitDatabase conf_file' pkg_configs1
    
    795
    +  return $ UnitDatabase (unsafeEncodeUtf conf_file') pkg_configs1
    
    794 796
       where
    
    795 797
         readDirStyleUnitInfo conf_dir = do
    
    796 798
           let filename = conf_dir </> "package.cache"
    
    ... ... @@ -1388,7 +1390,7 @@ mergeDatabases logger = foldM merge (emptyUniqMap, emptyUniqMap) . zip [1..]
    1388 1390
       where
    
    1389 1391
         merge (pkg_map, prec_map) (i, UnitDatabase db_path db) = do
    
    1390 1392
           debugTraceMsg logger 2 $
    
    1391
    -          text "loading package database" <+> text db_path
    
    1393
    +          text "loading package database" <+> text (fromMaybe "invalid path" (decodeUtf db_path))
    
    1392 1394
           forM_ (Set.toList override_set) $ \pkg ->
    
    1393 1395
               debugTraceMsg logger 2 $
    
    1394 1396
                   text "package" <+> ppr pkg <+>