Cheng Shao pushed to branch wip/no-binary-char-2 at Glasgow Haskell Compiler / GHC Commits: 82d390b5 by Cheng Shao at 2025-12-07T07:49:30+01:00 WIP - - - - - 2 changed files: - compiler/GHC/Data/FastString.hs - compiler/GHC/Iface/Recomp.hs Changes: ===================================== compiler/GHC/Data/FastString.hs ===================================== @@ -55,6 +55,7 @@ module GHC.Data.FastString -- * ShortByteString fastStringToShortByteString, + fastStringToOsPath, mkFastStringShortByteString, -- * ShortText @@ -142,6 +143,7 @@ import System.IO import Data.Data import Data.IORef import Data.Semigroup as Semi +import Data.Type.Coercion (coerceWith, sym) import Foreign @@ -149,6 +151,12 @@ import GHC.Conc.Sync (sharedCAF) import GHC.Exts import GHC.IO +import System.OsString.Internal.Types + ( PosixString(..) + , WindowsString(..) + , coercionToPlatformTypes + ) +import System.OsPath (OsPath) -- | Gives the Modified UTF-8 encoded bytes corresponding to a 'FastString' bytesFS, fastStringToByteString :: FastString -> ByteString @@ -161,6 +169,14 @@ fastStringToByteString = bytesFS fastStringToShortByteString :: FastString -> ShortByteString fastStringToShortByteString = fs_sbs +fastStringToOsPath :: FastString -> OsPath +fastStringToOsPath fs = + case coercionToPlatformTypes of + Left (_cChar, cStr) -> + coerceWith (sym cStr) (WindowsString (fastStringToShortByteString fs)) + Right (_cChar, cStr) -> + coerceWith (sym cStr) (PosixString (fastStringToShortByteString fs)) + fastStringToShortText :: FastString -> ShortText fastStringToShortText = ShortText . fs_sbs ===================================== compiler/GHC/Iface/Recomp.hs ===================================== @@ -53,7 +53,7 @@ import GHC.Utils.Exception import GHC.Utils.Logger import GHC.Utils.Constants (debugIsOn) import qualified GHC.Data.ShortText as ST -import GHC.Data.OsPath (unsafeDecodeUtf) +import GHC.Data.OsPath (OsPath, unsafeDecodeUtf) import GHC.Types.Annotations import GHC.Types.Avail @@ -195,9 +195,9 @@ data RecompReason | ModuleAdded (ImportLevel, UnitId, ModuleName) | ModuleChangedRaw ModuleName | ModuleChangedIface ModuleName - | FileChanged FilePath - | DirChanged FilePath - | CustomReason String + | FileChanged !OsPath + | DirChanged !OsPath + | CustomReason !ST.ShortText | FlagsChanged | LinkFlagsChanged | OptimFlagsChanged @@ -232,9 +232,9 @@ instance Outputable RecompReason where ModuleChangedIface m -> ppr m <+> text "changed (interface)" ModuleRemoved (_st, _uid, m) -> ppr m <+> text "removed" ModuleAdded (_st, _uid, m) -> ppr m <+> text "added" - FileChanged fp -> text fp <+> text "changed" - DirChanged dp -> text "Contents of" <+> text dp <+> text "changed" - CustomReason s -> text s + FileChanged fp -> text (unsafeDecodeUtf fp) <+> text "changed" + DirChanged dp -> text "Contents of" <+> text (unsafeDecodeUtf dp) <+> text "changed" + CustomReason s -> text (ST.unpack s) FlagsChanged -> text "Flags changed" LinkFlagsChanged -> text "Flags changed" OptimFlagsChanged -> text "Optimisation flags changed" @@ -812,10 +812,11 @@ checkModUsage fc UsageFile{ usg_file_path = file, if (old_hash /= new_hash) then return recomp else return UpToDate - where - reason = FileChanged $ unpackFS file - recomp = needsRecompileBecause $ fromMaybe reason $ fmap (CustomReason . ST.unpack) mlabel - handler = if debugIsOn + where + pathOs = fastStringToOsPath file + reason = FileChanged pathOs + recomp = needsRecompileBecause $ fromMaybe reason (CustomReason <$> mlabel) + handler = if debugIsOn then \e -> pprTrace "UsageFile" (text (show e)) $ return recomp else \_ -> return recomp -- if we can't find the file, just recompile, don't fail @@ -828,10 +829,11 @@ checkModUsage fc UsageDirectory{ usg_dir_path = dir, if (old_hash /= new_hash) then return recomp else return UpToDate - where - reason = DirChanged $ unpackFS dir - recomp = needsRecompileBecause $ fromMaybe reason $ fmap (CustomReason . ST.unpack) mlabel - handler = if debugIsOn + where + dirOs = fastStringToOsPath dir + reason = DirChanged dirOs + recomp = needsRecompileBecause $ fromMaybe reason (CustomReason <$> mlabel) + handler = if debugIsOn then \e -> pprTrace "UsageDirectory" (text (show e)) $ return recomp else \_ -> return recomp -- if we can't find the dir, just recompile, don't fail View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/82d390b5649b4de95ba99f50da6059d1... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/82d390b5649b4de95ba99f50da6059d1... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Cheng Shao (@TerrorJack)