[Git][ghc/ghc][wip/spj-reinstallable-base2] 3 commits: Trying to fix horrendous blackhole hang in almost every compiled
Rodrigo Mesquita pushed to branch wip/spj-reinstallable-base2 at Glasgow Haskell Compiler / GHC Commits: 83639740 by Rodrigo Mesquita at 2026-05-21T11:51:57+01:00 Trying to fix horrendous blackhole hang in almost every compiled Required fixing plugins, which were broken too! - - - - - dc475bf4 by Rodrigo Mesquita at 2026-05-22T16:25:41+01:00 fix runtime loop with Simon - - - - - 563805cc by Rodrigo Mesquita at 2026-05-22T16:56:22+01:00 tweaks, finally running the testsuite! - - - - - 6 changed files: - compiler/GHC/Builtin/WiredIn/Types.hs - libraries/ghc-experimental/src/Data/Sum/Experimental.hs - libraries/ghc-experimental/src/Prelude/Experimental.hs - libraries/ghc-internal/src/GHC/Internal/Data/Typeable/Internal.hs - libraries/ghc-internal/src/GHC/Internal/IO/Encoding/UTF8.hs - libraries/template-haskell/Language/Haskell/TH/Lib.hs Changes: ===================================== compiler/GHC/Builtin/WiredIn/Types.hs ===================================== @@ -2898,10 +2898,10 @@ pLUGINS :: Module pLUGINS = mkThisGhcModule (fsLit "GHC.Driver.Plugins") pluginTyConName :: Name -pluginTyConName = mkKnownKeyName pluginTyConKey pLUGINS (mkOccName tcName "Plugin") noSrcSpan +pluginTyConName = mkExternalName pluginTyConKey pLUGINS (mkOccName tcName "Plugin") noSrcSpan frontendPluginTyConName :: Name -frontendPluginTyConName = mkKnownKeyName frontendPluginTyConKey pLUGINS (mkOccName tcName "FrontendPlugin") noSrcSpan +frontendPluginTyConName = mkExternalName frontendPluginTyConKey pLUGINS (mkOccName tcName "FrontendPlugin") noSrcSpan {- ************************************************************************ ===================================== libraries/ghc-experimental/src/Data/Sum/Experimental.hs ===================================== @@ -1,4 +1,4 @@ -{-# LANGUAGE Trustworthy #-} +{-# LANGUAGE Safe #-} {-# LANGUAGE NoImplicitPrelude, MagicHash, UnboxedSums, NoListTuplePuns #-} {- ===================================== libraries/ghc-experimental/src/Prelude/Experimental.hs ===================================== @@ -1,4 +1,9 @@ +{-# LANGUAGE CPP #-} +#if __GLASGOW_HASKELL__ >= 1001 +{-# LANGUAGE Safe #-} +#else {-# LANGUAGE Trustworthy #-} +#endif {-# LANGUAGE NoImplicitPrelude #-} {-# OPTIONS_HADDOCK not-home #-} ===================================== libraries/ghc-internal/src/GHC/Internal/Data/Typeable/Internal.hs ===================================== @@ -209,7 +209,7 @@ data TypeRep a where -- 'Just and the trKindVars will be [Bool]. , trTyCon :: !TyCon , trKindVars :: [SomeTypeRep] - , trTyConKind :: !(TypeRep k) } -- See Note [Kind caching] + , trTyConKind :: TypeRep k } -- See Note [Kind caching] -> TypeRep (a :: k) -- | Invariant: Saturated arrow types (e.g. things of the form @a -> b@) @@ -318,14 +318,31 @@ There are two things we need to be careful about when caching kinds. Wrinkle 1: -We want to do it eagerly. Suppose we have +The kind cache must be a /lazy/ field because, otherwise, we get a runtime loop: - tf :: TypeRep (f :: j -> k) - ta :: TypeRep (a :: j) + consider: + $tcTYPE = TyCon fp1 fp2 mod "TYPE"# krep01 + krep01 = KindRepFun (KindRepTyConApp $tcRuntimeRep []) KindRepType -Then the cached kind of App tf ta should be eagerly evaluated to k, rather -than being stored as a thunk that will strip the (j ->) off of j -> k if -and when it is forced. + typeRep @TYPE + = mkTrCon $tcTYPE + = TrTyCon { tc, cachedKrep = instantiateKindRep krep01 } + + evaluating instantiateKindRep (KindRepFun ...) eagerly, will require + computing the fingerprint of tyConTYPE: + + tyConTYPE = typeRepTyCon (typeRep @TYPE) + = typeRepTyCon (mkTrCon $tcTYPE []) + + which in turn requires computing (mkTrCon $tcTYPE) again, which requires + computing the kind cache again, which is where we started. If we don't + compute the Kind cache, we can return the $tcTYPE straight away in a TrTyCon. + + Really, if we could say tyConTYPE = $tcTYPE, we would avoid the entire thing. + + This is very delicate, and it is essentially only necessary for TYPE. + Making the kind cache lazy suffices, but the overall design could be + potentially improved to avoid this subtlessness. Wrinkle 2: @@ -338,9 +355,10 @@ But we *do not* want TypeReps to have cyclical structure! Most importantly, a cyclical structure cannot be stored in a compact region. Secondarily, using :force in GHCi on a cyclical structure will lead to non-termination. -To avoid this trouble, we use a separate constructor for TypeRep Type. +To avoid this trouble, we use a separate constructor for TypeRep Type, +namely, TrType. mkTrApp is responsible for recognizing that TYPE is being applied to -'LiftedRep and produce trType; other functions must recognize that TrType +'LiftedRep and produce TrType; other functions must recognize that TrType represents an application. -} ===================================== libraries/ghc-internal/src/GHC/Internal/IO/Encoding/UTF8.hs ===================================== @@ -47,6 +47,8 @@ import GHC.Internal.Prim ( ) import GHC.Internal.Word import GHC.Internal.Data.Bits +import qualified GHC.Internal.IO.Exception as Rebindable +import qualified GHC.Internal.Stack.Types as Rebindable utf8 :: TextEncoding utf8 = mkUTF8 ErrorOnCodingFailure ===================================== libraries/template-haskell/Language/Haskell/TH/Lib.hs ===================================== @@ -1,4 +1,5 @@ {-# LANGUAGE Safe #-} +{-# LANGUAGE CPP #-} -- | -- Language.Haskell.TH.Lib contains lots of useful helper functions for @@ -180,8 +181,10 @@ import GHC.Boot.TH.Lib hiding , conP +#if __GLASGOW_HASKELL__ < 1001 , Role , InjectivityAnn +#endif ) import qualified GHC.Boot.TH.Lib as Internal import Language.Haskell.TH.Syntax View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ee1cc94e5be0570b7bb1310659f8f9a... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ee1cc94e5be0570b7bb1310659f8f9a... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Rodrigo Mesquita (@alt-romes)