[Git][ghc/ghc][wip/romes/async-rpc] fixup! fixup! ignore PipeReadClosedException on Shutdown.
by Andrea Vezzosi (@trac-Saizan) 20 Oct '26
by Andrea Vezzosi (@trac-Saizan) 20 Oct '26
20 Oct '26
Andrea Vezzosi pushed to branch wip/romes/async-rpc at Glasgow Haskell Compiler / GHC
Commits:
3db528a9 by Andrea Vezzosi at 2026-10-20T12:12:48+02:00
fixup! fixup! ignore PipeReadClosedException on Shutdown.
- - - - -
1 changed file:
- libraries/ghci/GHCi/Message/Async.hs
Changes:
=====================================
libraries/ghci/GHCi/Message/Async.hs
=====================================
@@ -50,7 +50,6 @@ import qualified Data.ByteString.Lazy as LB
import Data.IORef
import Data.IntMap (IntMap)
import qualified Data.IntMap as IntMap
-import Data.Maybe
import GHC.Generics
import System.Exit
import System.IO
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3db528a9c439568d900e150f3968663…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3db528a9c439568d900e150f3968663…
You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
1
0
[Git][ghc/ghc][wip/romes/async-rpc] fixup! ignore PipeReadClosedException on Shutdown.
by Andrea Vezzosi (@trac-Saizan) 20 Oct '26
by Andrea Vezzosi (@trac-Saizan) 20 Oct '26
20 Oct '26
Andrea Vezzosi pushed to branch wip/romes/async-rpc at Glasgow Haskell Compiler / GHC
Commits:
48d9f5a1 by Andrea Vezzosi at 2026-10-20T11:58:19+02:00
fixup! ignore PipeReadClosedException on Shutdown.
- - - - -
1 changed file:
- libraries/ghci/GHCi/Message/Async.hs
Changes:
=====================================
libraries/ghci/GHCi/Message/Async.hs
=====================================
@@ -128,7 +128,10 @@ closePipe p@Pipe{..} = do
failPendingReplies p (toException PipeReadClosedException)
pure closed
- writeAlreadyClosed <- readTVarIO pipeWriteClosed
+ writeAlreadyClosed <- atomically $ do
+ closed <- readTVar pipeWriteClosed
+ failPendingWrites p (toException PipeWriteClosedException)
+ pure closed
unless writeAlreadyClosed (withLock p pipeCloseWrite)
`finally` do
@@ -152,11 +155,14 @@ instance Exception PipeWriteClosedException
-- and identify whether they are requests or replies.
writePipe :: Pipe -> IddMsg -> IO ()
-writePipe Pipe{..} msg = atomically $ do
- readTVar pipeWriteClosed >>= \case
- True -> throwSTM PipeWriteClosedException
- False -> pure ()
- writeTQueue (writeQueue pipeAsyncMngr) msg
+writePipe Pipe{..} msg = do
+ var <- newEmptyTMVarIO
+ atomically $ do
+ readTVar pipeWriteClosed >>= \case
+ True -> throwSTM PipeWriteClosedException
+ False -> pure ()
+ writeTQueue (writeQueue pipeAsyncMngr) (msg, var)
+ either throwIO pure =<< atomically (takeTMVar var)
-- | Only the 'drainPipe' thread should read from the pipe directly. Other
-- functions should wait for the matching reply to be delivered asynchronously.
@@ -345,7 +351,7 @@ data AsyncManager = AsyncManager
, mailboxQueues :: !(TVar (IntMap (TQueue (CorrelationId, LB.ByteString))))
-- ^ Requests for a specific 'InboxId' that can be read using
-- @'handleAsyncReq' p get (Just <mailboxid>)@.
- , writeQueue :: !(TQueue IddMsg)
+ , writeQueue :: !(TQueue (IddMsg, TMVar (Either SomeException ())))
-- ^ Messages to write on the pipe.
, asyncDrainTid :: !ThreadId
, asyncFillTid :: !ThreadId
@@ -453,26 +459,26 @@ drainPipe p unmask = catch (unmask $ loop `finally` pipeCloseRead p) replyToPend
-- | "Fill"s write end of the Pipe with queues messages.
--
--- Closes the Pipe write end when stopping, notifying any requests still queued to write.
+-- Because Pipe is written to from this thread rather than 'writePipe', calls to
+-- the latter can be interrupted without compromising the protocol.
+--
+-- Closes the Pipe write end when stopping, notifying any messages still queued to write.
fillPipe :: Pipe -> (forall x. IO x -> IO x) -> IO ()
-fillPipe p unmask = unmask $ catch (loop `finally` pipeCloseWrite p) failPendingWrites where
+fillPipe p unmask = catch (loop `finally` pipeCloseWrite p) (atomically . failPendingWrites p) where
loop = do
- msg <- atomically $ readTQueue (writeQueue am)
- withLock p . putAll p . execPut . put $ msg
+ (msg,var) <- atomically $ readTQueue (writeQueue am)
+ unmask (withLock p (putAll p . execPut . put $ msg))
+ `catch` \ e -> atomically (putTMVar var (Left e)) >> throwIO e
+ atomically $ putTMVar var (Right ())
loop
am = pipeAsyncMngr p
- failPendingWrites :: SomeException -> IO ()
- failPendingWrites e = atomically $ do
- writeTVar (pipeWriteClosed p) True
-
- writes <- flushTQueue (writeQueue am)
- let uqs = [uq | Request uq _ _ <- writes]
- pendings <- readTVar (pendingReply (pipeAsyncMngr p))
- let tmvars = mapMaybe (`IntMap.lookup` pendings) uqs
- writeTVar (pendingReply (pipeAsyncMngr p)) $! (foldl' (flip IntMap.delete) pendings uqs)
- mapM_ (`writeTMVar` Left e) tmvars
+failPendingWrites :: Pipe -> SomeException -> STM ()
+failPendingWrites p e = do
+ writeTVar (pipeWriteClosed p) True
+ writes <- flushTQueue (writeQueue (pipeAsyncMngr p))
+ mapM_ (`writeTMVar` Left e) (map snd writes)
failPendingReplies :: Pipe -> SomeException -> STM ()
failPendingReplies p e = do
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/48d9f5a1ed4ebda8c59133a7c259b78…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/48d9f5a1ed4ebda8c59133a7c259b78…
You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
1
0
[Git][ghc/ghc][wip/romes/async-rpc] ignore PipeReadClosedException on Shutdown.
by Andrea Vezzosi (@trac-Saizan) 20 Oct '26
by Andrea Vezzosi (@trac-Saizan) 20 Oct '26
20 Oct '26
Andrea Vezzosi pushed to branch wip/romes/async-rpc at Glasgow Haskell Compiler / GHC
Commits:
5a897150 by Andrea Vezzosi at 2026-10-20T09:53:52+02:00
ignore PipeReadClosedException on Shutdown.
- - - - -
2 changed files:
- compiler/GHC/Runtime/Interpreter.hs
- libraries/ghci/GHCi/Server.hs
Changes:
=====================================
compiler/GHC/Runtime/Interpreter.hs
=====================================
@@ -653,7 +653,7 @@ stopInterp interp = case interpInstance interp of
ex <- getProcessExitCode (interpHandle (instProcess i))
if isJust ex
then pure ()
- else sendMessage i Shutdown
+ else sendMessage i Shutdown `catch` \ PipeReadClosedException -> pure ()
-- We asked the server to shutdown, so we will also shutdown any communication.
closePipe (interpPipe (instProcess i))
pure InterpPending
=====================================
libraries/ghci/GHCi/Server.hs
=====================================
@@ -209,8 +209,6 @@ defaultServerWithCustom customHandler = do
uninterruptibleMask $ \restore -> servWithCustom verbose hook pipe restore customHandler
where hook = return -- empty hook
- -- we cannot allow any async exceptions while communicating, because
- -- we will lose sync in the protocol, hence uninterruptibleMask.
dieWithUsage :: IO a
dieWithUsage = do
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5a897150dceaac9a502bf3a095bc974…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5a897150dceaac9a502bf3a095bc974…
You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
1
0
[Git][ghc/ghc][wip/fendor/dep-stdout] Add support for streaming `ghc -M` to stdout
by Hannes Siebenhandl (@fendor) 20 Oct '26
by Hannes Siebenhandl (@fendor) 20 Oct '26
20 Oct '26
Hannes Siebenhandl pushed to branch wip/fendor/dep-stdout at Glasgow Haskell Compiler / GHC
Commits:
252c5b3e by fendor at 2026-10-20T10:13:05+02:00
Add support for streaming `ghc -M` to stdout
Adds the flags `-dep-json-stdout` and `-dep-makefile-stdout` which
streams dependency information line-by-line to stdout.
Each dependency generation can be redirected to separate outputs.
Providing any extra `-dep-{json,makefile}[-stdout]` disables the default
generation of the `Makefile` file.
Allows consumers to start processing the dependency information as it
comes in and not waiting for the dependency generation to finish.
`DepStream` abstracts over the possible output handles, which is either
a file or the stdout handle.
Writing to a file requires temporary file paths, thus `DepStream` must
provide a way to perform clean up when dependency processing finished or
when an error is thrown for any reason.
We further decouple the rendering and writing of the result from the
dependency generation, localising side effects and making the code
slightly more readable.
Closes #27937
- - - - -
5 changed files:
- + changelog.d/make-depends-streaming-output
- compiler/GHC/Driver/DynFlags.hs
- compiler/GHC/Driver/MakeFile.hs
- compiler/GHC/Driver/Session.hs
- docs/users_guide/separate_compilation.rst
Changes:
=====================================
changelog.d/make-depends-streaming-output
=====================================
@@ -0,0 +1,16 @@
+section: compiler
+synopsis: Allow streaming `ghc -M` output to stdout
+issues: #27937
+mrs: !16830
+description: {
+ Add option `-dep-makefile-stdout` and `-dep-json-stdout` which stream the dependency generation
+ output to stdout.
+
+ The Makefile and json dependency generation can stream to separate targets, e.g. `-dep-makefile target.Makefile -dep-json-stdout`
+ streams the JSON Lines output to stdout and the Makefile to `target.Makefile`.
+
+ If `-dep-makefile-stdout`, `-dep-json` or `-dep-json-stdout` is given, we no longer generate a Makefile by default, but only
+ if the user explicitly requests the Makefile dependency generation.
+
+ The output from a particular backend can be disabled via `-no-dep-json` and `-no-dep-makefile` respectively.
+}
=====================================
compiler/GHC/Driver/DynFlags.hs
=====================================
@@ -73,6 +73,9 @@ module GHC.Driver.DynFlags (
IncludeSpecs(..), addGlobalInclude, addQuoteInclude, flattenIncludes,
addImplicitQuoteInclude,
+ -- * `ghc -M` specification
+ MkDependOutput(..),
+
-- * SDoc
initSDocContext, initDefaultSDocContext,
initPromotionTickContext,
@@ -350,8 +353,8 @@ data DynFlags = DynFlags {
-- ^ External plugins loaded from shared libraries
-- For ghc -M
- depMakefile :: Maybe FilePath,
- depJson :: Maybe FilePath,
+ depMakefile :: MkDependOutput,
+ depJson :: MkDependOutput,
depIncludePkgDeps :: Bool,
depIncludeCppDeps :: Bool,
depExcludeMods :: [ModuleName],
@@ -694,8 +697,8 @@ defaultDynFlags mySettings =
llvmOptLevel = 0,
-- ghc -M values
- depMakefile = Just "Makefile",
- depJson = Nothing,
+ depMakefile = MkDepend_Default "Makefile",
+ depJson = MkDepend_None,
depIncludePkgDeps = False,
depIncludeCppDeps = False,
depExcludeMods = [],
@@ -801,6 +804,15 @@ flattenExtensionFlags ml = foldr g defaultExtensionFlags
g (Off f) flags = EnumSet.delete f flags
defaultExtensionFlags = EnumSet.fromList (languageExtensions ml)
+-- -----------------------------------------------------------------------------
+-- -M -dep-*
+
+data MkDependOutput
+ = MkDepend_None
+ | MkDepend_Default !FilePath
+ | MkDepend_Explicit !FilePath
+ | MkDepend_StdOut
+
-- -----------------------------------------------------------------------------
-- -jN
=====================================
compiler/GHC/Driver/MakeFile.hs
=====================================
@@ -132,7 +132,7 @@ doMkDepend = do
module_graph <- GHC.depanal excl_mods True {- Allow dup roots -}
doMkDependModuleGraph dflags module_graph
-doMkDependModuleGraph :: GhcMonad m => DynFlags -> ModuleGraph -> m ()
+doMkDependModuleGraph :: GhcMonad m => DynFlags -> ModuleGraph -> m ()
doMkDependModuleGraph dflags module_graph = do
hsc_env <- getSession
logger <- getLogger
@@ -143,12 +143,14 @@ doMkDependModuleGraph dflags module_graph = do
root <- liftIO Directory.getCurrentDirectory
let
+ suffixes = fmap unsafeEncodeUtf (depSuffixes dflags)
+ tmpdir = tmpDir dflags
backends = concat
- [ [ initFileDepWriter logger root tmpfs dflags makefile_output
- | Just makefile_output <- [depMakefile dflags]
+ [ [ initFileDepWriter logger root tmpfs tmpdir suffixes makefile_output
+ | Just makefile_output <- [initDepOutput (depMakefile dflags)]
]
- , [ initJsonDepWriter logger tmpfs dflags json_output
- | Just json_output <- [depJson dflags]
+ , [ initJsonDepWriter logger tmpfs tmpdir json_output
+ | Just json_output <- [initDepOutput (depJson dflags)]
]
]
@@ -158,24 +160,14 @@ doMkDependModuleGraph dflags module_graph = do
liftIO $ debugTraceMsg logger 2 (text "Module dependencies" $$ ppr sorted)
liftIO $ do
-
- -- Setup the writers
- writers <- sequenceA backends
- sinks <- traverse dw_beginWriter writers
-
- -- Do the actual work
- do
+ withWriters backends $ \ depSink -> do
+ -- Do the actual work
-- Process them one by one, dumping results and complaining about cycles
- mapM_ (processDeps hsc_env (UniqSet.mkUniqSet excl_mods) sinks) sorted
+ mapM_ (processDeps hsc_env (UniqSet.mkUniqSet excl_mods) depSink) sorted
-- If -ddump-mod-cycles, show cycles in the module graph
liftIO $ dumpModCycles logger module_graph
- -- Tidy up
- do
- traverse_ dw_endWriter writers
-
-
-- Unconditional exiting is a bad idea. If an error occurs we'll get an
--exception; if that is not caught it's fine, but at least we have a
--chance to find out exactly what went wrong. Uncomment the following
@@ -216,15 +208,118 @@ data Dep
{ dep_path :: OsPath
}
+-- | Consumer of the dependency information generated from the 'ModuleGraph'.
+--
+-- Use with 'withWriter'/'withWriters' to initialise the consumers of the dependency information
+-- generation.
data DependencyWriter = DependencyWriter
- { dw_beginWriter :: IO DepSink
+ { dw_sink :: DepSink
+ -- ^ Sink for dependency information
, dw_endWriter :: IO ()
+ -- ^ We finished consuming the dependency information, perform final
+ -- tidy up operations. This may be a no-op, but could also
+ -- copy temporary files, close open handlers, etc...
+ --
+ -- If 'dw_endWriter' was called, calling 'dw_onError' is unnecessary.
+ , dw_onError :: IO ()
+ -- ^ Something crashed! Clean up any resources opened by this 'DependencyWriter'.
}
-data DepSink = DepSink
+-- | Initialise multiple backends and combine them into one output function.
+--
+-- Combines the 'DepSink' of each 'DependencyWriter' into one single consumer.
+withWriters :: [IO DependencyWriter] -> (DepSink -> IO a) -> IO a
+withWriters [] k = k noopSink
+withWriters (dw : dws) k =
+ withWriter
+ dw
+ $ \s -> withWriters dws (\s' -> k (s `mappendSink` s'))
+
+-- | Initialise a single 'DependencyWriter', making sure any allocated resource
+-- get's tidied up again.
+--
+-- Accepts 'IO' 'DependencyWriter' since the initialisation may perform setup operations,
+-- such as opening file handles, or intermediate data types.
+withWriter :: IO DependencyWriter -> (DepSink -> IO r) -> IO r
+withWriter dwIO k =
+ bracketOnError dwIO dw_onError $ \ dw -> do
+ r <- k (dw_sink dw)
+ -- Clean up open resources
+ dw_endWriter dw
+ pure r
+
+-- | Process the dependency information for one node in the 'ModuleGraph'.
+newtype DepSink = DepSink
{ ds_writeDependency :: DepNode -> [Dep] -> IO ()
}
+noopSink :: DepSink
+noopSink = DepSink $ \ _ _ -> pure ()
+
+mappendSink :: DepSink -> DepSink -> DepSink
+mappendSink (DepSink s1) (DepSink s2) = DepSink (\ node deps -> s1 node deps >> s2 node deps)
+
+-- | Where should the dependency output end up?
+data DepOutput
+ = DepStreamHandle Handle
+ -- | The dependency information should be written to this 'Handle'.
+ | DepFileOutput FilePath
+ -- | The dependency information should be written to this 'FilePath'.
+
+-- | A 'DepStream' is an abstraction over how to output single elements
+-- of the dependency generation, e.g., a json object or one makefile rule.
+data DepStream = DepStream
+ { depStream_write :: String -> IO ()
+ , depStream_close :: IO ()
+ , depStream_onError :: IO ()
+ }
+
+initDepOutput :: MkDependOutput -> Maybe DepOutput
+initDepOutput = \ case
+ MkDepend_None -> Nothing
+ MkDepend_Default fp -> Just $ DepFileOutput fp
+ MkDepend_Explicit fp -> Just $ DepFileOutput fp
+ MkDepend_StdOut -> Just $ DepStreamHandle stdout
+
+initMakefileDepStream :: Logger -> TmpFs -> TempDir -> DepOutput -> IO DepStream
+initMakefileDepStream _ _ _ (DepStreamHandle h) =
+ pure $ depStreamHandle h
+initMakefileDepStream logger tmpfs tmpdir (DepFileOutput fp) = do
+ files <- beginMkDependHS logger tmpfs tmpdir fp
+ pure $
+ DepStream
+ { depStream_write = hPutStrLn (mkd_tmp_hdl files)
+ , depStream_onError = do
+ hClose $ mkd_tmp_hdl files
+ case mkd_make_hdl files of
+ Nothing -> return ()
+ Just hdl -> hClose hdl
+ , depStream_close = endMkDependHS logger files
+ }
+
+initJsonDepStream :: Logger -> TmpFs -> TempDir -> DepOutput -> IO DepStream
+initJsonDepStream _ _ _ (DepStreamHandle h) =
+ pure $ depStreamHandle h
+initJsonDepStream logger tmpfs tmpdir (DepFileOutput fp) = do
+ files <- initJsonDepFiles logger tmpfs tmpdir fp
+ pure $
+ DepStream
+ { depStream_write = hPutStrLn (json_tmp_hdl files)
+ , depStream_onError = hClose (json_tmp_hdl files)
+ , depStream_close = endJsonDepFiles logger files
+ }
+
+depStreamHandle :: Handle -> DepStream
+depStreamHandle h =
+ DepStream
+ { depStream_write =
+ \output -> do
+ hPutStrLn h output
+ hFlush h -- We flush to ensure the output is streamed per line.
+ , depStream_close = pure ()
+ , depStream_onError = pure ()
+ }
+
-----------------------------------------------------------------
--
-- processDeps
@@ -233,7 +328,7 @@ data DepSink = DepSink
processDeps :: HscEnv
-> UniqSet ModuleName -- ^ Excludes
- -> [DepSink]
+ -> DepSink
-> SCC ModuleGraphNode
-> IO ()
-- Write suitable dependencies to handle
@@ -267,7 +362,7 @@ processDeps _ _ _ (AcyclicSCC (ModuleNode _ (ModuleNodeFixed {})))
-- No dependencies needed for fixed modules (already compiled)
= return ()
-processDeps hsc_env0 excl_mods sinks (AcyclicSCC (ModuleNode _ (ModuleNodeCompile node))) = do
+processDeps hsc_env0 excl_mods sink (AcyclicSCC (ModuleNode _ (ModuleNodeCompile node))) = do
pp <- preprocessor
let
dep_node = mkDepNode pp
@@ -279,7 +374,7 @@ processDeps hsc_env0 excl_mods sinks (AcyclicSCC (ModuleNode _ (ModuleNodeCompil
if null missing_dep_errs
then do
- traverse_ (\ sink -> ds_writeDependency sink dep_node deps) sinks
+ ds_writeDependency sink dep_node deps
else do
let sec = initSourceErrorContext (hsc_dflags local_hsc_env)
throwErrors sec (mkMessages (listToBag missing_dep_errs))
@@ -380,17 +475,16 @@ find_preprocessor d = do
--
-----------------------------------------------------------------
-initFileDepWriter :: Logger -> OsPath -> TmpFs -> DynFlags -> FilePath -> IO DependencyWriter
-initFileDepWriter logger root tmpfs dflags makefile = do
- files <- beginMkDependHS logger tmpfs dflags makefile
+initFileDepWriter :: Logger -> OsPath -> TmpFs -> TempDir -> [OsPath] -> DepOutput -> IO DependencyWriter
+initFileDepWriter logger root tmpfs tmpdir suffixes output = do
+ stream <- initMakefileDepStream logger tmpfs tmpdir output
pure DependencyWriter
- { dw_beginWriter = do
- pure $ DepSink $ \ node deps -> do
- writeDependencies root (mkd_tmp_hdl files) suffixes node deps
- , dw_endWriter = endMkDependHS logger files
+ { dw_sink =
+ DepSink $ \ node deps -> do
+ traverse_ (depStream_write stream) (dependencyRules root suffixes node deps)
+ , dw_endWriter = depStream_close stream
+ , dw_onError = depStream_onError stream
}
- where
- suffixes = map unsafeEncodeUtf (depSuffixes dflags)
data MkDepFiles
= MkDep { mkd_make_file :: FilePath, -- Name of the makefile
@@ -398,11 +492,11 @@ data MkDepFiles
mkd_tmp_file :: FilePath, -- Name of the temporary file
mkd_tmp_hdl :: Handle } -- Handle of the open temporary file
-beginMkDependHS :: Logger -> TmpFs -> DynFlags -> FilePath -> IO MkDepFiles
-beginMkDependHS logger tmpfs dflags makefile = do
+beginMkDependHS :: Logger -> TmpFs -> TempDir -> FilePath -> IO MkDepFiles
+beginMkDependHS logger tmpfs tmpdir makefile = do
-- open a new temp file in which to stuff the dependency info
-- as we go along.
- tmp_file <- newTempName logger tmpfs (tmpDir dflags) TFL_CurrentModule "dep"
+ tmp_file <- newTempName logger tmpfs tmpdir TFL_CurrentModule "dep"
tmp_hdl <- openFile tmp_file WriteMode
-- open the makefile
@@ -443,16 +537,15 @@ beginMkDependHS logger tmpfs dflags makefile = do
return (MkDep { mkd_make_file = makefile, mkd_make_hdl = mb_make_hdl,
mkd_tmp_file = tmp_file, mkd_tmp_hdl = tmp_hdl})
-writeDependencies ::
+dependencyRules ::
OsPath ->
- Handle ->
[OsString] ->
-- ^ Suffixes
DepNode ->
[Dep] ->
- IO ()
-writeDependencies root hdl suffixes node deps =
- traverse_ write tasks
+ [String]
+dependencyRules root suffixes node deps =
+ map rule tasks
where
tasks = source_dep : boot_dep ++ concatMap import_dep deps
@@ -479,7 +572,7 @@ writeDependencies root hdl suffixes node deps =
DepCpp {dep_path} -> [(obj_files, dep_path)]
- write (from, to) = writeDependency root hdl from to
+ rule (from, to) = dependencyRule root from to
obj_files = suffixed dn_obj
@@ -488,18 +581,18 @@ writeDependencies root hdl suffixes node deps =
DepNode {dn_src, dn_obj, dn_hi, dn_mod} = node
-----------------------------
-writeDependency :: OsPath -> Handle -> [OsPath] -> OsPath -> IO ()
+dependencyRule :: OsPath -> [OsPath] -> OsPath -> String
-- (writeDependency r h [t1,t2] dep) writes to handle h the dependency
-- t1 t2 : dep
-writeDependency root hdl targets dep
- = do let -- We need to avoid making deps on
- -- c:/foo/...
- -- on Windows as make gets confused by the :
- -- Making relative deps avoids some instances of this.
- dep' = OsPath.makeRelative root dep
- forOutput = escapeSpaces . reslash Forwards . unsafeDecodeUtf . OsPath.normalise
- output = unwords (map forOutput targets) ++ " : " ++ forOutput dep'
- hPutStrLn hdl output
+dependencyRule root targets dep
+ = let -- We need to avoid making deps on
+ -- c:/foo/...
+ -- on Windows as make gets confused by the :
+ -- Making relative deps avoids some instances of this.
+ dep' = OsPath.makeRelative root dep
+ forOutput = escapeSpaces . reslash Forwards . unsafeDecodeUtf . OsPath.normalise
+ in
+ unwords (map forOutput targets) ++ " : " ++ forOutput dep'
-----------------------------
insertSuffixes
@@ -554,16 +647,27 @@ endMkDependHS logger
--
-----------------------------------------------------------------
-initJsonDepWriter :: Logger -> TmpFs -> DynFlags -> FilePath -> IO DependencyWriter
-initJsonDepWriter logger tmpfs dflags output = do
- json_var <- mkJsonOutput logger tmpfs dflags output initDepJson
- pure DependencyWriter
- { dw_beginWriter =
- pure $ DepSink $ \ node deps ->
- writeHomeUnitDeps json_var node deps
- , dw_endWriter = do
- writeJsonOutput logger json_var
- }
+initJsonDepWriter :: Logger -> TmpFs -> TempDir -> DepOutput -> IO DependencyWriter
+initJsonDepWriter logger tmpfs tmpdir output = do
+ stream <- initJsonDepStream logger tmpfs tmpdir output
+ json_var <- mkJsonOutput stream
+ pure
+ DependencyWriter
+ { dw_sink =
+ DepSink $ \node deps -> do
+ extUnits <- readJson json_var
+ let
+ (extUnitsDeps, payload) = homeUnitDeps node deps
+ newExtUnits = Set.difference extUnitsDeps (externalDeps extUnits)
+ -- Write new external unit deps before the module that uses them
+ for_ newExtUnits $ \extUnit -> do
+ depStream_write stream (renderJsonl extUnit)
+ depStream_write stream (renderJsonl payload)
+ -- Cache external deps we already reported in the past
+ updateJson json_var $ cacheExternalDepsJson newExtUnits
+ , dw_endWriter = depStream_close stream
+ , dw_onError = depStream_onError stream
+ }
--------------------------------------------------------------------------------
-- Output interface for json dumps
@@ -572,65 +676,64 @@ initJsonDepWriter logger tmpfs dflags output = do
-- The flag @-dep-json@ add an additional output target for dependency
-- diagnostics.
--
--- Contains temporary file locations to stream output to.
-data JsonOutput =
- JsonOutput {
- -- | This ref is updated in @processDeps@ incrementally, using a
- -- flag-specific type.
- json_ref :: IORef DepJson,
-
- -- | The output file path specified as argument to the flag.
- json_path :: FilePath,
- -- | Name of the temporary file
- json_tmp_file :: FilePath,
- -- | Handle of the open temporary file
- json_tmp_hdl :: Handle
+data JsonOutput
+ = JsonOutput
+ { json_ref :: IORef DepJson
+ -- ^ This ref is updated in @processDeps@ incrementally, using a
+ -- flag-specific type.
+ , json_dep_stream :: DepStream
}
--- | Set up json generation for `ghc -M`.
---
--- Creates a temporary file that we write the dependency information to.
--- The temporary file is written to the final output file path in 'writeJsonOutput'.
-mkJsonOutput ::
- Logger ->
- TmpFs ->
- DynFlags ->
- FilePath ->
- IO (IORef DepJson) ->
- IO JsonOutput
-mkJsonOutput logger tmpfs dflags json_path mk_ref = do
- json_ref <- mk_ref
- -- open a new temp file in which to stuff the dependency info
+data JsonDepFiles = JsonDepFiles
+ { json_path :: FilePath
+ -- ^ The output file path specified as argument to the flag.
+ , json_tmp_file :: FilePath
+ -- ^ Name of the temporary file
+ , json_tmp_hdl :: Handle
+ -- ^ Handle of the open temporary file
+ }
+
+initJsonDepFiles :: Logger -> TmpFs -> TempDir -> FilePath -> IO JsonDepFiles
+initJsonDepFiles logger tmpfs tmpdir path = do
+ -- open a new temp file in which to stuff the dependency info into
-- as we go along.
- json_tmp_file <- newTempName logger tmpfs (tmpDir dflags) TFL_CurrentModule "dep"
+ json_tmp_file <- newTempName logger tmpfs tmpdir TFL_CurrentModule "dep-json"
json_tmp_hdl <- openFile json_tmp_file WriteMode
-
- pure JsonOutput {json_ref, json_path, json_tmp_file, json_tmp_hdl}
-
-updateJson :: JsonOutput -> (DepJson -> DepJson) -> IO ()
-updateJson JsonOutput {json_ref} f = modifyIORef' json_ref f
-
-readJson :: JsonOutput -> IO DepJson
-readJson JsonOutput {json_ref} = readIORef json_ref
+ pure $ JsonDepFiles
+ { json_path = path
+ , json_tmp_file = json_tmp_file
+ , json_tmp_hdl = json_tmp_hdl
+ }
-- | Finalise the json generation by copying the temporary file to the final destination.
-- Avoids partial writes in the case of an error.
-writeJsonOutput ::
- Logger ->
- JsonOutput ->
- IO ()
-writeJsonOutput logger JsonOutput {json_path, json_tmp_file, json_tmp_hdl} = do
+endJsonDepFiles :: Logger -> JsonDepFiles -> IO ()
+endJsonDepFiles logger JsonDepFiles {json_path, json_tmp_file, json_tmp_hdl} = do
hClose json_tmp_hdl
-- Copy the new jsonl in place
showPass logger "Installing new json output"
SysTools.copyFile json_tmp_file json_path
+-- | Set up json generation for `ghc -M`.
+mkJsonOutput ::
+ DepStream ->
+ IO JsonOutput
+mkJsonOutput dep_stream = do
+ json_ref <- newIORef (DepJson Set.empty)
+ pure JsonOutput {json_ref, json_dep_stream = dep_stream }
+
+updateJson :: JsonOutput -> (DepJson -> DepJson) -> IO ()
+updateJson JsonOutput {json_ref} f = modifyIORef' json_ref f
+
+readJson :: JsonOutput -> IO DepJson
+readJson JsonOutput {json_ref} = readIORef json_ref
+
--------------------------------------------------------------------------------
-- Output helpers
-writeJsonl :: ToJson a => JsonOutput -> a -> IO ()
-writeJsonl JsonOutput {json_tmp_hdl} output = do
- hPutStrLn json_tmp_hdl (showSDocUnsafe $ renderJSON $ json output)
+renderJsonl :: ToJson a => a -> String
+renderJsonl output = do
+ showSDocUnsafe $ renderJSON $ json output
--------------------------------------------------------------------------------
-- Payload for -dep-json
@@ -788,9 +891,6 @@ instance ToJson ExtUnitDep where
where
showPackageId (DPackageId (PackageId pid)) = unpackFS pid
-initDepJson :: IO (IORef DepJson)
-initDepJson = newIORef $ DepJson Set.empty
-
cacheExternalDepsJson :: Set.Set ExtUnitDep -> DepJson -> DepJson
cacheExternalDepsJson extUnits (DepJson e0) =
DepJson
@@ -798,19 +898,10 @@ cacheExternalDepsJson extUnits (DepJson e0) =
Set.union e0 extUnits
}
-writeHomeUnitDeps :: JsonOutput -> DepNode -> [Dep] -> IO ()
-writeHomeUnitDeps deps_json DepNode {..} deps = do
- extUnits <- readJson deps_json
- let newExtUnits = Set.difference extUnitsDeps (externalDeps extUnits)
- -- Write new external unit deps before the module that uses them
- for_ newExtUnits $ \ extUnit -> do
- writeJsonl deps_json extUnit
- writeJsonl deps_json payload
- -- Cache external deps we already reported in the past
- updateJson deps_json $ cacheExternalDepsJson newExtUnits
+homeUnitDeps :: Foldable t => DepNode -> t Dep -> (Set.Set ExtUnitDep, HomeUnitDep)
+homeUnitDeps DepNode {..} deps =
+ foldl' go (Set.empty, initial_node_data) deps
where
- (extUnitsDeps, payload) = foldl' go (Set.empty, initial_node_data) deps
-
initial_node_data =
HomeUnitDep
{ unitId = dn_unitId
=====================================
compiler/GHC/Driver/Session.hs
=====================================
@@ -790,16 +790,44 @@ addOptCmmP f = alterToolSettings $ \s -> s
}
setDepMakefile :: FilePath -> DynFlags -> DynFlags
-setDepMakefile f d = d { depMakefile = Just f }
+setDepMakefile f d = d { depMakefile = MkDepend_Explicit f
+ -- depJson has no default value, we add this for symmetry with `setDepJson`
+ -- and if anything changes in the future, then the code is already here :)
+ , depJson = unsetMkDependOutputIfDefault (depJson d)
+ }
+
+setDepMakefileStdout :: DynFlags -> DynFlags
+setDepMakefileStdout d = d { depMakefile = MkDepend_StdOut
+ -- depJson has no default value, we add this for symmetry with `setDepJson`
+ -- and if anything changes in the future, then the code is already here :)
+ , depJson = unsetMkDependOutputIfDefault (depJson d)
+ }
unsetDepMakefile :: DynFlags -> DynFlags
-unsetDepMakefile d = d { depMakefile = Nothing }
+unsetDepMakefile d = d { depMakefile = MkDepend_None }
setDepJson :: FilePath -> DynFlags -> DynFlags
-setDepJson f d = d { depJson = Just f }
+setDepJson f d = d { depJson = MkDepend_Explicit f
+ -- We generate a Makefile by default, but if a user requests json
+ -- output, then they most likely don't need a Makefile.
+ -- Thus, we only generate it if the user requests it.
+ , depMakefile = unsetMkDependOutputIfDefault (depMakefile d)
+ }
+
+setDepJsonStdout :: DynFlags -> DynFlags
+setDepJsonStdout d = d { depJson = MkDepend_StdOut
+ -- We generate a Makefile by default, but if a user requests json
+ -- output, then they most likely don't need a Makefile.
+ -- Thus, we only generate it if the user requests it.
+ , depMakefile = unsetMkDependOutputIfDefault (depMakefile d)
+ }
unsetDepJson :: DynFlags -> DynFlags
-unsetDepJson d = d { depJson = Nothing }
+unsetDepJson d = d { depJson = MkDepend_None }
+
+unsetMkDependOutputIfDefault :: MkDependOutput -> MkDependOutput
+unsetMkDependOutputIfDefault (MkDepend_Default _) = MkDepend_None
+unsetMkDependOutputIfDefault mkDepend_output = mkDepend_output
setDepIncludeCppDeps :: Bool -> DynFlags -> DynFlags
setDepIncludeCppDeps b d = d { depIncludeCppDeps = b }
@@ -1272,8 +1300,10 @@ dynamic_flags_deps = [
, make_ord_flag defGhcFlag "dep-suffix" (hasArg addDepSuffix)
, make_ord_flag defGhcFlag "dep-makefile" (hasArg setDepMakefile)
, make_ord_flag defGhcFlag "no-dep-makefile" (noArg unsetDepMakefile)
+ , make_ord_flag defGhcFlag "dep-makefile-stdout" (noArg setDepMakefileStdout)
, make_ord_flag defGhcFlag "dep-json" (hasArg setDepJson)
, make_ord_flag defGhcFlag "no-dep-json" (noArg unsetDepJson)
+ , make_ord_flag defGhcFlag "dep-json-stdout" (noArg setDepJsonStdout)
, make_ord_flag defGhcFlag "include-cpp-deps"
(noArg (setDepIncludeCppDeps True))
, make_ord_flag defGhcFlag "include-pkg-deps"
=====================================
docs/users_guide/separate_compilation.rst
=====================================
@@ -1511,6 +1511,16 @@ generation are:
Introduced in GHC 10.1, ``-no-dep-makefile`` disables the generation of a Makefile altogether.
+.. ghc-flag:: -dep-makefile-stdout
+ :shortdesc: Write dependency generation to stdout using makefile format
+ :type: dynamic
+ :reverse: -no-dep-makefile
+ :category: redirect-output
+
+ :since: 10.1
+
+ Stream the dependency generation of :ghc-flag:`-dep-makefile ⟨file⟩` to stdout instead of ⟨file⟩.
+
.. ghc-flag:: -dep-json ⟨file⟩
:shortdesc: Write dependencies to ⟨file⟩ as a JSON Lines format
:type: dynamic
@@ -1540,8 +1550,19 @@ generation are:
``-no-dep-json`` disables the generation of the JSON file.
- By default, :ghc-flag:`-dep-makefile ⟨file⟩` is enabled even if :ghc-flag:`-dep-json ⟨file⟩` is given.
- Disable the generation of any Makefile via ``-no-dep-makefile``.
+ :ghc-flag:`-dep-json ⟨file⟩` and :ghc-flag:`-dep-json-stdout` disable the default generation of a Makefile.
+ To generate a Makefile for the dependency information, explicitly use :ghc-flag:`-dep-makefile ⟨file⟩` or
+ :ghc-flag:`-dep-makefile-stdout`.
+
+.. ghc-flag:: -dep-json-stdout
+ :shortdesc: Write dependency generation to stdout using JSON Lines format
+ :type: dynamic
+ :reverse: -no-dep-json
+ :category: redirect-output
+
+ :since: 10.1
+
+ Stream the dependency generation of :ghc-flag:`-dep-json ⟨file⟩` to stdout instead of ⟨file⟩.
.. ghc-flag:: -dep-suffix ⟨suffix⟩
:shortdesc: Make dependencies that declare that files with suffix
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/252c5b3efaeb309dd32d238fa50bd80…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/252c5b3efaeb309dd32d238fa50bd80…
You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
1
0
[Git][ghc/ghc][wip/andrea/async-rpc] 15 commits: Asynchronous RPC with external interpreter
by Andrea Vezzosi (@trac-Saizan) 20 Oct '26
by Andrea Vezzosi (@trac-Saizan) 20 Oct '26
20 Oct '26
Andrea Vezzosi pushed to branch wip/andrea/async-rpc at Glasgow Haskell Compiler / GHC
Commits:
b5227250 by Rodrigo Mesquita at 2026-10-15T16:38:09+01:00
Asynchronous RPC with external interpreter
There's a single pipe to connect the host compiler to the external
interpreter. On this pipe, we have historically done synchronous
request/reply communication to invoke methods on the external
interpreter.
However, with the advent of multi-threaded debugging, it has become
necessary to do asynchronous calls on the external interpreter, where we
may block on the host waiting for a reply, but the external interpreter
should handle the request asynchronously and reply when ready. For
instance, we want to start the evaluation of the debuggee but not block
the interpreter waiting for it to finish or hit a breakpoint. Or e.g. we
want to resume two threads of the debuggee simulatenously instead of
blocking waiting for the resume result of each one sequentially.
And it turns out, we were already doing some ad-hoc asynchronous
communication to evaluate Template Haskell on the external interpreter.
It used to go as an ad-hoc "send request without expecting reply",
followed by handling on the host a set of 'THMessage's sent by the
interpreter, followed by "expect a response to arrive now". It worked
because there was still a fixed order of messages, but it fits an async
model in a non-ad-hoc way.
Asynchronous communication that unblocks the external interpreter main
thread will also make it possible to resolve issues such as #18852
(exceptions leaving the external interpreter in an unrecoverrable state)
The new design
--------------
The new invariant: every single request should receive a matching reply.
The pipe is bidirectional (the ext. interpreter can receive requests,
but it can also send requests for TH evaluation; the host can send
requests, but it can also receive TH requests from the interpreter).
When a request is sent in whichever direction, it always contains a
correlation-id header. The Sender places an empty MVar on a
pending-reply map keyed by id and waits on it for a response.
See 'remoteCall' and 'remoteTHCall'.
The pipe is associated to a thread which drains the read end. Because
it's bidirectional, two things may be read off the pipe:
- A Reply, with a correlation-id header, which we match against the
pending requests map to unblock the corresponding pending-reply MVar
- A Request, which is queued to the pending-request queue.
To handle a message, we take a Request from the pending-request queue
and run a handler that produces a Reply. Currently, the handler is run
synchronously in the thread, but it is trivial to make the handler run
in a forked thread for certain ("interruptible") messages in an upcoming
patch (when it is necessary for the multi-threaded debugger).
See 'handleRemoteCall' and 'handleRemoteTHCall'.
The old interp lock now just protect the pipe writing (reads don't lock
bc they are done exclusively by drainPipe), it doesn't need nor should
lock the full remote procedure call.
Fixes #27960
- - - - -
cc116c23 by Rodrigo Mesquita at 2026-10-15T16:38:09+01:00
interp: Add separate mailboxes for TH async RPC
When the host sends a `RunTH` command to the interpreter, it expects a
few "reverse requests" from the interpreter (e.g. `NewName`) which must
be run in the same context that initiated the `RunTH`.
When the host is evaluating many splices at once, it will send many
`RunTH` commands to the interpreter and start listening for reverse
requests in the meantime. However, a received request previously had no
way to be associated to the scope of a particular `RunTH` invocation, so
the reverse commands could get replied to from incorrect contexts, or
e.g. a `RunTHDone` from the interp. could terminate early the wrong
`RunTH` computation.
In this commit we add independent mailboxes to the interpreter
asynchronous RPC infrastructure, allowing a RunTH to announce a
particular `InboxId` that all reverse requests for that RunTH should
use. On the host, we create that mailbox id and have
`handleRemoteTHCall` listen on that specific mailbox rather than for
requests without a specific mailbox address.
- - - - -
58a378d9 by Rodrigo Mesquita at 2026-10-15T16:38:10+01:00
refactor: Move Async RPC abstraction into GHCi.Message.Async
Carves out the Async RPC over the Pipe abstraction to a new module,
making the GHCi.Message more about the specific interpreter messages
rather than about the IPC protocol.
- - - - -
014202d0 by Rodrigo Mesquita at 2026-10-15T16:38:10+01:00
interp: If we have pending reads in the queue we can deliver them
We may still be able to reply even if the read end was closed.
As long as we have pending messages we should try to deliver them.
- - - - -
d707be17 by Andrea Vezzosi at 2026-10-15T16:38:10+01:00
interp: close Handles when done with Pipe
Ensures we close the pipe handles (if created using 'mkPipeFromHandles')
on `closePipe`, and do `closePipe` on `Shutdown`.
The thread draining the read end always `'finally'` closes the read end.
And `closePipe` kills the draining thread and closes the write end.
When `remoteAsyncReq`, we throw PipeReadClosedException if the pipe read is
closed, since we wouldn't be able to receive the reply.
It's fine for the drain thread not to close the write end, even if it
dies without `closePipe` (which does close the write end), because:
- requests pending a reply will get PipeClosedException (we'll not be
able to read any further "real" reply)
- new calls to `remoteAsyncReq` will throw PipeReadClosedException
- pending pipe writes, in response to an already read request, might still succeed
And the clean up code should call close pipe to ensure the write end is
closed as well.
So, if the drain thread dies naturally and the read end is closed, may
still be attempted to be used, but it will throw accordingly. The user
likely wants to catch this to close the write end as well.
- - - - -
66d87bca by Zubin Duggal at 2026-10-16T15:18:00+05:30
interp: fix external interpreter shutdown deadlock on Windows
On shutdown both GHC and iserv call `closePipe`, which stopped the drain
thread before closing the write end. On Windows the drain thread reads
with a safe foreign call to _read, which `throwTo' can't interrupt, so
the two sides were stuck in the deadlock deadlock.
Closing the write end first is not enough on its own. On Windows a read
on a pipe only unblocks once all write handles to it are closed [1].
However, all all four pipe ends were inheritable and we didn't close the
child's ends in the parent. This means a close on any one side wouldn't
unblock any reads, becuase the other side had another copy open.
* runWithPipes now uses System.Process.CommunicationHandle [2], which is
built for passing pipes to a child process: only the child's ends are
inheritable, and it simplifies our mess of CPP. Additionally, it is
important to close our copy of the endpoints passed to the child so
each side only keeps open copies it needs to allow a close to unblock
reads.
* readGhcHandle makes the handle non-inheritable so we don't have
additional references floating around that stop reads from unblocking
on close.
* In closePipe the ordering is subtle and important. We first fail any
requests still waiting for a reply, then close the write end so the
other side sees EOF. We take the write lock to close it, so we never
close under a concurrent write [3]. Only then do we stop the drain
thread, which closes the read end itself once its read has finished.
Bump bound to process >= 1.6.20 as this is the version with
System.Process.CommunicationHandle
[1] https://learn.microsoft.com/en-us/windows/win32/ipc/anonymous-pipe-operatio…
[2] https://github.com/haskell/process/pull/308
[3] https://gitlab.haskell.org/ghc/ghc/-/work_items/27801
- - - - -
753abb81 by Andrea Vezzosi at 2026-10-16T16:04:25+02:00
generalized handleRemoteCall to allow forking.
- - - - -
ed3ec8fc by Andrea Vezzosi at 2026-10-16T16:16:56+02:00
GHCi.Server: handle RunTH and RunModFinalizers in forked thread
- - - - -
ee5d2db0 by Andrea Vezzosi at 2026-10-16T16:21:54+02:00
wip: GHCi.Message.Async: pipeCloseWrite if pipeWrite encounters IOError.
- - - - -
de57cda3 by Rodrigo Mesquita at 2026-10-16T16:07:19+01:00
Revert "generalized handleRemoteCall to allow forking."
This reverts commit 753abb8145b3591596e35f1e83307d1dcfae81e0.
- - - - -
05b34675 by Rodrigo Mesquita at 2026-10-16T17:21:46+01:00
better forkIO linear api and direct use in loop
- - - - -
67555abb by Andrea Vezzosi at 2026-10-19T11:17:53+02:00
Revert "wip: GHCi.Message.Async: pipeCloseWrite if pipeWrite encounters IOError."
This reverts commit ee5d2db04cf26509ae9bf565c73213d7d38376d5.
- - - - -
2b13e177 by Andrea Vezzosi at 2026-10-19T14:56:07+02:00
use fillPipe thread, writePipe now safely interruptible
- - - - -
2c718d86 by Andrea Vezzosi at 2026-10-19T14:59:21+02:00
fixup! use fillPipe thread, writePipe now safely interruptible
- - - - -
5a897150 by Andrea Vezzosi at 2026-10-20T09:53:52+02:00
ignore PipeReadClosedException on Shutdown.
- - - - -
17 changed files:
- + changelog.d/T27960
- compiler/GHC/Runtime/Interpreter.hs
- compiler/GHC/Runtime/Interpreter/JS.hs
- compiler/GHC/Runtime/Interpreter/Process.hs
- compiler/GHC/Runtime/Interpreter/Types.hs
- compiler/GHC/Runtime/Interpreter/Wasm.hs
- compiler/GHC/Runtime/Utils.hs
- compiler/GHC/Tc/Gen/Splice.hs
- compiler/ghc.cabal.in
- libraries/ghci/GHCi/Message.hs
- + libraries/ghci/GHCi/Message/Async.hs
- libraries/ghci/GHCi/Server.hs
- + libraries/ghci/GHCi/Server/Threads.hs
- libraries/ghci/GHCi/TH.hs
- libraries/ghci/GHCi/Utils.hsc
- libraries/ghci/ghci.cabal.in
- testsuite/tests/ghci/custom-external-interpreter-commands/Main.hs
Changes:
=====================================
changelog.d/T27960
=====================================
@@ -0,0 +1,17 @@
+section: ghci
+synopsis: Make external interpreter communication use an explicit Async RPC
+issues: #27960
+mrs: !16802
+
+description: {
+ iserv already implements RPC today, although in a fairly ad-hoc and
+ convoluted manner. The template haskell consumer already requires
+ bidirectional communication and async requests, and got implemented in a
+ way that precludes other consumers with async needs.
+ This change streamlines all this by using an explicit Async RPC protocol.
+
+ It additionally clears the path to fix #18852 since the main thread is no
+ longer blocked per request, enables evaluating splices concurrently in the
+ external interpreter, and unblocks multi-threaded interactive debugging.
+}
+
=====================================
compiler/GHC/Runtime/Interpreter.hs
=====================================
@@ -626,11 +626,9 @@ spawnIServ conf = do
[]
(iservConfOpts conf)
interpPipe <- mkPipeFromHandles rh wh
- lock <- newMVar ()
let process = InterpProcess
{ interpHandle = ph
, interpPipe
- , interpLock = lock
}
pending_frees <- newMVar []
@@ -655,7 +653,9 @@ stopInterp interp = case interpInstance interp of
ex <- getProcessExitCode (interpHandle (instProcess i))
if isJust ex
then pure ()
- else sendMessage i Shutdown
+ else sendMessage i Shutdown `catch` \ PipeReadClosedException -> pure ()
+ -- We asked the server to shutdown, so we will also shutdown any communication.
+ closePipe (interpPipe (instProcess i))
pure InterpPending
-- -----------------------------------------------------------------------------
=====================================
compiler/GHC/Runtime/Interpreter/JS.hs
=====================================
@@ -127,11 +127,9 @@ startTHRunnerProcess interp_js settings = do
std_in <- readIORef interp_in
interpPipe <- mkPipeFromHandles rh wh
- lock <- newMVar ()
let proc = InterpProcess
{ interpHandle = hdl
, interpPipe
- , interpLock = lock
}
pure (std_in, proc)
@@ -382,7 +380,7 @@ jsLinkPlan logger tmpfs tmp_dir ar_cache link_cfg cfg inst link_plan = do
-- Haskell server.
server_started <- jsServerStarted <$> readMVar (instJSState (instExtra inst))
if server_started
- then sendMessageNoResponse inst $ LoadObj all_js
+ then sendMessage inst $ LoadObj all_js
else jsLoadFile inst all_js
----------------------------------------------------------------
=====================================
compiler/GHC/Runtime/Interpreter/Process.hs
=====================================
@@ -2,16 +2,8 @@ module GHC.Runtime.Interpreter.Process
(
-- * Message API
Message(..)
- , DelayedResponse (..)
- -- * Top-level message API (these acquire/release a lock)
, sendMessage
- , sendMessageNoResponse
- , sendMessageDelayedResponse
- , receiveDelayedResponse
- -- * Nested message API (these require the interpreter to already be locked)
- , sendAnyValue
- , receiveAnyValue
- , receiveTHMessage
+ , sendTHComputation
)
where
@@ -27,97 +19,63 @@ import GHC.Utils.Exception as Ex
import Data.Binary
import System.Exit
import System.Process
-import Control.Concurrent.MVar (MVar, withMVar, takeMVar, putMVar, isEmptyMVar)
-
-data DelayedResponse a = DelayedResponse
+import Control.Concurrent
+import Data.IORef
+import Control.Concurrent.STM
-- -----------------------------------------------------------------------------
-- Top-level Message API
--- | Send a message to the interpreter process that doesn't expect a response
--- (locks the interpreter while sending)
-sendMessageNoResponse :: ExtInterpInstance d -> Message () -> IO ()
-sendMessageNoResponse i m =
- withLock i $ writeInterpProcess (instProcess i) (putMessage m)
-
--- | Send a message to the interpreter that expects a response
--- (locks the interpreter while until the response is received)
+-- | Send a message to the interpreter and expect a response, blocking until it arrives.
+--
+-- This issues an asynchronous RPC on the external interpreter which does not
+-- block the external interpreter thread. We block here on the host because we
+-- wait for the asynchronous response to arrive.
sendMessage :: Binary a => ExtInterpInstance d -> Message a -> IO a
-sendMessage i m = withLock i $ callInterpProcess (instProcess i) m
-
--- | Send a message to the interpreter process whose response is expected later
+sendMessage i msg =
+ remoteCall (interpPipe proc) msg
+ `catchException` \(e :: SomeException) -> handleInterpProcessFailure proc e
+ where
+ proc = instProcess i
+
+-- | Send a message with a TH computation to the ext. interpreter (like
+-- 'RunTH', or 'RunModFinalizers') and handle 'THMessage' requests from the
+-- ext. interpreter to us in the meantime.
--
--- This is useful to avoid forgetting to receive the value and to ensure that
--- the type of the response isn't lost. Use receiveDelayedResponse to read it.
--- (locks the interpreter until the response is received using
--- `receiveDelayedResponse`)
-sendMessageDelayedResponse :: ExtInterpInstance d -> Message a -> IO (DelayedResponse a)
-sendMessageDelayedResponse i m = do
- lock i
- writeInterpProcess (instProcess i) (putMessage m)
- pure DelayedResponse
-
--- | Expect a delayed result to be received now
-receiveDelayedResponse :: Binary a => ExtInterpInstance d -> DelayedResponse a -> IO a
-receiveDelayedResponse i DelayedResponse = do
- ensureLocked i
- r <- readInterpProcess (instProcess i) get
- unlock i
- pure r
-
--- -----------------------------------------------------------------------------
--- Nested Message API
-
--- | Send any value (requires locked interpreter)
-sendAnyValue :: Binary a => ExtInterpInstance d -> a -> IO ()
-sendAnyValue i m = ensureLocked i >> writeInterpProcess (instProcess i) (put m)
-
--- | Expect a value to be received (requires locked interpreter)
-receiveAnyValue :: ExtInterpInstance d -> Get a -> IO a
-receiveAnyValue i get = ensureLocked i >> readInterpProcess (instProcess i) get
-
--- | Wait for a Template Haskell message (requires locked interpreter)
-receiveTHMessage :: ExtInterpInstance d -> IO THMsg
-receiveTHMessage i = ensureLocked i >> receiveAnyValue i getTHMessage
-
--- -----------------------------------------------------------------------------
-
-getLock :: ExtInterpInstance d -> MVar ()
-getLock = interpLock . instProcess
-
-withLock :: ExtInterpInstance d -> IO a -> IO a
-withLock i f = withMVar (getLock i) (const f)
-
-lock :: ExtInterpInstance d -> IO ()
-lock i = takeMVar (getLock i)
-
-unlock :: ExtInterpInstance d -> IO ()
-unlock i = putMVar (getLock i) ()
-
-ensureLocked :: ExtInterpInstance d -> IO ()
-ensureLocked i =
- isEmptyMVar (getLock i) >>= \case
- False -> panic "ensureLocked: external interpreter not locked"
- _ -> pure ()
-
-
--- | Send a 'Message' and receive the response from the interpreter process
-callInterpProcess :: Binary a => InterpProcess -> Message a -> IO a
-callInterpProcess i msg =
- remoteCall (interpPipe i) msg
- `catchException` \(e :: SomeException) -> handleInterpProcessFailure i e
-
--- | Read a value from the interpreter process
-readInterpProcess :: InterpProcess -> Get a -> IO a
-readInterpProcess i get =
- readPipe (interpPipe i) get
- `catchException` \(e :: SomeException) -> handleInterpProcessFailure i e
-
--- | Send a value to the interpreter process
-writeInterpProcess :: InterpProcess -> Put -> IO ()
-writeInterpProcess i put =
- writePipe (interpPipe i) put
- `catchException` \(e :: SomeException) -> handleInterpProcessFailure i e
+-- This function blocks until the TH computation returns a value, but spawns in
+-- the background a thread to handle the 'THMessage's until the TH computation
+-- is fully done.
+sendTHComputation
+ :: Binary a
+ => ExtInterpInstance d
+ -> (InboxId -> Message a)
+ -> (forall b. Binary b => THMessage b -> IO (Bool, b))
+ -- ^ Handle one message. Return True to end the loop.
+ -- This handler must never uninterrutibly mask an expression which may get
+ -- stuck. If it does, then 'sendTHComputation' will also get uninterruptibly stuck.
+ -> IO a
+sendTHComputation i msg reqHandler = mask $ \restore -> do
+ -- inline "withAsync/wait"
+ var <- newEmptyTMVarIO
+ mbox <- newMailbox (pipeAsyncMngr (interpPipe proc))
+ ht <- forkFinally (restore (handlerLoop mbox)) (atomically . putTMVar var)
+ restore (sendMessage i (msg mbox) <* atomically (readTMVar var))
+ `onException` uninterruptibleMask_ (throwTo ht CancelTHHandler)
+ where
+ proc = instProcess i
+ handleOne mbox doneRef = do
+ handleRemoteTHCall (interpPipe proc) mbox $ \req -> do
+ (stop, res) <- reqHandler req
+ writeIORef doneRef stop
+ return res
+ handlerLoop mbox = do
+ doneRef <- newIORef False
+ let loop = do
+ handleOne mbox doneRef
+ isDone <- readIORef doneRef
+ if isDone then return ()
+ else loop
+ in loop
handleInterpProcessFailure :: InterpProcess -> SomeException -> IO a
handleInterpProcessFailure i e = do
@@ -130,3 +88,8 @@ handleInterpProcessFailure i e = do
terminateProcess hdl
_ <- waitForProcess hdl
throw e
+
+data CancelTHHandler = CancelTHHandler deriving Show
+instance Exception CancelTHHandler where
+ fromException = asyncExceptionFromException
+ toException = asyncExceptionToException
=====================================
compiler/GHC/Runtime/Interpreter/Types.hs
=====================================
@@ -111,7 +111,6 @@ type WasmInterp = ExtInterpState WasmInterpConfig ()
data InterpProcess = InterpProcess
{ interpPipe :: !Pipe -- ^ Pipe to communicate with the server
, interpHandle :: !ProcessHandle -- ^ Process handle of the server
- , interpLock :: !(MVar ()) -- ^ Lock to prevent concurrent access to the stream
}
-- | Status of an external interpreter
=====================================
compiler/GHC/Runtime/Interpreter/Wasm.hs
=====================================
@@ -73,14 +73,12 @@ spawnWasmInterp WasmInterpConfig {..} = do
hSetBuffering rh NoBuffering
interpPipe <- mkPipeFromHandles rh wh
pending_frees <- newMVar []
- lock <- newMVar ()
pure
$ ExtInterpInstance
{ instProcess =
InterpProcess
{ interpHandle = ph,
- interpPipe,
- interpLock = lock
+ interpPipe
},
instPendingFrees = pending_frees,
instExtra = ()
=====================================
compiler/GHC/Runtime/Utils.hs
=====================================
@@ -1,84 +1,30 @@
-{-# LANGUAGE CPP #-}
-
module GHC.Runtime.Utils
( runWithPipes
)
where
import GHC.Prelude
+import GHC.Utils.Exception (onException)
-#if defined(mingw32_HOST_OS)
-import Foreign.C
-import GHC.IO.Handle.FD (fdToHandle)
-import GHC.Utils.Exception as Ex
-# if defined(__IO_MANAGER_WINIO__)
-import GHC.IO.SubSystem ((<!>))
-import GHC.IO.Handle.Windows (handleToHANDLE)
-import GHC.Event.Windows (associateHandle')
-# endif
-#else
-import System.Posix as Posix
-#endif
import System.Process
+import System.Process.CommunicationHandle
import System.IO
+-- | Spawn a process connected to us by two pipes. Important to close our copy
+-- of the endpoints passed to the child so each side only keeps open copies it
+-- needs. If we don't do that, then closing one end wouldn't interrupt reads on
+-- the other.
runWithPipes :: (CreateProcess -> IO ProcessHandle)
-> FilePath -> [String] -> [String] -> IO (ProcessHandle, Handle, Handle)
-#if defined(mingw32_HOST_OS)
-foreign import ccall "io.h _close"
- c__close :: CInt -> IO CInt
-
-foreign import ccall unsafe "io.h _get_osfhandle"
- _get_osfhandle :: CInt -> IO CIntPtr
-
-runWithPipesPOSIX :: (CreateProcess -> IO ProcessHandle)
- -> FilePath -> [String] -> [String] -> IO (ProcessHandle, Handle, Handle)
-runWithPipesPOSIX createProc prog pre_opts opts = do
- (rfd1, wfd1) <- createPipeFd -- we read on rfd1
- (rfd2, wfd2) <- createPipeFd -- we write on wfd2
- wh_client <- _get_osfhandle wfd1
- rh_client <- _get_osfhandle rfd2
- let args = pre_opts ++ (show wh_client : show rh_client : opts)
- ph <- createProc (proc prog args)
- rh <- mkHandle rfd1
- wh <- mkHandle wfd2
- return (ph, rh, wh)
- where mkHandle :: CInt -> IO Handle
- mkHandle fd = (fdToHandle fd) `Ex.onException` (c__close fd)
-
-# if defined (__IO_MANAGER_WINIO__)
-runWithPipesNative :: (CreateProcess -> IO ProcessHandle)
- -> FilePath -> [String] -> [String] -> IO (ProcessHandle, Handle, Handle)
-runWithPipesNative createProc prog pre_opts opts = do
- (rh, wfd1) <- createPipe -- we read on rfd1
- (rfd2, wh) <- createPipe -- we write on wfd2
- wh_client <- handleToHANDLE wfd1
- rh_client <- handleToHANDLE rfd2
- -- Associate the handle with the current manager
- -- but don't touch the ones we're passing to the child
- -- since it needs to register the handle with its own manager.
- associateHandle' =<< handleToHANDLE rh
- associateHandle' =<< handleToHANDLE wh
- let args = pre_opts ++ (show wh_client : show rh_client : opts)
- ph <- createProc (proc prog args)
- return (ph, rh, wh)
-
-runWithPipes = runWithPipesPOSIX <!> runWithPipesNative
-# else
-runWithPipes = runWithPipesPOSIX
-# endif
-#else
runWithPipes createProc prog pre_opts opts = do
- (rfd1, wfd1) <- Posix.createPipe -- we read on rfd1
- (rfd2, wfd2) <- Posix.createPipe -- we write on wfd2
- setFdOption rfd1 CloseOnExec True
- setFdOption wfd2 CloseOnExec True
- let args = pre_opts ++ (show wfd1 : show rfd2 : opts)
+ (rh, chTheyWrite) <- createWeReadTheyWritePipe
+ (chTheyRead, wh) <- createTheyReadWeWritePipe
+ let args = pre_opts ++ (show chTheyWrite : show chTheyRead : opts)
+ closeTheirs = do
+ closeCommunicationHandle chTheyWrite
+ closeCommunicationHandle chTheyRead
+ -- These handles have no finalizers, so close them ourselves if the spawn fails.
ph <- createProc (proc prog args)
- closeFd wfd1
- closeFd rfd2
- rh <- fdToHandle rfd1
- wh <- fdToHandle wfd2
+ `onException` (closeTheirs >> hClose rh >> hClose wh)
+ closeTheirs
return (ph, rh, wh)
-#endif
-
=====================================
compiler/GHC/Tc/Gen/Splice.hs
=====================================
@@ -170,6 +170,7 @@ import Data.IORef
import GHC.Parser.HaddockLex (lexHsDoc)
import GHC.Parser (parseIdentifier)
import GHC.Rename.Doc (rnHsDoc)
+import Data.Function
{-
Note [Template Haskell state diagram]
@@ -1165,11 +1166,12 @@ runRemoteModFinalizers (ThModFinalizers finRefs) = do
case th_state of
Nothing -> return () -- TH was not started, nothing to do
Just fhv -> do
- r <- liftIO $ withForeignRef fhv $ \st ->
- withForeignRefs finRefs $ \qrefs ->
- sendMessageDelayedResponse inst (RunModFinalizers st qrefs)
- () <- runRemoteTH inst []
- qr <- liftIO $ receiveDelayedResponse inst r
+ qr <- withRunInIO $ \runInIO -> do
+ recovers <- newIORef []
+ withForeignRef fhv $ \st ->
+ withForeignRefs finRefs $ \qrefs ->
+ sendTHComputation inst (\ii -> RunModFinalizers ii st qrefs) $ \msg ->
+ runInIO (runRemoteTH recovers msg)
checkQResult qr
runQResult
@@ -1824,48 +1826,47 @@ runTH ty fhv = do
rstate <- getTHState inst
loc <- location
-- run a remote TH request
- r <- liftIO $
+ qr <- withRunInIO $ \runInIO -> do
+ recovers <- newIORef []
withForeignRef rstate $ \state_hv ->
- withForeignRef fhv $ \q_hv ->
- sendMessageDelayedResponse inst (RunTH state_hv q_hv ty (Just loc))
- -- respond to requests from the interpreter
- runRemoteTH inst []
- -- get the final result
- qr <- liftIO $ receiveDelayedResponse inst r
+ withForeignRef fhv $ \q_hv ->
+ sendTHComputation inst (\ii -> RunTH ii state_hv q_hv ty (Just loc)) $ \msg ->
+ runInIO (runRemoteTH recovers msg)
bs <- checkQResult qr
return $! runGet get (LB.fromStrict bs)
--- | communicate with a remotely-running TH computation until it finishes.
+-- | Communicate with a remotely-running TH computation until it finishes.
-- See Note [Remote Template Haskell] in libraries/ghci/GHCi/TH.hs.
runRemoteTH
- :: ExtInterpInstance d
- -> [Messages TcRnMessage] -- saved from nested calls to qRecover
- -> TcM ()
-runRemoteTH inst recovers = do
- THMsg msg <- liftIO $ receiveTHMessage inst
+ :: Binary a
+ => IORef [Messages TcRnMessage] -- ^ saved from nested calls to qRecover
+ -> THMessage a
+ -> TcM (Bool, a)
+runRemoteTH recovers msg = do
case msg of
- RunTHDone -> return ()
+ RunTHDone -> return (True, ())
StartRecover -> do -- Note [TH recover with -fexternal-interpreter]
v <- getErrsVar
msgs <- readTcRef v
writeTcRef v emptyMessages
- runRemoteTH inst (msgs : recovers)
+ modifyIORef recovers (msgs:) & liftIO
+ return (False, ())
EndRecover caught_error -> do
- let (prev_msgs, rest) = case recovers of
- [] -> panic "EndRecover"
- a : b -> (a,b)
+ (prev_msgs, rest) <- liftIO $
+ readIORef recovers >>= \case
+ [] -> panic "EndRecover"
+ a : b -> pure (a,b)
v <- getErrsVar
warn_msgs <- getWarningMessages <$> readTcRef v
-- keep the warnings only if there were no errors
writeTcRef v $ if caught_error
then prev_msgs
else mkMessages warn_msgs `unionMessages` prev_msgs
- runRemoteTH inst rest
+ writeIORef recovers rest & liftIO
+ return (False, ())
_other -> do
- r <- handleTHMessage msg
- liftIO $ sendAnyValue inst r
- runRemoteTH inst recovers
+ (False,) <$> handleTHMessage msg
-- | Check a QResult
checkQResult :: QResult a -> TcM a
=====================================
compiler/ghc.cabal.in
=====================================
@@ -117,7 +117,7 @@ Library
Build-Depends: base >= 4.11 && < 4.24,
deepseq >= 1.4 && < 1.6,
directory >= 1 && < 1.4,
- process >= 1 && < 1.7,
+ process >= 1.6.20 && < 1.7,
bytestring >= 0.11 && < 0.13,
binary == 0.8.*,
text >= 2.0 && < 2.2,
=====================================
libraries/ghci/GHCi/Message.hs
=====================================
@@ -1,6 +1,7 @@
-{-# LANGUAGE GADTs, DeriveGeneric, StandaloneDeriving, ScopedTypeVariables,
- GeneralizedNewtypeDeriving, ExistentialQuantification, RecordWildCards,
- CPP, NamedFieldPuns #-}
+{-# LANGUAGE RecursiveDo, GADTs, DeriveGeneric, StandaloneDeriving, ScopedTypeVariables,
+ GeneralizedNewtypeDeriving, ExistentialQuantification, RecordWildCards, CPP,
+ NamedFieldPuns, LambdaCase, TypeAbstractions, TypeApplications,
+ LinearTypes, RankNTypes, UnboxedTuples, BlockArguments, TupleSections, MagicHash #-}
{-# OPTIONS_GHC -fno-warn-name-shadowing -fno-warn-orphans #-}
-- |
@@ -22,7 +23,16 @@ module GHCi.Message
, ResumeContext(..)
, QState(..)
, getMessage, putMessage, getTHMessage, putTHMessage
- , Pipe, mkPipeFromHandles, mkPipeFromContinuations, remoteCall, remoteTHCall, readPipe, writePipe
+
+ , Pipe(..), mkPipeFromHandles, mkPipeFromContinuations, closePipe
+ , remoteCall, remoteTHCall
+ , handleRemoteCall, handleRemoteTHCall, writeReply
+ , RemoteProcessException(..), PipeReadClosedException(..)
+
+ , InboxId(..)
+ , newMailbox
+ , closeMailbox
+
, BreakModule
, BreakUnitId
, LoadedDLL
@@ -45,18 +55,14 @@ import qualified GHC.Exts.Heap as Heap
import GHC.ForeignSrcLang
import GHC.Fingerprint
import GHC.Conc (pseq, par)
+import GHC.IO (IO(..))
import Control.Concurrent
import Control.DeepSeq
import Control.Exception
-#if MIN_VERSION_base(4,20,0)
-import Control.Exception.Context
-#endif
import Data.Binary
import Data.Binary.Get
import Data.Binary.Put
import Data.ByteString (ByteString)
-import qualified Data.ByteString as B
-import qualified Data.ByteString.Builder as B
import qualified Data.ByteString.Lazy as LB
import qualified Data.ByteString.Short as BS
import Data.Dynamic
@@ -68,9 +74,7 @@ import GHC.Generics
import GHC.Stack.CCS
import qualified GHC.Boot.TH.Syntax as TH
import qualified GHC.Boot.TH.Monad as TH
-import System.Exit
-import System.IO
-import System.IO.Error
+import GHCi.Message.Async
-- -----------------------------------------------------------------------------
-- The RPC protocol between GHC and the interactive server
@@ -214,14 +218,16 @@ data Message a where
-- they did, we have to serialize the value anyway, so we might
-- as well serialize it to force it.
RunTH
- :: RemoteRef (IORef QState)
+ :: InboxId -- ^ announce mailbox for related 'remoteTHCall's
+ -> RemoteRef (IORef QState)
-> HValueRef {- e.g. TH.Q TH.Exp -}
-> THResultType
-> Maybe TH.Loc
-> Message (QResult ByteString)
-- | Run the given mod finalizers.
- RunModFinalizers :: RemoteRef (IORef QState)
+ RunModFinalizers :: InboxId -- ^ announce mailbox for related 'remoteTHCall's
+ -> RemoteRef (IORef QState)
-> [RemoteRef (TH.Q ())]
-> Message (QResult ())
@@ -458,45 +464,6 @@ data BreakUnitId
-- | A dummy type that tags pointers returned by 'LoadDLLs'.
data LoadedDLL
--- SomeException can't be serialized because it contains dynamic
--- types. However, we do very limited things with the exceptions that
--- are thrown by interpreted computations:
---
--- * We print them, e.g. "*** Exception: <something>"
--- * UserInterrupt has a special meaning
--- * In ghc -e, exitWith should exit with the appropriate exit code
---
--- So all we need to do is distinguish UserInterrupt and ExitCode, and
--- all other exceptions can be represented by their 'show' string.
---
-data SerializableException
- = EUserInterrupt
- | EExitCode ExitCode
- | EOtherException String
- deriving (Generic, Show)
-
-toSerializableException :: SomeException -> SerializableException
-toSerializableException ex
- | Just UserInterrupt <- fromException ex = EUserInterrupt
- | Just (ec::ExitCode) <- fromException ex = (EExitCode ec)
- | otherwise = EOtherException $
-#if MIN_VERSION_base(4,20,0)
- -- Exception plus backtrace as seen in `displayExceptionWithInfo`
- case displayExceptionContext (someExceptionContext ex) of
- "" -> displayException (ex :: SomeException)
- cx -> displayException (ex :: SomeException) ++ "\n\n" ++ cx
-#else
- show (ex :: SomeException)
-#endif
-
-fromSerializableException :: SerializableException -> SomeException
-fromSerializableException EUserInterrupt = toException UserInterrupt
-fromSerializableException (EExitCode c) = toException c
-fromSerializableException (EOtherException str) = toException (ErrorCall str)
-
-instance Binary ExitCode
-instance Binary SerializableException
-
data THResult a
= THException String
| THComplete a
@@ -513,11 +480,13 @@ instance Binary THResultType
-- StartTH message. A new one is created per module that GHC
-- typechecks.
data QState = QState
- { qsMap :: Map TypeRep Dynamic
+ { qsMap :: Map TypeRep Dynamic
-- ^ persistent data between splices in a module
- , qsLocation :: Maybe TH.Loc
+ , qsLocation :: Maybe TH.Loc
-- ^ location for current splice, if any
- , qsPipe :: Pipe
+ , qsInboxId :: InboxId
+ -- ^ the mailbox expecting requests for each RunTH-like run
+ , qsPipe :: Pipe
-- ^ pipe to communicate with GHC
}
instance Show QState where show _ = "<QState>"
@@ -600,9 +569,9 @@ getMessage = do
29 -> Msg <$> (BreakpointStatus <$> get <*> get)
30 -> Msg <$> (GetBreakpointVar <$> get <*> get)
31 -> Msg <$> return StartTH
- 32 -> Msg <$> (RunModFinalizers <$> get <*> get)
+ 32 -> Msg <$> (RunModFinalizers <$> get <*> get <*> get)
33 -> Msg <$> (AddSptEntry <$> get <*> get)
- 34 -> Msg <$> (RunTH <$> get <*> get <*> get <*> get)
+ 34 -> Msg <$> (RunTH <$> get <*> get <*> get <*> get <*> get)
35 -> Msg <$> (GetClosure <$> get)
36 -> Msg <$> (Seq <$> get)
37 -> Msg <$> return RtsRevertCAFs
@@ -648,9 +617,9 @@ putMessage m = case m of
BreakpointStatus arr ix -> putWord8 29 >> put arr >> put ix
GetBreakpointVar a b -> putWord8 30 >> put a >> put b
StartTH -> putWord8 31
- RunModFinalizers a b -> putWord8 32 >> put a >> put b
+ RunModFinalizers a b c -> putWord8 32 >> put a >> put b >> put c
AddSptEntry a b -> putWord8 33 >> put a >> put b
- RunTH st q loc ty -> putWord8 34 >> put st >> put q >> put loc >> put ty
+ RunTH ii st q loc ty -> putWord8 34 >> put ii >> put st >> put q >> put loc >> put ty
GetClosure a -> putWord8 35 >> put a
Seq a -> putWord8 36 >> put a
RtsRevertCAFs -> putWord8 37
@@ -688,73 +657,39 @@ serializeBCOs rbcos = parMap doChunk (chunkList 100 rbcos)
chunkList _ [] = []
chunkList n xs = as : chunkList n bs where (as,bs) = splitAt n xs
--- -----------------------------------------------------------------------------
--- Reading/writing messages
-
--- | An opaque pipe for bidirectional binary data transmission.
-data Pipe = Pipe
- { getSome :: !(IO ByteString)
- , putAll :: !(B.Builder -> IO ())
- , pipeLeftovers :: !(IORef (Maybe ByteString))
- }
-
--- | Make a 'Pipe' from a 'Handle' to read and a 'Handle' to write.
-mkPipeFromHandles :: Handle -> Handle -> IO Pipe
-mkPipeFromHandles pipeRead pipeWrite = do
- let getSome = B.hGetSome pipeRead (32*1024)
- putAll b = do
- B.hPutBuilder pipeWrite b
- hFlush pipeWrite
- pipeLeftovers <- newIORef Nothing
- pure $ Pipe { getSome, putAll, pipeLeftovers }
-
--- | Make a 'Pipe' from a reader function and a writer function.
-mkPipeFromContinuations :: IO ByteString -> (B.Builder -> IO ()) -> IO Pipe
-mkPipeFromContinuations getSome putAll = do
- pipeLeftovers <- newIORef Nothing
- pure $ Pipe { getSome, putAll, pipeLeftovers }
-
+-- | Send a 'Message' request to and wait for a reply from the interpreter
+-- (blocks on the calling side, doesn't necessarily block the interpreter)
remoteCall :: Binary a => Pipe -> Message a -> IO a
-remoteCall pipe msg = do
- writePipe pipe (putMessage msg)
- readPipe pipe get
-
-writePipe :: Pipe -> Put -> IO ()
-writePipe Pipe{..} put = putAll $ execPut put
-
-remoteTHCall :: Binary a => Pipe -> THMessage a -> IO a
-remoteTHCall pipe msg = do
- writePipe pipe (putTHMessage msg)
- readPipe pipe get
-
-readPipe :: Pipe -> Get a -> IO a
-readPipe Pipe{..} get = do
- leftovers <- readIORef pipeLeftovers
- m <- getBin getSome get leftovers
- case m of
- Nothing -> throw $
- mkIOError eofErrorType "GHCi.Message.readPipe" Nothing Nothing
- Just (result, new_leftovers) -> do
- writeIORef pipeLeftovers new_leftovers
- return result
-
-getBin
- :: (IO ByteString) -> Get a -> Maybe ByteString
- -> IO (Maybe (a, Maybe ByteString))
-
-getBin getsome get leftover = go leftover (runGetIncremental get)
- where
- go Nothing (Done leftover _ msg) =
- return (Just (msg, if B.null leftover then Nothing else Just leftover))
- go _ Done{} = throwIO (ErrorCall "getBin: Done with leftovers")
- go (Just leftover) (Partial fun) = do
- go Nothing (fun (Just leftover))
- go Nothing (Partial fun) = do
- -- putStrLn "before hGetSome"
- b <- getsome
- -- putStrLn $ "hGetSome: " ++ show (B.length b)
- if B.null b
- then return Nothing
- else go Nothing (fun (Just b))
- go _lft (Fail _rest _off str) =
- throwIO (ErrorCall ("getBin: " ++ str))
+remoteCall pipe msg = either throwIO (pure . runGet get)
+ =<< remoteAsyncReq pipe (putMessage msg) Nothing
+
+-- | Handle a single 'Message' request on the interpreter and reply to the host
+handleRemoteCall :: Pipe
+ -> (Msg -> IO Msg) {-^ Msg hook -}
+ -> (forall a. (Show a, Binary a) => WriteReply a %1 -> Message a -> IO r)
+ -> IO r
+handleRemoteCall pipe hook k =
+ handleAsyncReq pipe getMessage Nothing \(WriteReply writer) msg0 -> IO \s0 ->
+ case hook msg0 |#> s0 of -- unIO for linearity checking
+ (# s1, Msg msg #) -> k (WriteReply \x -> writer (fmap put x)) msg |#> s1
+
+-- | Send a 'THMessage' request to the host and wait for a reply from the host
+-- to the interpreter.
+--
+-- A 'THMessage' request from the interpreter is always associated with a
+-- 'RunTH'-like run. Since the host may have many in-flight TH runs, we always
+-- want a specific host 'InboxId' (which is announced in the 'RunTH' request)
+remoteTHCall :: Binary a => Pipe -> InboxId -> THMessage a -> IO a
+remoteTHCall pipe ii msg = either throwIO (pure . runGet get)
+ =<< remoteAsyncReq pipe (putTHMessage msg) (Just ii)
+
+-- | Handle a 'THMessage' request on the host and reply to the interpreter.
+-- Symmterically to 'remoteTHCall', we always want to specify the 'InboxId' for
+-- RunTH "reverse requests"
+handleRemoteTHCall
+ :: Pipe -> InboxId -> (forall a. (Show a, Binary a) => THMessage a -> IO a) -> IO ()
+handleRemoteTHCall pipe ii k =
+ handleAsyncReq pipe getTHMessage (Just ii) \writer (THMsg msg) -> IO \s0 ->
+ case k msg |#> s0 of -- unIO for linearity checking
+ (# s1, a #) -> writeReply writer (put a) |#> s1
+
=====================================
libraries/ghci/GHCi/Message/Async.hs
=====================================
@@ -0,0 +1,562 @@
+{-# LANGUAGE RecursiveDo, GADTs, DeriveGeneric, StandaloneDeriving, ScopedTypeVariables,
+ GeneralizedNewtypeDeriving, ExistentialQuantification, RecordWildCards, CPP,
+ NamedFieldPuns, LambdaCase, TypeAbstractions, TypeApplications,
+ LinearTypes, RankNTypes, UnboxedTuples, BlockArguments, TupleSections, MagicHash #-}
+{-# OPTIONS_GHC -fno-warn-name-shadowing -fno-warn-orphans #-}
+module GHCi.Message.Async
+ (
+ -- * Pipes
+ Pipe(..), mkPipeFromHandles, mkPipeFromContinuations
+ , closePipe, PipeReadClosedException(..)
+
+ -- * Interface for async bidirectional RPC
+ , remoteAsyncReq, handleAsyncReq
+ , RemoteProcessException(..), DecodeAsyncReqException(..)
+
+ -- ** Mailboxes
+ , InboxId(..)
+ , newMailbox
+ , closeMailbox
+
+ -- ** Async matching internals
+ , AsyncManager(..), CorrelationId
+ , IddMsg(..), newAsyncManager
+
+ -- ** Consume `reply` exactly once
+ , WriteReply(..), writeReply
+ , runWriteReply, (|#>), (%>>=)
+
+ -- * Serializable exceptions
+ , SerializableException(..)
+ , toSerializableException, fromSerializableException
+ ) where
+
+import Prelude -- See note [Why do we import Prelude here?]
+import GHCi.TH.Binary () -- For Binary instances
+
+import GHC.IO (IO(..))
+import Control.Concurrent
+import Control.Exception
+#if MIN_VERSION_base(4,20,0)
+import Control.Exception.Context
+#endif
+import Data.Binary
+import Data.Binary.Get
+import Data.Binary.Put
+import Data.ByteString (ByteString)
+import qualified Data.ByteString as B
+import qualified Data.ByteString.Builder as B
+import qualified Data.ByteString.Lazy as LB
+import Data.IORef
+import Data.IntMap (IntMap)
+import qualified Data.IntMap as IntMap
+import Data.Maybe
+import GHC.Generics
+import System.Exit
+import System.IO
+import Control.Monad
+import Control.Concurrent.STM
+import Data.Bifunctor
+import GHC.Base (State#)
+import GHC.Exts (RealWorld)
+
+--------------------------------------------------------------------------------
+-- * Reading/writing and Pipes
+--------------------------------------------------------------------------------
+
+-- | An opaque pipe for bidirectional binary data transmission.
+data Pipe = Pipe
+ { getSome :: !(IO ByteString)
+ , putAll :: !(B.Builder -> IO ())
+ , pipeLeftovers :: !(IORef (Maybe ByteString))
+ , pipeLock :: !(MVar ()) -- ^ Lock to prevent concurrent writes to the stream
+ , pipeAsyncMngr :: !AsyncManager
+ , pipeCloseRead :: !(IO ())
+ -- ^ closes read end of the pipe
+ , pipeCloseWrite :: !(IO ())
+ -- ^ closes write end of the pipe
+ , pipeReadClosed :: !(TVar Bool)
+ -- ^ After the pipe is closed, messages can no longer be received from the
+ -- other end, but the 'AsyncManager' queues might not be empty yet.
+ , pipeWriteClosed :: !(TVar Bool)
+ -- ^ After the write end of the pipe is closed we can no longer submit
+ -- requests or respond to ones we receive, but we might still receive
+ -- replies.
+ }
+
+-- | Make a 'Pipe' from a 'Handle' to read and a 'Handle' to write.
+-- Must call 'closePipe' at the end to clean up.
+mkPipeFromHandles :: Handle -> Handle -> IO Pipe
+mkPipeFromHandles pipeRead pipeWrite = do
+ let getSome = B.hGetSome pipeRead (32*1024)
+ putAll b = do
+ B.hPutBuilder pipeWrite b
+ hFlush pipeWrite
+ mkPipeFromContinuations getSome putAll (hClose pipeRead) (hClose pipeWrite)
+
+-- | Make a 'Pipe' from a reader function and a writer function.
+-- The pipe should be closed with 'closePipe', which will call 'pipeCloseRead' and 'pipeCloseWrite'.
+mkPipeFromContinuations :: IO ByteString -> (B.Builder -> IO ())
+ -> IO ()
+ -- ^ pipeCloseRead
+ -> IO ()
+ -- ^ pipeCloseWrite
+ -> IO Pipe
+mkPipeFromContinuations getSome putAll pipeCloseRead pipeCloseWrite = mdo
+ pipeLeftovers <- newIORef Nothing
+ pipeLock <- newMVar ()
+ pipeReadClosed <- newTVarIO False
+ pipeWriteClosed <- newTVarIO False
+ mdo
+ pipeAsyncMngr <- newAsyncManager p
+ let p = Pipe { .. }
+ pure p
+
+-- | Close our ends of the pipe.
+--
+-- The ordering is subtle and important. We first fail any requests still
+-- waiting for a reply, then close the write end so the other side sees EOF.
+-- We take the write lock to close it, so we never close under a concurrent
+-- write. Only then do we stop the drain thread, which closes the read end
+-- itself once its read has finished. On Windows its read can't be
+-- interrupted, so this waits for the other side to close its write end too.
+-- Finally we stop the write thread, which could be blocked waiting for more to write.
+closePipe :: Pipe -> IO ()
+closePipe p@Pipe{..} = do
+ readAlreadyClosed <- atomically $ do
+ closed <- readTVar pipeReadClosed
+ failPendingReplies p (toException PipeReadClosedException)
+ pure closed
+
+ writeAlreadyClosed <- readTVarIO pipeWriteClosed
+
+ unless writeAlreadyClosed (withLock p pipeCloseWrite)
+ `finally` do
+ unless readAlreadyClosed
+ (throwTo (asyncDrainTid pipeAsyncMngr) PipeReadClosedException)
+ unless writeAlreadyClosed
+ (throwTo (asyncFillTid pipeAsyncMngr) PipeWriteClosedException)
+
+-- | We've closed the pipe read end on this process
+data PipeReadClosedException = PipeReadClosedException deriving Show
+instance Exception PipeReadClosedException
+
+-- | We've closed the pipe write end on this process
+data PipeWriteClosedException = PipeWriteClosedException deriving Show
+instance Exception PipeWriteClosedException
+
+--------------------------------------------------------------------------------
+-- ** Pipe thread-safe read/write
+--------------------------------------------------------------------------------
+-- All messages on the wire are 'IddMsg', which contain a correlation header
+-- and identify whether they are requests or replies.
+
+writePipe :: Pipe -> IddMsg -> IO ()
+writePipe Pipe{..} msg = atomically $ do
+ readTVar pipeWriteClosed >>= \case
+ True -> throwSTM PipeWriteClosedException
+ False -> pure ()
+ writeTQueue (writeQueue pipeAsyncMngr) msg
+
+-- | Only the 'drainPipe' thread should read from the pipe directly. Other
+-- functions should wait for the matching reply to be delivered asynchronously.
+-- (see 'withAsyncReq'). It doesn't lock to read bc it assumes single reader is 'drainPipe'.
+--
+-- Returns @Nothing@ on EOF.
+readPipe :: Pipe -> IO (Maybe IddMsg)
+readPipe Pipe{..} = do
+ leftovers <- readIORef pipeLeftovers
+ m <- getBin getSome get leftovers
+ case m of
+ Nothing -> return Nothing
+ Just (result, new_leftovers) -> do
+ writeIORef pipeLeftovers new_leftovers
+ return (Just result)
+
+getBin
+ :: (IO ByteString) -> Get a -> Maybe ByteString
+ -> IO (Maybe (a, Maybe ByteString))
+
+getBin getsome get leftover = go leftover (runGetIncremental get)
+ where
+ go Nothing (Done leftover _ msg) =
+ return (Just (msg, if B.null leftover then Nothing else Just leftover))
+ go _ Done{} = throwIO (ErrorCall "getBin: Done with leftovers")
+ go (Just leftover) (Partial fun) = do
+ go Nothing (fun (Just leftover))
+ go Nothing (Partial fun) = do
+ -- putStrLn "before hGetSome"
+ b <- getsome
+ -- putStrLn $ "hGetSome: " ++ show (B.length b)
+ if B.null b
+ then return Nothing
+ else go Nothing (fun (Just b))
+ go _lft (Fail _rest _off str) =
+ throwIO (ErrorCall ("getBin: " ++ str))
+
+withLock :: Pipe -> IO c -> IO c
+withLock Pipe{..} = bracket (takeMVar pipeLock) (putMVar pipeLock) . const
+
+--------------------------------------------------------------------------------
+-- * Matching requests with async replies
+--------------------------------------------------------------------------------
+
+-- | Send an asynchronous request and block waiting for a matching reply
+remoteAsyncReq :: Pipe -> Put -> (Maybe InboxId) -> IO (Either SomeException LB.ByteString)
+remoteAsyncReq pipe msg ii = do
+
+ let pendingReplies = pendingReply (pipeAsyncMngr pipe)
+
+ -- Mark pending request
+ uq <- freshId (pipeAsyncMngr pipe)
+ wv <- newEmptyTMVarIO
+
+ isClosed <- atomically $ do
+ isClosed <- readTVar (pipeReadClosed pipe)
+ -- don't send the req if we won't get a reply.
+ if isClosed
+ then pure True
+ else do
+ modifyTVar pendingReplies (IntMap.insert uq wv)
+ pure False
+
+ when isClosed $ do
+ throwIO PipeReadClosedException
+
+ -- Write request
+ writePipe pipe (Request uq ii (runPut msg))
+ `onException`
+ -- the req wasn't done, or no one will be reading the reply:
+ -- in either case, drop it from the pending map.
+ atomically (modifyTVar pendingReplies (IntMap.delete uq))
+
+ -- Block waiting for reply
+ atomically (takeTMVar wv)
+ `onException`
+ atomically (modifyTVar pendingReplies (IntMap.delete uq))
+
+-- | Receive a single asynchronous request and send a matching reply
+-- asynchronously (the handler may fork a computation that eventually replies
+-- and can return before actually replying, as long as it eventually does).
+--
+-- The handler receives as an argument the function to use to reply to the request.
+-- It must be used exactly once (all requests expect a reply, and you can't
+-- reply more than once). Linear types enforce the handler replies in every
+-- branch, and if the handler otherwise throws, it is handled by 'handleAsyncReq'.
+handleAsyncReq :: Pipe -> Get a -> (Maybe InboxId) -> (WriteReply Put %1 -> a -> IO r) -> IO r
+handleAsyncReq pipe getit mii k = mask $ \restore -> do
+ let am = pipeAsyncMngr pipe
+ ack <- newEmptyMVar
+
+ -- Block waiting for request
+ mbreq <- atomically $ do
+ readTVar (pipeWriteClosed pipe) >>= \case
+ -- We will not be able to write the reply, so no point in continuiting.
+ True -> throwSTM PipeWriteClosedException
+ False -> pure ()
+ isClosed <- readTVar (pipeReadClosed pipe)
+ taken <- case mii of
+ Nothing -> tryReadTQueue $ requestsQueue am
+ Just ii -> tryReadTQueue =<< getMailbox am ii
+ case taken of
+ Just req -> pure (Just req)
+ Nothing | isClosed -> pure Nothing -- empty and closed
+ | otherwise -> retry -- wait for msg
+
+ case mbreq of
+ Nothing -> throwIO PipeReadClosedException -- can't expect reqs
+ Just (uq, bs) -> do
+ let reply p = do
+ writePipe pipe (Reply uq (bimap toSerializableException runPut p))
+ putMVar ack ()
+
+ -- Run the continuation which must reply exactly once with 'writeReply'
+ case runGetOrFail getit bs of
+ Left (_, _, err) -> do
+ let exc = DecodeAsyncReqException err
+ reply (Left (toException exc))
+ throwIO exc
+ Right (_, _, it) ->
+ restore (k (WriteReply reply) it)
+
+ -- If there's an exception before the reply is sent, reply with an error instead.
+ `catch` \(e :: SomeException) -> do
+
+ tryTakeMVar ack >>= \case
+ Just () ->
+ -- Already replied
+ throwIO e
+ Nothing -> do
+ -- Reply with an error
+ reply (Left e)
+ throwIO e
+
+-- | 'handleSyncReq' failed to decode an incoming request payload using the given @'Get' a@
+newtype DecodeAsyncReqException = DecodeAsyncReqException String deriving Show
+instance Exception DecodeAsyncReqException
+
+
+-- ** Mailboxes ----------------------------------------------------------------
+
+-- | A 'Request' may optionally declare an 'InboxId'. If it does, it can only
+-- be read by a 'handleAsyncReq' for that specific 'InboxId'. That is,
+-- @'handleAsyncReq' p get Nothing@ will not receive messages meant for a
+-- specific inbox.
+--
+-- This is useful to prevent mixing up reverse requests, where we want to send
+-- many reverse requests but have the caller handle them without interleaving
+-- them.
+newtype InboxId = InboxId Int deriving (Show, Binary)
+
+-- | Create a new mailbox from where we can read all requests addressed to this 'InboxId'.
+newMailbox :: AsyncManager -> IO InboxId
+newMailbox am = InboxId <$> freshId am
+ -- `mailboxQueues` is written on demand, no need to do it here.
+
+-- | Clean up a created mailbox by 'InboxId'.
+closeMailbox :: AsyncManager -> InboxId -> IO ()
+closeMailbox AsyncManager{..} (InboxId ii) =
+ atomically (modifyTVar mailboxQueues (IntMap.delete ii))
+
+-- | Get or create a new mailbox for this 'InboxId'
+getMailbox :: AsyncManager -> InboxId -> STM (TQueue (CorrelationId, LB.ByteString))
+getMailbox am (InboxId ii) = do
+ mboxes <- readTVar (mailboxQueues am)
+ case IntMap.lookup ii mboxes of
+ Nothing -> do
+ q <- newTQueue
+ writeTVar (mailboxQueues am) (IntMap.insert ii q mboxes)
+ pure q
+ Just q ->
+ pure q
+
+-- ** Async matching "internals" -----------------------------------------------
+
+data AsyncManager = AsyncManager
+ { pendingReply :: !(TVar (IntMap (TMVar (Either SomeException LB.ByteString))))
+ -- ^ When a request is sent, keep track that we're expecting a reply. The
+ -- TMVar is signaled when the reply arrives. The exception can originate
+ -- from the host process, or from the remote one (with 'RemoteProcessException').
+ , requestsQueue :: !(TQueue (CorrelationId, LB.ByteString))
+ -- ^ A queue of pending received requests. When a request is received
+ -- /without/ a specific 'InboxId', queue it here. A request handler will
+ -- pop the next request from it. (Nothing except the 'drainPipe' thread
+ -- should read from the pipe). Read with @'handleAsyncReq' p get Nothing@.
+ , mailboxQueues :: !(TVar (IntMap (TQueue (CorrelationId, LB.ByteString))))
+ -- ^ Requests for a specific 'InboxId' that can be read using
+ -- @'handleAsyncReq' p get (Just <mailboxid>)@.
+ , writeQueue :: !(TQueue IddMsg)
+ -- ^ Messages to write on the pipe.
+ , asyncDrainTid :: !ThreadId
+ , asyncFillTid :: !ThreadId
+ , asyncFreshId :: !(IORef Int)
+ }
+
+-- | Each 'Request' expects a 'Reply' with a matching 'CorrelationId'.
+type CorrelationId = Int
+
+-- | We have a single type for requests and replies because both the host and
+-- interpreter may send requests *and* replies on the write end *and* on recv
+-- both on the read end.
+--
+-- For instance:
+-- 1. The host sends a RunTH request on its Host Write End (HWE)
+-- 2. The interpreter sends a NewName TH request on its Interpreter Write End (IWE)
+-- 3. The host sends a reply to the TH request on its HWE
+-- 4. The interpreter sends the reply to the RunTH request on its IWE
+--
+-- Additionally, we want to keep concurrent TH requests for independent RunTH
+-- calls separated. Thus the interpreter requests additionally specify a
+-- mailbox announced by RunTH:
+-- 1. To interpreter: @Request _ Nothing (RunTH <mailid>)@
+-- 2. From interpreter: @Request _ (Just <mailid>) NewName@
+-- And the host will relate the <mailid> reverse requests to that RunTH run
+-- exclusively.
+data IddMsg = Request !CorrelationId !(Maybe InboxId) LB.ByteString
+ | Reply !CorrelationId (Either SerializableException LB.ByteString)
+
+instance Binary IddMsg where
+ put (Request i ii bs) = putWord8 0 >> put i >> put ii >> put bs
+ put (Reply i bs) = putWord8 1 >> put i >> put bs
+ get = do
+ b <- getWord8
+ case b of
+ 0 -> Request <$> get <*> get <*> get
+ 1 -> Reply <$> get <*> get
+ _ -> fail $ "impossible: Binary IddMsg - " ++ show b
+
+newAsyncManager :: Pipe -> IO AsyncManager
+newAsyncManager pipe = do
+ asyncFreshId <- newIORef 0
+ pendingReply <- newTVarIO IntMap.empty
+ requestsQueue <- newTQueueIO
+ mailboxQueues <- newTVarIO IntMap.empty
+ writeQueue <- newTQueueIO
+
+ -- Fork thread to drain read end.
+ -- (cleaned up on 'closePipe')
+ asyncDrainTid <- forkIOWithUnmask (drainPipe pipe)
+
+ -- Fork thread to fill write end.
+ -- (cleaned up on 'closePipe')
+ asyncFillTid <- forkIOWithUnmask (fillPipe pipe)
+
+ let am = AsyncManager{..}
+ pure am
+
+-- | Drains the read end of the Pipe and match 'Reply'es against pending 'Request's.
+--
+-- In pratice, we'll have both a thread draining the read end of the host's
+-- 'Pipe' and a thread draining the read end of the interpreter's 'Pipe', since
+-- both processes construct a 'Pipe' and send and receive messages
+--
+-- Closes the Pipe read end when done reading
+drainPipe :: Pipe -> (forall x. IO x -> IO x) -> IO ()
+drainPipe p unmask = catch (unmask $ loop `finally` pipeCloseRead p) replyToPendings where
+ loop = do
+ readPipe p >>= \case
+ -- Receive a reply to a pending notification
+ Just (Reply uq bs) -> do
+ atomically $ do
+ m <- readTVar (pendingReply am)
+ case IntMap.lookup uq m of
+ Nothing ->
+ -- the req was dropped from pending bc there was an exception, and no
+ -- one's listening any more. the reply is ignored
+ pure ()
+ Just wv -> do
+ writeTVar (pendingReply am) (IntMap.delete uq m)
+ -- signal matching request
+ putTMVar wv (bimap (toException . RemoteProcessException) id bs)
+ loop
+ -- Receive a request and queue it
+ Just (Request uq mbi bs) -> do
+ atomically $ case mbi of
+ Nothing ->
+ -- "Global" request
+ writeTQueue (requestsQueue am) (uq,bs)
+ Just ii -> do
+ -- "Specific mailbox" request
+ q <- getMailbox am ii
+ writeTQueue q (uq,bs)
+ loop
+ -- EOF on read handle
+ Nothing -> do
+ -- clean up pipe then exit loop
+ replyToPendings (toException PipeReadClosedException)
+ pure ()
+
+ replyToPendings e = atomically $ failPendingReplies p e
+
+ am = pipeAsyncMngr p
+
+
+-- | "Fill"s write end of the Pipe with queues messages.
+--
+-- Closes the Pipe write end when stopping, notifying any requests still queued to write.
+fillPipe :: Pipe -> (forall x. IO x -> IO x) -> IO ()
+fillPipe p unmask = unmask $ catch (loop `finally` pipeCloseWrite p) failPendingWrites where
+ loop = do
+ msg <- atomically $ readTQueue (writeQueue am)
+ withLock p . putAll p . execPut . put $ msg
+ loop
+
+ am = pipeAsyncMngr p
+
+ failPendingWrites :: SomeException -> IO ()
+ failPendingWrites e = atomically $ do
+ writeTVar (pipeWriteClosed p) True
+
+ writes <- flushTQueue (writeQueue am)
+ let uqs = [uq | Request uq _ _ <- writes]
+ pendings <- readTVar (pendingReply (pipeAsyncMngr p))
+ let tmvars = mapMaybe (`IntMap.lookup` pendings) uqs
+ writeTVar (pendingReply (pipeAsyncMngr p)) $! (foldl' (flip IntMap.delete) pendings uqs)
+ mapM_ (`writeTMVar` Left e) tmvars
+
+failPendingReplies :: Pipe -> SomeException -> STM ()
+failPendingReplies p e = do
+ -- reqs are only added if pipe not closed;
+ -- thus we close and take all pending atomically.
+ writeTVar (pipeReadClosed p) True
+ pendings <- swapTVar (pendingReply (pipeAsyncMngr p)) IntMap.empty
+ mapM_ (\wv -> putTMVar wv (Left e)) pendings
+
+-- | An exception that can be thrown on the host process representing an
+-- expection that happened on the remote one.
+newtype RemoteProcessException = RemoteProcessException SerializableException deriving Show
+instance Exception RemoteProcessException
+
+-- | Come up with a fresh id for 'CorrelationId' or 'InboxId'
+freshId :: AsyncManager -> IO Int
+freshId AsyncManager{asyncFreshId} =
+ atomicModifyIORef' asyncFreshId $ \i -> (i+1, i)
+
+--------------------------------------------------------------------------------
+-- * Consume `reply` exactly once
+--------------------------------------------------------------------------------
+
+-- | Every request should get exactly one reply.
+data WriteReply a where
+ WriteReply :: (Either SomeException a -> IO ()) %1 -> WriteReply a
+
+-- | Write a reply exactly once (consuming the ability to write more replies)
+writeReply :: WriteReply a %1 -> a -> IO ()
+writeReply (WriteReply r) = \x -> r (Right x)
+
+-- | Write the reply with a value or an exception
+runWriteReply :: WriteReply a %1 -> Either SomeException a -> IO ()
+runWriteReply (WriteReply r) = r
+
+-- | Infix, linear, 'unIO'
+(|#>) :: IO a %1 -> State# RealWorld -> (# State# RealWorld, a #)
+(|#>) (IO fs) s = fs s
+
+(%>>=) :: (IO a) -> (a -> IO b) %1 -> IO b
+(%>>=) = \ m f -> IO (\s0 ->
+ case m |#> s0 of -- unIO for linearity checking
+ (# s1, x #) -> f x |#> s1)
+infixl 1 %>>=
+
+--------------------------------------------------------------------------------
+-- * Serializable Exceptions
+--------------------------------------------------------------------------------
+
+-- SomeException can't be serialized because it contains dynamic
+-- types. However, we do very limited things with the exceptions that
+-- are thrown by interpreted computations:
+--
+-- * We print them, e.g. "*** Exception: <something>"
+-- * UserInterrupt has a special meaning
+-- * In ghc -e, exitWith should exit with the appropriate exit code
+--
+-- So all we need to do is distinguish UserInterrupt and ExitCode, and
+-- all other exceptions can be represented by their 'show' string.
+--
+data SerializableException
+ = EUserInterrupt
+ | EExitCode ExitCode
+ | EOtherException String
+ deriving (Generic, Show)
+
+toSerializableException :: SomeException -> SerializableException
+toSerializableException ex
+ | Just UserInterrupt <- fromException ex = EUserInterrupt
+ | Just (ec::ExitCode) <- fromException ex = (EExitCode ec)
+ | otherwise = EOtherException $
+#if MIN_VERSION_base(4,20,0)
+ -- Exception plus backtrace as seen in `displayExceptionWithInfo`
+ case displayExceptionContext (someExceptionContext ex) of
+ "" -> displayException (ex :: SomeException)
+ cx -> displayException (ex :: SomeException) ++ "\n\n" ++ cx
+#else
+ show (ex :: SomeException)
+#endif
+
+fromSerializableException :: SerializableException -> SomeException
+fromSerializableException EUserInterrupt = toException UserInterrupt
+fromSerializableException (EExitCode c) = toException c
+fromSerializableException (EOtherException str) = toException (ErrorCall str)
+
+instance Binary ExitCode
+instance Binary SerializableException
=====================================
libraries/ghci/GHCi/Server.hs
=====================================
@@ -1,4 +1,4 @@
-{-# LANGUAGE CPP, RankNTypes, RecordWildCards, GADTs, ScopedTypeVariables #-}
+{-# LANGUAGE LambdaCase, CPP, RankNTypes, RecordWildCards, GADTs, ScopedTypeVariables, LinearTypes #-}
module GHCi.Server
( MessageHook
, CustomMessageHandler
@@ -15,6 +15,7 @@ import GHCi.Signals
import GHCi.TH
import GHCi.Message
import Data.ByteString (ByteString)
+import Data.IORef
#if defined(wasm32_HOST_ARCH)
import qualified Data.ByteString.Builder as B
import qualified Data.ByteString.Internal as B
@@ -30,7 +31,6 @@ import GHCi.Utils
import Control.DeepSeq
import Control.Exception
import Control.Monad
-import Control.Concurrent (threadDelay)
import Data.Binary
import Text.Printf
@@ -38,6 +38,10 @@ import System.Environment (getProgName, getArgs)
import System.Exit
import System.IO
+import Control.Concurrent
+import GHCi.Message.Async (runWriteReply, (%>>=))
+import GHCi.Server.Threads
+
type MessageHook = Msg -> IO Msg
-- | How to interpret the 'CustomCommand'.
@@ -57,30 +61,35 @@ servWithCustom
:: Bool
-> MessageHook
-> Pipe
- -> (forall a .IO a -> IO a)
+ -> (forall a. IO a -> IO a)
-> CustomMessageHandler
-> IO ()
-servWithCustom verbose hook pipe restore customHandler = loop
+servWithCustom verbose hook pipe restore customHandler = do
+ ref <- newIORef False
+ withThreadManager $ \mngr ->
+ loop ref mngr `finally` closePipe pipe
where
- loop = do
+ loop doneRef mngr = do
when verbose $ trace "reading pipe..."
- Msg msg <- readPipe pipe getMessage >>= hook
- discardCtrlC
+ handleRemoteCall pipe hook $ \wr (msg :: Message a) ->
- when verbose $ trace ("msg: " ++ (show msg))
- case msg of
- CustomMessage tag payload -> handleCustom tag payload
- Shutdown -> return ()
- RunTH st q ty loc -> wrapRunTH $ runTH pipe st q ty loc
- RunModFinalizers st qrefs -> wrapRunTH $ runModFinalizerRefs pipe st qrefs
- _other -> run msg >>= reply
+ discardCtrlC %>>= \_ ->
+ when verbose (trace ("msg: " ++ (show msg))) %>>= \_ ->
- reply :: forall a. (Binary a, Show a) => a -> IO ()
- reply r = do
- when verbose $ trace ("writing pipe: " ++ show r)
- writePipe pipe (put r)
- loop
+ case msg of
+ CustomMessage tag payload -> handleCustom tag payload %>>= writeReply wr
+ Shutdown -> writeIORef doneRef True >>
+ reply () %>>= writeReply wr
+ RunTH ii st q ty loc -> spawnFinally mngr (runWriteReply wr)
+ (wrapRunTH ii (runTH pipe ii st q ty loc))
+ RunModFinalizers ii st qs -> spawnFinally mngr (runWriteReply wr)
+ (wrapRunTH ii (runModFinalizerRefs pipe ii st qs))
+ _other -> run msg >>= reply %>>= writeReply wr
+
+ isDone <- readIORef doneRef
+ if isDone then pure ()
+ else loop doneRef mngr
handleCustom tag payload = do
mresp <- customHandler tag payload
@@ -89,17 +98,22 @@ servWithCustom verbose hook pipe restore customHandler = loop
Nothing ->
error $ "GHCi.Server: unhandled CustomMessage with tag " ++ show tag
+ reply :: forall a. Show a => a -> IO a
+ reply r = do
+ when verbose $ trace ("writing pipe: " ++ show r)
+ return r -- the result of the handler is passed to writeReply
+
-- Run some TH code, which may interact with GHC by sending
-- THMessage requests, and then finally send RunTHDone followed by a
-- QResult. For an overview of how TH works with Remote GHCi, see
-- Note [Remote Template Haskell] in libraries/ghci/GHCi/TH.hs.
- wrapRunTH :: forall a. (Binary a, Show a) => IO a -> IO ()
- wrapRunTH io = do
+ wrapRunTH :: forall a. (Binary a, Show a) => InboxId -> IO a -> IO (QResult a)
+ wrapRunTH ii io = do
when verbose $ trace "wrapRunTH..."
r <- try io
when verbose $ trace "wrapRunTH done."
when verbose $ trace "writing RunTHDone."
- writePipe pipe (putTHMessage RunTHDone)
+ remoteTHCall pipe ii RunTHDone
case r of
Left e
| Just (GHCiQException _ err) <- fromException e -> do
@@ -159,8 +173,8 @@ defaultServerWithCustom customHandler = do
(outh, inh, rest) <-
case args of
arg0:arg1:rest -> do
- inh <- readGhcHandle arg1
- outh <- readGhcHandle arg0
+ inh <- readGhcHandle ReadMode arg1
+ outh <- readGhcHandle WriteMode arg0
return (outh, inh, rest)
_ -> dieWithUsage
#endif
@@ -179,7 +193,7 @@ defaultServerWithCustom customHandler = do
#if defined(wasm32_HOST_ARCH)
-- See Note [wasm ghci signal handlers] for details
installSignalHandlers $ js_register_signal_handler cb_sig
- pipe <- mkPipeFromContinuations (recv_buf cb_recv) (send_buf cb_send)
+ pipe <- mkPipeFromContinuations (recv_buf cb_recv) (send_buf cb_send) (pure ()) (pure ())
#else
when verbose $
printf "GHC iserv starting (in: %s; out: %s)\n" (show inh) (show outh)
@@ -195,8 +209,6 @@ defaultServerWithCustom customHandler = do
uninterruptibleMask $ \restore -> servWithCustom verbose hook pipe restore customHandler
where hook = return -- empty hook
- -- we cannot allow any async exceptions while communicating, because
- -- we will lose sync in the protocol, hence uninterruptibleMask.
dieWithUsage :: IO a
dieWithUsage = do
=====================================
libraries/ghci/GHCi/Server/Threads.hs
=====================================
@@ -0,0 +1,72 @@
+{-# LANGUAGE LambdaCase, CPP, RankNTypes, RecordWildCards, GADTs, ScopedTypeVariables, LinearTypes, BlockArguments #-}
+module GHCi.Server.Threads
+ ( ThreadManager -- abstract for linearity
+ , withThreadManager -- scoped, so that we're guaranteed to wait for threads
+ , spawnFinally
+ ) where
+
+import Prelude
+import Control.Exception
+import Control.Monad
+
+import Control.Concurrent
+import Control.Concurrent.STM
+import qualified Data.Set as Set
+import qualified Unsafe.Coerce as Unsafe
+
+data ThreadManager = ThreadManager
+ { managedThreads :: !(TVar (Set.Set ThreadId))
+ , managerClosed :: !(TVar Bool)
+ }
+
+-- | Cancels and Waits for all threads spawned by 'ThreadManager' to terminate
+-- before returning.
+--
+-- This thread manager which cancels then waits for all pending threads allows
+-- us to provide a resource-safe linearly typed 'spawnFinally', because
+-- 'withThreadManager' guarantees neither the threads nor their exceptions
+-- leak.
+withThreadManager :: (ThreadManager -> IO a) -> IO a
+withThreadManager k = do
+ managedThreads <- newTVarIO Set.empty
+ managerClosed <- newTVarIO False
+ let tm = ThreadManager{..}
+ k tm `finally` shutdown tm
+ where
+ shutdown ThreadManager{..} = do
+ ts <- atomically $ do
+ writeTVar managerClosed True
+ Set.elems <$> readTVar managedThreads
+ mapM_ killThread ts
+
+-- | Linear and resource-safe because 'ThreadManager' is guaranteed to wait or
+-- cancel all threads.
+spawnFinally :: ThreadManager -> (Either SomeException a -> IO ()) %1 -> IO a -> IO ()
+spawnFinally ThreadManager{..} = unsafeLinear \fin -> \action -> void $
+ forkFinally
+ ( mask $ \unmask -> do
+ tid <- myThreadId
+ registered <- atomically $ do
+ s <- readTVar managerClosed
+ unless s $ modifyTVar' managedThreads (Set.insert tid)
+ pure (not s)
+ if registered
+ then (unmask action)
+ `finally`
+ atomically (modifyTVar' managedThreads (Set.delete tid))
+ else throwIO ThreadKilled
+ )
+ ( \ea -> fin ea )
+
+unsafeLinear :: (a -> b) %1 -> (a %1 -> b)
+unsafeLinear = Unsafe.unsafeCoerce (Unsafe.unsafeCoerce :: (a -> b) -> (a %1 -> b))
+
+-- TODO:
+-- could be used to cancel a specific handler.
+-- cancel :: ThreadManager -> CorrelationId -> IO ()
+-- cancel ThreadManager{..} i = do
+-- ts <- atomically $ do
+-- readTVar managedThreads
+-- case IM.lookup i ts of
+-- Just tid -> killThread tid
+-- Nothing -> pure ()
=====================================
libraries/ghci/GHCi/TH.hs
=====================================
@@ -115,8 +115,8 @@ import qualified GHC.Boot.TH.Monad as TH
import Unsafe.Coerce
-- | Create a new instance of 'QState'
-initQState :: Pipe -> QState
-initQState p = QState M.empty Nothing p
+initQState :: Pipe -> InboxId -> QState
+initQState p ii = QState M.empty Nothing ii p
-- | The monad in which we run TH computations on the server
newtype GHCiQ a = GHCiQ { runGHCiQ :: IORef QState -> IO a }
@@ -156,7 +156,7 @@ noLoc = TH.Loc "<no file>" "<no package>" "<no module>" (0,0) (0,0)
ghcCmd :: Binary a => THMessage (THResult a) -> GHCiQ a
ghcCmd m = GHCiQ $ \sRef -> do
s <- readIORef sRef
- r <- remoteTHCall (qsPipe s) m
+ r <- remoteTHCall (qsPipe s) (qsInboxId s) m
case r of
THException str -> throwIO (GHCiQException s str)
THComplete res -> return res
@@ -189,9 +189,9 @@ metaHandlersGHCiQ runInIO = TH.MetaHandlers {
-- See Note [TH recover with -fexternal-interpreter] in GHC.Tc.Gen.Splice
, mRecover = \h a -> runInIO $ GHCiQ $ \sRef -> mask $ \unmask -> do
s <- readIORef sRef
- remoteTHCall (qsPipe s) StartRecover
+ remoteTHCall (qsPipe s) (qsInboxId s) StartRecover
e <- try $ unmask $ runGHCiQ (runQinGHCiQ a <* ghcCmd FailIfErrs) sRef
- remoteTHCall (qsPipe s) (EndRecover (isLeft e))
+ remoteTHCall (qsPipe s) (qsInboxId s) (EndRecover (isLeft e))
case e of
Left GHCiQException{} ->
runGHCiQ (runQinGHCiQ h) sRef
@@ -233,26 +233,28 @@ metaHandlersGHCiQ runInIO = TH.MetaHandlers {
-- a new IORef QState, and return a RemoteRef to it.
startTH :: IO (RemoteRef (IORef QState))
startTH = do
- r <- newIORef (initQState (error "startTH: no pipe"))
+ r <- newIORef (initQState (error "startTH: no pipe") (error "startTH: no inbox id"))
mkRemoteRef r
-- | Runs the mod finalizers.
--
-- The references must be created on the caller process.
-runModFinalizerRefs :: Pipe -> RemoteRef (IORef QState)
+runModFinalizerRefs :: Pipe -> InboxId
+ -> RemoteRef (IORef QState)
-> [RemoteRef (TH.Q ())]
-> IO ()
-runModFinalizerRefs pipe rstate qrefs = do
+runModFinalizerRefs pipe ii rstate qrefs = do
qs <- mapM localRef qrefs
qstateref <- localRef rstate
qstate <- readIORef qstateref
- qstate' <- newIORef $ qstate { qsPipe = pipe }
+ qstate' <- newIORef $ qstate { qsInboxId = ii, qsPipe = pipe }
_ <- runGHCiQ (runQinGHCiQ $ sequence_ qs) qstate'
return ()
-- | The implementation of the 'RunTH' message
runTH
:: Pipe
+ -> InboxId
-> RemoteRef (IORef QState)
-- ^ The TH state, created by 'startTH'
-> HValueRef
@@ -264,13 +266,13 @@ runTH
-> IO ByteString
-- ^ Returns an (encoded) result that depends on the THResultType
-runTH pipe rstate rhv ty mb_loc = do
+runTH pipe ii rstate rhv ty mb_loc = do
hv <- localRef rhv
case ty of
- THExp -> runTHQ pipe rstate mb_loc (unsafeCoerce hv :: TH.Q TH.Exp)
- THPat -> runTHQ pipe rstate mb_loc (unsafeCoerce hv :: TH.Q TH.Pat)
- THType -> runTHQ pipe rstate mb_loc (unsafeCoerce hv :: TH.Q TH.Type)
- THDec -> runTHQ pipe rstate mb_loc (unsafeCoerce hv :: TH.Q [TH.Dec])
+ THExp -> runTHQ pipe ii rstate mb_loc (unsafeCoerce hv :: TH.Q TH.Exp)
+ THPat -> runTHQ pipe ii rstate mb_loc (unsafeCoerce hv :: TH.Q TH.Pat)
+ THType -> runTHQ pipe ii rstate mb_loc (unsafeCoerce hv :: TH.Q TH.Type)
+ THDec -> runTHQ pipe ii rstate mb_loc (unsafeCoerce hv :: TH.Q [TH.Dec])
THAnnWrapper -> do
hv <- unsafeCoerce <$> localRef rhv
case hv :: AnnotationWrapper of
@@ -279,10 +281,10 @@ runTH pipe rstate rhv ty mb_loc = do
-- | Run a Q computation.
runTHQ
- :: Binary a => Pipe -> RemoteRef (IORef QState) -> Maybe TH.Loc -> TH.Q a
+ :: Binary a => Pipe -> InboxId -> RemoteRef (IORef QState) -> Maybe TH.Loc -> TH.Q a
-> IO ByteString
-runTHQ pipe rstate mb_loc ghciq = do
+runTHQ pipe ii rstate mb_loc ghciq = do
qstateref <- localRef rstate
- modifyIORef' qstateref (\qstate -> qstate { qsLocation = mb_loc, qsPipe = pipe })
+ modifyIORef' qstateref (\qstate -> qstate { qsLocation = mb_loc, qsInboxId = ii, qsPipe = pipe })
r <- runGHCiQ (runQinGHCiQ ghciq) qstateref
return $! LB.toStrict (runPut (put r))
=====================================
libraries/ghci/GHCi/Utils.hsc
=====================================
@@ -8,19 +8,22 @@ where
import Prelude
import Foreign.C
import GHC.IO.Handle (Handle())
+import GHC.IO.IOMode
#if defined(mingw32_HOST_OS)
-import Foreign.Ptr (ptrToIntPtr,wordPtrToPtr)
+import Foreign.Ptr (ptrToIntPtr)
import GHC.IO (onException)
import GHC.IO.Handle.FD (fdToHandle)
-import GHC.Windows (HANDLE)
+import GHC.Windows (BOOL, DWORD, HANDLE, failIfFalse_)
import GHC.IO.SubSystem ((<!>))
import GHC.IO.Handle.Windows (mkHandleFromHANDLE)
import GHC.IO.Device as IODevice
import GHC.IO.Encoding (getLocaleEncoding)
-import GHC.IO.IOMode
import GHC.IO.Windows.Handle (fromHANDLE, Io(), NativeHandle())
+import System.Process.CommunicationHandle.Internal
+ ( CommunicationHandle(..), useCommunicationHandle )
#include <fcntl.h> /* for _O_BINARY */
+#include <windows.h>
#else
import System.Posix
@@ -54,18 +57,23 @@ getGhcHandle fd = fdToHandle $ Fd fd
#endif
-- | Read a handle passed on the command-line and prepare it to be used with the IO manager
-readGhcHandle :: String -> IO Handle
-readGhcHandle s = do
+-- also make the handle non-inheritable so we don't have additional references floating
+-- around that stop reads from unblocking on close
+readGhcHandle :: IOMode -> String -> IO Handle
#if defined(mingw32_HOST_OS)
- let fd = wordPtrToPtr (Prelude.read s)
-# if defined(__IO_MANAGER_WINIO__)
- -- register the handles we received with
- -- our I/O manager otherwise we can't use
- -- them correctly.
- return () <!> associateHandle' fd
-# endif
+readGhcHandle mode s = do
+ let ch@(CommunicationHandle h) = Prelude.read s
+ failIfFalse_ "SetHandleInformation" $
+ c_SetHandleInformation h (#const HANDLE_FLAG_INHERIT) 0
+ useCommunicationHandle (mode == ReadMode) ch
+
+foreign import ccall unsafe "windows.h SetHandleInformation"
+ c_SetHandleInformation :: HANDLE -> DWORD -> DWORD -> IO BOOL
#else
+readGhcHandle _ s = do
let fd = Prelude.read s
-#endif
+# if !defined(javascript_HOST_ARCH)
+ setFdOption (Fd fd) CloseOnExec True
+# endif
getGhcHandle fd
-
+#endif
=====================================
libraries/ghci/ghci.cabal.in
=====================================
@@ -68,6 +68,7 @@ library
GHCi.StaticPtrTable
GHCi.TH
GHCi.Server
+ GHCi.Server.Threads
if !arch(javascript)
exposed-modules:
@@ -76,6 +77,7 @@ library
exposed-modules:
GHCi.BreakArray
GHCi.Message
+ GHCi.Message.Async
GHCi.ResolvedBCO
GHCi.RemoteTypes
GHCi.FFI
@@ -95,7 +97,8 @@ library
filepath >= 1.4 && < 1.6,
ghc-boot == @ProjectVersionMunged@,
ghc-heap >= 9.10.1 && <=@ProjectVersionMunged@,
- transformers >= 0.5 && < 0.7
+ transformers >= 0.5 && < 0.7,
+ stm >= 2.4 && < 2.6
if flag(bootstrap)
build-depends:
@@ -106,6 +109,8 @@ library
if !os(windows)
Build-Depends: unix >= 2.7 && < 2.9
+ else
+ Build-Depends: process >= 1.6.20 && < 1.7
if arch(wasm32)
build-depends: ghc-experimental == @ProjectVersionForLib@.0
=====================================
testsuite/tests/ghci/custom-external-interpreter-commands/Main.hs
=====================================
@@ -12,6 +12,7 @@ import GHCi.Message
, mkPipeFromHandles
, remoteCall
, Pipe
+ , closePipe
)
import GHCi.Server
( CustomMessageHandler
@@ -153,14 +154,13 @@ customMessage pipe c = do
runClient :: Int -> IO ()
runClient input = do
serverExe <- getExecutablePath
- withServer serverExe $ \hFromServer hToServer -> do
- pipe <- mkPipeFromHandles hFromServer hToServer
+ withServer serverExe $ \pipe -> do
res <- customMessage pipe (SquareCommand input)
putStrLn $ "Square returned: " ++ show res
res2 <- customMessage pipe (MulCommand 2 res)
putStrLn $ "Mul returned: " ++ show res2
-withServer :: FilePath -> (Handle -> Handle -> IO a) -> IO a
+withServer :: FilePath -> (Pipe -> IO a) -> IO a
withServer serverExe action = do
(ghcRead, serverWrite) <- createPipe
(serverRead, ghcWrite) <- createPipe
@@ -171,13 +171,12 @@ withServer serverExe action = do
, std_out = Inherit
, std_err = Inherit
}
- bracket (mkHandles ghcRead ghcWrite)
- (\(hFromServer, hToServer) -> do
- hClose hFromServer
- hClose hToServer
+ bracket (mkHandles ghcRead ghcWrite >>= uncurry mkPipeFromHandles)
+ (\pipe -> do
+ closePipe pipe
terminateProcess ph
void (waitForProcess ph))
- (\(hFromServer, hToServer) -> action hFromServer hToServer)
+ (\pipe -> action pipe)
where
mkHandles r w = do
hR <- fdToHandle r
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/14f03672c3eeadcdea77560aeae3b2…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/14f03672c3eeadcdea77560aeae3b2…
You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
1
0
[Git][ghc/ghc][wip/27323] Don't report -XStrict-generated bangs under -Wredundant-bang-patterns
by Sasha Bogicevic (@Bogicevic) 20 Oct '26
by Sasha Bogicevic (@Bogicevic) 20 Oct '26
20 Oct '26
Sasha Bogicevic pushed to branch wip/27323 at Glasgow Haskell Compiler / GHC
Commits:
15638403 by Sasha Bogicevic at 2026-10-20T09:14:53+02:00
Don't report -XStrict-generated bangs under -Wredundant-bang-patterns
-Wredundant-bang-patterns could warn about bangs inserted by -XStrict,
including those on unlifted function arguments and local tuple
bindings, even though there is no user-written bang to remove.
Mark bangs inserted by decideBangHood with generatedSrcSpan and track
generated code in DsLclEnv through putSrcSpanDs. The pattern-match
checker emits these bangs without SrcInfo, suppressing redundant-bang
warnings while retaining divergence checks and inaccessible-RHS
warnings.
Update tidy1 and tidy_bang_pat to use the monadic context instead of
threading a Boolean. Push sub-pattern locations when descending, and
consult inGeneratedCodeDs when checking literal overflow.
Preserve located patterns through matchSinglePatVar, pmcPatBind and
desugarPatBind, using desugarLPat so pattern bindings retain their
generated-code information.
Add regression tests T27323 and T27323b and a changelog entry.
- - - - -
10 changed files:
- + changelog.d/T27323
- compiler/GHC/HsToCore/Match.hs
- compiler/GHC/HsToCore/Monad.hs
- compiler/GHC/HsToCore/Pmc.hs
- compiler/GHC/HsToCore/Pmc/Desugar.hs
- compiler/GHC/HsToCore/Types.hs
- compiler/GHC/HsToCore/Utils.hs
- + testsuite/tests/pmcheck/should_compile/T27323.hs
- + testsuite/tests/pmcheck/should_compile/T27323b.hs
- testsuite/tests/pmcheck/should_compile/all.T
Changes:
=====================================
changelog.d/T27323
=====================================
@@ -0,0 +1,7 @@
+section: compiler
+synopsis: Don't report ``-XStrict``-generated bang patterns under ``-Wredundant-bang-patterns``
+description:
+ Bangs introduced by ``-XStrict`` are no longer reported as redundant under
+ ``-Wredundant-bang-patterns``, as they are not user-written.
+issues: #27323
+mrs: !16395
=====================================
compiler/GHC/HsToCore/Match.hs
=====================================
@@ -383,12 +383,14 @@ tidyEqnInfo :: MatchId -> EquationInfo
tidyEqnInfo _ eqn@(EqnDone {}) = return (idDsWrapper, eqn)
-tidyEqnInfo v eqn@(EqnMatch { eqn_pat = (L loc pat) }) = do
- (wrap, pat') <- tidy1 v (not . isGoodSrcSpan . locA $ loc) pat
+tidyEqnInfo v eqn@(EqnMatch { eqn_pat = p@(L loc _) }) = do
+ (wrap, pat') <- tidyLPat v p
return (wrap, eqn{eqn_pat = L loc pat' })
+tidyLPat :: MatchId -> LPat GhcTc -> DsM (DsWrapper, Pat GhcTc)
+tidyLPat v (L loc pat) = putSrcSpanDsA loc (tidy1 v pat)
+
tidy1 :: MatchId -- The scrutinee
- -> Bool -- `True` if the pattern was generated, `False` if it was user-written
-> Pat GhcTc -- The pattern against which it is to be matched
-> DsM (DsWrapper, -- Extra bindings to do before the match
Pat GhcTc) -- Equivalent pattern
@@ -399,21 +401,22 @@ tidy1 :: MatchId -- The scrutinee
-- It eliminates many pattern forms (as-patterns, variable patterns,
-- list patterns, etc) and returns any created bindings in the wrapper.
-tidy1 v g (ParPat _ pat) = tidy1 v g (unLoc pat)
-tidy1 v g (SigPat _ pat _) = tidy1 v g (unLoc pat)
-tidy1 _ _ (WildPat ty) = return (idDsWrapper, WildPat ty)
-tidy1 v g (BangPat _ (L l p)) = tidy_bang_pat v g l p
-tidy1 v g (ModifiedPat _ _ pat) = tidy1 v g (unLoc pat)
+tidy1 v (ParPat _ pat) = tidyLPat v pat
+tidy1 v (SigPat _ pat _) = tidyLPat v pat
+tidy1 _ (WildPat ty) = return (idDsWrapper, WildPat ty)
+tidy1 v (BangPat _ (L l p)) = putSrcSpanDsA l $ tidy_bang_pat v l p
+tidy1 v (ModifiedPat _ _ pat) = tidyLPat v pat
-- case v of { x -> mr[] }
-- = case v of { _ -> let x=v in mr[] }
-tidy1 v _ (VarPat _ (L _ var))
+tidy1 v (VarPat _ (L _ var))
= return (bindMatchId var v, WildPat (idType var))
-- case v of { x@p -> mr[] }
-- = case v of { p -> let x=v in mr[] }
-tidy1 v g (AsPat _ (L _ var) pat)
- = do { (wrap, pat') <- tidy1 v g (unLoc pat)
+tidy1 v (AsPat _ (L _ var) pat)
+
+ = do { (wrap, pat') <- tidyLPat v pat
; return (bindMatchId var v . wrap, pat') }
{- now, here we handle lazy patterns:
@@ -427,7 +430,7 @@ tidy1 v g (AsPat _ (L _ var) pat)
The case expr for v_i is just: match [v] [(p, [], \ x -> Var v_i)] any_expr
-}
-tidy1 v _ (LazyPat _ pat)
+tidy1 v (LazyPat _ pat)
-- This is a convenient place to check for unlifted types under a lazy pattern.
-- Doing this check during type-checking is unsatisfactory because we may
-- not fully know the zonked types yet. We sure do here.
@@ -441,14 +444,14 @@ tidy1 v _ (LazyPat _ pat)
; let sel_binds = [NonRec b rhs | (b,rhs) <- sel_prs]
; return (mkCoreLets sel_binds, WildPat (matchIdType v)) }
-tidy1 _ _ (ListPat ty pats)
+tidy1 _ (ListPat ty pats)
= return (idDsWrapper, unLoc list_ConPat)
where
list_ConPat = foldr (\ x y -> mkPrefixConPat consDataCon [x, y] [ty])
(mkNilPat ty)
pats
-tidy1 _ _ (TuplePat tys pats boxity)
+tidy1 _ (TuplePat tys pats boxity)
= return (idDsWrapper, unLoc tuple_ConPat)
where
arity = length pats
@@ -458,34 +461,37 @@ tidy1 _ _ (TuplePat tys pats boxity)
Boxed -> tys
-- See Note [Unboxed tuple RuntimeRep vars] in TyCon
-tidy1 _ _ (SumPat tys pat alt arity)
+tidy1 _ (SumPat tys pat alt arity)
= return (idDsWrapper, unLoc sum_ConPat)
where
sum_ConPat = mkPrefixConPat (sumDataCon alt arity) [pat] (map getRuntimeRep tys ++ tys)
-- See Note [Unboxed tuple RuntimeRep vars] in TyCon
-- LitPats: we *might* be able to replace these w/ a simpler form
-tidy1 _ g (LitPat _ lit)
- = do { unless g $
+tidy1 _ (LitPat _ lit)
+ = do { in_gen <- inGeneratedCodeDs;
+ unless in_gen $
warnAboutOverflowedLit lit
; return (idDsWrapper, tidyLitPat lit) }
-- NPats: we *might* be able to replace these w/ a simpler form
-tidy1 _ g (NPat ty (L _ lit@OverLit { ol_val = v }) mb_neg eq)
- = do { unless g $
+tidy1 _ (NPat ty (L _ lit@OverLit { ol_val = v }) mb_neg eq)
+ = do { in_gen <- inGeneratedCodeDs;
+ unless in_gen $
let lit' | Just _ <- mb_neg = lit{ ol_val = negateOverLitVal v }
| otherwise = lit
in warnAboutOverflowedOverLit lit'
; return (idDsWrapper, tidyNPat lit mb_neg eq ty) }
-- NPlusKPat: we may want to warn about the literals
-tidy1 _ g n@(NPlusKPat _ _ (L _ lit1) lit2 _ _)
- = do { unless g $ do
+tidy1 _ n@(NPlusKPat _ _ (L _ lit1) lit2 _ _)
+ = do { in_gen <- inGeneratedCodeDs;
+ unless in_gen $ do
warnAboutOverflowedOverLit lit1
warnAboutOverflowedOverLit lit2
; return (idDsWrapper, n) }
-tidy1 _ _ (OrPat ty lpats)
+tidy1 _ (OrPat ty lpats)
-- See Note [Implementation of OrPatterns]. We desugar
-- (1; 2; 3)
-- to
@@ -514,44 +520,44 @@ tidy1 _ _ (OrPat ty lpats)
single_grhs e = GRHSs emptyComments [noLocA $ GRHS noAnn [] e] (EmptyLocalBinds noExtField)
-- Everything else goes through unchanged...
-tidy1 _ _ non_interesting_pat
+tidy1 _ non_interesting_pat
= return (idDsWrapper, non_interesting_pat)
--------------------
-tidy_bang_pat :: MatchId -> Bool -> SrcSpanAnnA -> Pat GhcTc
+tidy_bang_pat :: MatchId -> SrcSpanAnnA -> Pat GhcTc
-> DsM (DsWrapper, Pat GhcTc)
-- Discard par/sig under a bang
-tidy_bang_pat v g _ (ParPat _ (L l p)) = tidy_bang_pat v g l p
-tidy_bang_pat v g _ (SigPat _ (L l p) _) = tidy_bang_pat v g l p
+tidy_bang_pat v _ (ParPat _ (L l p)) = putSrcSpanDsA l $ tidy_bang_pat v l p
+tidy_bang_pat v _ (SigPat _ (L l p) _) = putSrcSpanDsA l $ tidy_bang_pat v l p
-- Push the bang-pattern inwards, in the hope that
-- it may disappear next time
-tidy_bang_pat v g l (AsPat x v' p)
- = tidy1 v g (AsPat x v' (L l (BangPat noExtField p)))
-tidy_bang_pat v g l (XPat (CoPat w p t))
- = tidy1 v g (XPat $ CoPat w (BangPat noExtField (L l p)) t)
-tidy_bang_pat v g l (OrPat x (p:|ps)) -- push bang into first pat alt
- = tidy1 v g (OrPat x (L l (BangPat noExtField p) :| ps))
+tidy_bang_pat v l (AsPat x v' p)
+ = tidy1 v (AsPat x v' (L l (BangPat noExtField p)))
+tidy_bang_pat v l (XPat (CoPat w p t))
+ = tidy1 v (XPat $ CoPat w (BangPat noExtField (L l p)) t)
+tidy_bang_pat v l (OrPat x (p:|ps)) -- push bang into first pat alt
+ = tidy1 v (OrPat x (L l (BangPat noExtField p) :| ps))
-- Discard bang around strict pattern
-tidy_bang_pat v g _ p@(LitPat {}) = tidy1 v g p
-tidy_bang_pat v g _ p@(ListPat {}) = tidy1 v g p
-tidy_bang_pat v g _ p@(TuplePat {}) = tidy1 v g p
-tidy_bang_pat v g _ p@(SumPat {}) = tidy1 v g p
+tidy_bang_pat v _ p@(LitPat {}) = tidy1 v p
+tidy_bang_pat v _ p@(ListPat {}) = tidy1 v p
+tidy_bang_pat v _ p@(TuplePat {}) = tidy1 v p
+tidy_bang_pat v _ p@(SumPat {}) = tidy1 v p
-- Data/newtype constructors
-tidy_bang_pat v g l p@(ConPat { pat_con = L _ (RealDataCon dc)
- , pat_args = args
- , pat_con_ext = ConPatTc
- { cpt_arg_tys = arg_tys
- }
- })
+tidy_bang_pat v l p@(ConPat { pat_con = L _ (RealDataCon dc)
+ , pat_args = args
+ , pat_con_ext = ConPatTc
+ { cpt_arg_tys = arg_tys
+ }
+ })
-- Newtypes: push bang inwards (#9844)
=
if isNewTyCon (dataConTyCon dc)
- then tidy1 v g (p { pat_args = push_bang_into_newtype_arg l (scaledThing ty) args })
- else tidy1 v g p -- Data types: discard the bang
+ then tidy1 v (p { pat_args = push_bang_into_newtype_arg l (scaledThing ty) args })
+ else tidy1 v p -- Data types: discard the bang
where
(ty:_) = dataConInstArgTys dc arg_tys
@@ -570,7 +576,7 @@ tidy_bang_pat v g l p@(ConPat { pat_con = L _ (RealDataCon dc)
--
-- NB: SigPatIn, ConPatIn should not happen
-tidy_bang_pat _ _ l p = return (idDsWrapper, BangPat noExtField (L l p))
+tidy_bang_pat _ l p = return (idDsWrapper, BangPat noExtField (L l p))
-------------------
push_bang_into_newtype_arg :: SrcSpanAnnA
@@ -954,7 +960,7 @@ matchSinglePatVar var mb_scrut ctx pat ty match_result
; ldi_nablas <-
if isMatchContextPmChecked_SinglePat dflags FromSource ctx pat
then addCoreScrutTmCs (maybeToList mb_scrut) [var] $
- pmcPatBind (DsMatchContext ctx locn) var (unLoc pat)
+ pmcPatBind (DsMatchContext ctx locn) var pat
else getLdiNablas
; let eqn_info = EqnMatch { eqn_pat = decideBangHood dflags pat
=====================================
compiler/GHC/HsToCore/Monad.hs
=====================================
@@ -15,7 +15,7 @@ module GHC.HsToCore.Monad (
duplicateLocalDs, newSysLocalDs, newSysLocalsDs,
newSysLocalMDs, newSysLocalsMDs, newFailLocalMDs,
newUniqueId, newPredVarDs, newStaticId,
- getSrcSpanDs, putSrcSpanDs, putSrcSpanDsA,
+ getSrcSpanDs, inGeneratedCodeDs, putSrcSpanDs, putSrcSpanDsA,
mkNamePprCtxDs,
newUnique,
UniqSupply, newUniqueSupply,
@@ -584,6 +584,7 @@ mkDsEnvs unit_env mod rdr_env type_env fam_inst_env tcm_plugins ptc msg_var
, dsl_loc = real_span
, dsl_nablas = Ldi initNablas
, dsl_unspecables = Just emptyVarSet
+ , dsl_in_generated_code = False
}
in (gbl_env, lcl_env)
@@ -676,13 +677,17 @@ getSrcSpanDs :: DsM SrcSpan
getSrcSpanDs = do { env <- getLclEnv
; return (RealSrcSpan (dsl_loc env) Strict.Nothing) }
+-- | See 'dsl_in_generated_code'
+inGeneratedCodeDs :: DsM Bool
+inGeneratedCodeDs = dsl_in_generated_code <$> getLclEnv
+
putSrcSpanDs :: SrcSpan -> DsM a -> DsM a
putSrcSpanDs (RealSrcSpan real_span _) thing_inside
- = updLclEnv (\ env -> env {dsl_loc = real_span}) thing_inside
+ = updLclEnv (\ env -> env {dsl_loc = real_span, dsl_in_generated_code = False}) thing_inside
putSrcSpanDs UnhelpfulSpan{} thing_inside
= thing_inside
putSrcSpanDs GeneratedSrcSpan{} thing_inside
- = thing_inside
+ = updLclEnv (\ env -> env {dsl_in_generated_code = True}) thing_inside
putSrcSpanDsA :: EpAnn ann -> DsM a -> DsM a
putSrcSpanDsA loc = putSrcSpanDs (locA loc)
=====================================
compiler/GHC/HsToCore/Pmc.hs
=====================================
@@ -104,7 +104,7 @@ whenDoingPmc no_pmc thing_inside
Ldi nablas -> thing_inside nablas }
-- | Check a pattern binding (let, where) for exhaustiveness.
-pmcPatBind :: DsMatchContext -> Id -> Pat GhcTc -> DsM LdiNablas
+pmcPatBind :: DsMatchContext -> Id -> LPat GhcTc -> DsM LdiNablas
pmcPatBind ctxt@(DsMatchContext match_ctxt loc) var p
= whenDoingPmc NoPmc $ \ !missing ->
mb_discard_warnings $ do
=====================================
compiler/GHC/HsToCore/Pmc/Desugar.hs
=====================================
@@ -155,11 +155,15 @@ desugarPat x pat = case pat of
VarPat _ y -> pure (mkPmLetVar (unLoc y) x)
ParPat _ p -> desugarLPat x p
LazyPat _ _ -> pure GdEnd -- like a wildcard
- BangPat _ p@(L l p') ->
+ BangPat _ p@(L l p') -> do
-- Add the bang in front of the list, because it will happen before any
-- nested stuff.
+ in_gen <- inGeneratedCodeDs
+ -- A bang inserted by -XStrict (decideBangHood) has no SrcInfo: it is
+ -- divergence-checked but never reported as redundant (#27323).
+ let pm_loc | in_gen = Nothing
+ | otherwise = Just (SrcInfo (L (locA l) (ppr p')))
consGrdDag (PmBang x pm_loc) <$> desugarLPat x p
- where pm_loc = Just (SrcInfo (L (locA l) (ppr p')))
-- (x@pat) ==> Desugar pat with x as match var and handle impedance
-- mismatch with incoming match var
@@ -311,11 +315,11 @@ desugarPatV pat = do
pure (x, grds)
desugarLPat :: Id -> LPat GhcTc -> DsM GrdDag
-desugarLPat x = desugarPat x . unLoc
+desugarLPat x (L loc pat) = putSrcSpanDsA loc (desugarPat x pat)
-- | 'desugarLPat', but also select and return a new match var.
desugarLPatV :: LPat GhcTc -> DsM (Id, GrdDag)
-desugarLPatV = desugarPatV . unLoc
+desugarLPatV (L loc pat) = putSrcSpanDsA loc (desugarPatV pat)
-- | @desugarListPat _ x [p1, ..., pn]@ is basically
-- @desugarConPatOut _ x $(mkListConPatOuts [p1, ..., pn]>@ without ever
@@ -374,11 +378,11 @@ desugarConPatOut x con univ_tys ex_tvs dicts = \case
-- tracePm "ConPatOut" (ppr x $$ ppr con $$ ppr arg_ids)
pure (con_grd `consGrdDag` arg_grds)
-desugarPatBind :: SrcSpan -> Id -> Pat GhcTc -> DsM (PmPatBind Pre)
+desugarPatBind :: SrcSpan -> Id -> LPat GhcTc -> DsM (PmPatBind Pre)
-- See 'GrdPatBind' for how this simply repurposes GrdGRHS.
-- See Note [Suppress warnings in PMC desugaring]
desugarPatBind loc var pat = discardWarningsDs $
- PmPatBind . flip PmGRHS (SrcInfo (L loc (ppr pat))) <$> desugarPat var pat
+ PmPatBind . flip PmGRHS (SrcInfo (L loc (ppr pat))) <$> desugarLPat var pat
desugarEmptyCase :: Id -> DsM PmEmptyCase
desugarEmptyCase var = pure PmEmptyCase { pe_var = var }
@@ -650,4 +654,19 @@ user *had* written a bang:
+ In an equation for ‘idV’: idV !v = ...
So we live with the duplication.
+
+Note that 'decideBangHood' places the bangs it inserts at a 'generatedSrcSpan'.
+When 'desugarLPat' enters such a span, 'putSrcSpanDs' (GHC.HsToCore.Monad)
+records in 'dsl_in_generated_code' that we are desugaring compiler-generated
+code. For a bang in generated code, 'desugarPat' emits a 'PmBang' with no
+'SrcInfo': the checker still performs the divergence check (so the
+inaccessible-RHS warning above survives), but -Wredundant-bang-patterns only
+ever reports bangs the user actually wrote (#27323). See
+Note [Dead bang patterns] in GHC.HsToCore.Pmc.Check.
+
+Eventually the bangs inserted by -XStrict should become expanded patterns,
+following Note [Handling overloaded and rebindable constructs] in
+GHC.Rename.Expr. That would let warnings always display the original
+user-written code, making the decideBangHood duplication described above
+unnecessary. This is tracked as #27677.
-}
=====================================
compiler/GHC/HsToCore/Types.hs
=====================================
@@ -11,7 +11,7 @@ module GHC.HsToCore.Types (
DsMetaEnv, DsMetaVal(..), CompleteMatches
) where
-import GHC.Prelude (Int)
+import GHC.Prelude (Bool, Int)
import Data.IORef
@@ -125,6 +125,7 @@ data DsLclEnv
-- ^ See Note [Desugaring non-canonical evidence]
-- This field collects all un-specialisable evidence variables in scope.
-- Nothing <=> don't collect this info (used for the LHS of Rules)
+ , dsl_in_generated_code :: Bool -- Desugaring compiler-generated or user-written code
}
-- Inside [| |] brackets, the desugarer looks
=====================================
compiler/GHC/HsToCore/Utils.hs
=====================================
@@ -72,6 +72,7 @@ import GHC.Unit.Module
import GHC.Builtin.KnownKeys
import GHC.Utils.Outputable
import GHC.Utils.Panic
+import GHC.Rename.Utils (wrapGenSpan')
import GHC.Types.SrcLoc
import GHC.Types.Tickish
import GHC.Utils.Misc
@@ -1025,6 +1026,9 @@ Specifically:
-- | Use -XStrict to add a ! or remove a ~
+-- The bang we insert is compiler-generated, so we put it at a generatedSrcSpan.
+-- The pattern-match checker uses this (via dsl_in_generated_code) to avoid reporting
+-- such bangs under -Wredundant-bang-patterns (#27323).
-- See Note [decideBangHood]
decideBangHood :: DynFlags
-> LPat GhcTc -- ^ Original pattern
@@ -1040,7 +1044,7 @@ decideBangHood dflags lpat
ParPat x p -> L l (ParPat x (go p))
LazyPat _ lp' -> lp'
BangPat _ _ -> lp
- _ -> L l (BangPat noExtField lp)
+ _ -> wrapGenSpan' (locA l) (BangPat noExtField lp)
isTrueLHsExpr :: LHsExpr GhcTc -> Maybe (CoreExpr -> DsM CoreExpr)
=====================================
testsuite/tests/pmcheck/should_compile/T27323.hs
=====================================
@@ -0,0 +1,9 @@
+{-# LANGUAGE MagicHash, Strict #-}
+{-# OPTIONS_GHC -Wredundant-bang-patterns #-}
+
+import GHC.Prim (Int#)
+
+idInt# :: Int# -> Int#
+idInt# x = x
+
+main = pure ()
=====================================
testsuite/tests/pmcheck/should_compile/T27323b.hs
=====================================
@@ -0,0 +1,6 @@
+{-# LANGUAGE Strict, MonoLocalBinds #-}
+{-# OPTIONS_GHC -Wredundant-bang-patterns #-}
+module T27323b where
+
+f :: Int -> Int
+f x = let (a, b) = (x, x) in a + b
=====================================
testsuite/tests/pmcheck/should_compile/all.T
=====================================
@@ -190,4 +190,6 @@ test('T24845', [], compile, [overlapping_incomplete])
test('T22652', [], compile, [overlapping_incomplete])
test('T22652a', [], compile, [overlapping_incomplete])
test('T24867', [], compile_fail, [overlapping_incomplete])
+test('T27323', normal, compile, ['-Wredundant-bang-patterns'])
+test('T27323b', normal, compile, ['-Wredundant-bang-patterns'])
test('T27360', normal, compile, [overlapping_incomplete + '-g3'])
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/15638403e3e13a44edbee68984ecb1d…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/15638403e3e13a44edbee68984ecb1d…
You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
1
0
20 Oct '26
Florian Ragwitz pushed to branch wip/rafl/hpc-tixdir at Glasgow Haskell Compiler / GHC
Commits:
200f09cd by Florian Ragwitz at 2026-10-19T22:12:06-07:00
A little more, maybe?
- - - - -
2 changed files:
- .gitlab/generate-ci/gen_ci.hs
- .gitlab/jobs.yaml
Changes:
=====================================
.gitlab/generate-ci/gen_ci.hs
=====================================
@@ -1003,7 +1003,7 @@ validate arch opsys bc =
covered = ignorePerfFailures
$ setVariable "RUNTEST_ARGS"
(unwords $ fromMaybe [] (mmlookup "RUNTEST_ARGS" (jobVariables j))
- ++ ["-e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout"])
+ ++ ["-e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout"])
$ setVariable "BUILD_FLAVOUR"
(flavourString (mkJobFlavour bc) ++ "+coverage") j
saveCoverage = (if opsys == Windows then "bash " else "")
=====================================
.gitlab/jobs.yaml
=====================================
@@ -65,7 +65,7 @@
"LANG": "en_US.UTF-8",
"MACOSX_DEPLOYMENT_TARGET": "11.0",
"NIX_SYSTEM": "aarch64-darwin",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "aarch64-darwin-validate",
"TEST_WAYS": ""
}
@@ -132,7 +132,7 @@
"CONFIGURE_ARGS": "--disable-ld-override --enable-ignore-build-platform-mismatch --build=aarch64-unknown-linux --host=aarch64-unknown-linux --target=aarch64-unknown-linux --enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "aarch64-linux-alpine3_23-validate",
"TEST_WAYS": ""
}
@@ -198,7 +198,7 @@
"CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "aarch64-linux-deb11-validate",
"TEST_WAYS": ""
}
@@ -264,7 +264,7 @@
"CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "aarch64-linux-deb12-validate",
"TEST_WAYS": ""
}
@@ -346,7 +346,7 @@
"OBJCOPY": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-objcopy",
"OBJDUMP": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-objdump",
"RANLIB": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-llvm-ranlib",
- "RUNTEST_ARGS": "-e config.timeout=900 -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
+ "RUNTEST_ARGS": "-e config.timeout=900 -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout",
"SIZE": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-size",
"STRINGS": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-strings",
"STRIP": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-strip",
@@ -433,7 +433,7 @@
"OBJCOPY": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-objcopy",
"OBJDUMP": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-objdump",
"RANLIB": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-llvm-ranlib",
- "RUNTEST_ARGS": "-e config.timeout=900 -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
+ "RUNTEST_ARGS": "-e config.timeout=900 -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout",
"SIZE": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-size",
"STRINGS": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-strings",
"STRIP": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-strip",
@@ -504,7 +504,7 @@
"CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "aarch64-linux-deb13-validate",
"TEST_WAYS": ""
}
@@ -570,7 +570,7 @@
"CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "aarch64-linux-deb13-validate+llvm",
"TEST_WAYS": "llvm optllvm"
}
@@ -637,7 +637,7 @@
"CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "i386-linux-alpine3_23-validate",
"TEST_WAYS": ""
}
@@ -703,7 +703,7 @@
"CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "i386-linux-deb11-validate",
"TEST_WAYS": ""
}
@@ -769,7 +769,7 @@
"CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "i386-linux-deb12-validate",
"TEST_WAYS": ""
}
@@ -835,7 +835,7 @@
"CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "i386-linux-deb13-validate",
"TEST_WAYS": ""
}
@@ -5711,7 +5711,7 @@
"LANG": "en_US.UTF-8",
"MACOSX_DEPLOYMENT_TARGET": "11.0",
"NIX_SYSTEM": "x86_64-darwin",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-darwin-validate",
"TEST_WAYS": "",
"ac_cv_func_clock_gettime": "no",
@@ -5783,7 +5783,7 @@
"FETCH_GHC_VERSION": "9.10.3",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-freebsd14-validate",
"TEST_WAYS": ""
}
@@ -5850,7 +5850,7 @@
"CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-alpine3_12-int_native-validate+fully_static",
"TEST_WAYS": ""
}
@@ -5917,7 +5917,7 @@
"CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-alpine3_12-validate+fully_static",
"TEST_WAYS": ""
}
@@ -5984,7 +5984,7 @@
"CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-alpine3_23-validate",
"TEST_WAYS": ""
}
@@ -6053,7 +6053,7 @@
"FIREFOX_LAUNCH_OPTS": "{\"browser\":\"firefox\",\"executablePath\":\"/usr/bin/firefox\"}",
"HADRIAN_ARGS": "--docs=no-sphinx-pdfs --docs=no-sphinx-man",
"IGNORE_PERF_FAILURES": "all",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-alpine3_23-wasm-cross_wasm32-wasi-release+host_fully_static+text_simdutf",
"TEST_WAYS": ""
}
@@ -6123,7 +6123,7 @@
"FIREFOX_LAUNCH_OPTS": "{\"browser\":\"firefox\",\"executablePath\":\"/usr/bin/firefox\"}",
"HADRIAN_ARGS": "--docs=no-sphinx-pdfs --docs=no-sphinx-man",
"IGNORE_PERF_FAILURES": "all",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-alpine3_23-wasm-int_native-cross_wasm32-wasi-release+host_fully_static+text_simdutf",
"TEST_WAYS": ""
}
@@ -6193,7 +6193,7 @@
"FIREFOX_LAUNCH_OPTS": "{\"browser\":\"firefox\",\"executablePath\":\"/usr/bin/firefox\"}",
"HADRIAN_ARGS": "--docs=no-sphinx-pdfs --docs=no-sphinx-man",
"IGNORE_PERF_FAILURES": "all",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-alpine3_23-wasm-unreg-cross_wasm32-wasi-release+host_fully_static+text_simdutf",
"TEST_WAYS": ""
}
@@ -6262,7 +6262,7 @@
"CROSS_TARGET": "javascript-unknown-ghcjs",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": "-e config.timeout=900 -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
+ "RUNTEST_ARGS": "-e config.timeout=900 -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-deb11-emsdk-closure-int_native-cross_javascript-unknown-ghcjs-validate",
"TEST_WAYS": ""
}
@@ -6328,7 +6328,7 @@
"CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-deb11-validate",
"TEST_WAYS": ""
}
@@ -6394,7 +6394,7 @@
"CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-deb11-validate+debug_info",
"TEST_WAYS": ""
}
@@ -6460,7 +6460,7 @@
"CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-deb12-validate",
"TEST_WAYS": ""
}
@@ -6529,7 +6529,7 @@
"CROSS_TARGET": "aarch64-linux-gnu",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": "-e config.timeout=900 -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
+ "RUNTEST_ARGS": "-e config.timeout=900 -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-deb13-cross_aarch64-linux-gnu-validate",
"TEST_WAYS": ""
}
@@ -6595,7 +6595,7 @@
"CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-deb13-int_native-validate",
"TEST_WAYS": ""
}
@@ -6662,7 +6662,7 @@
"CONFIGURE_ARGS": "--disable-tables-next-to-code --enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-deb13-no_tntc-validate",
"TEST_WAYS": ""
}
@@ -6729,7 +6729,7 @@
"ENABLE_NUMA": "1",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-deb13-numa-slow-validate",
"TEST_WAYS": ""
}
@@ -6795,7 +6795,7 @@
"CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " --config perf_path=perf -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
+ "RUNTEST_ARGS": " --config perf_path=perf -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-deb13-release",
"TEST_WAYS": ""
}
@@ -6864,7 +6864,7 @@
"CROSS_TARGET": "riscv64-linux-gnu",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": "-e config.timeout=900 -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
+ "RUNTEST_ARGS": "-e config.timeout=900 -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-deb13-riscv-cross_riscv64-linux-gnu-validate",
"TEST_WAYS": ""
}
@@ -6930,7 +6930,7 @@
"CONFIGURE_ARGS": "--enable-unregisterised --enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-deb13-unreg-validate",
"TEST_WAYS": ""
}
@@ -6996,7 +6996,7 @@
"CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-deb13-validate",
"TEST_WAYS": ""
}
@@ -7062,7 +7062,7 @@
"CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": "--way=nonmoving --way=nonmoving_thr --way=nonmoving_thr_sanity -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
+ "RUNTEST_ARGS": "--way=nonmoving --way=nonmoving_thr --way=nonmoving_thr_sanity -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-deb13-validate+boot_nonmoving_gc",
"TEST_WAYS": ""
}
@@ -7128,7 +7128,7 @@
"CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-deb13-validate+llvm",
"TEST_WAYS": "llvm optllvm"
}
@@ -7196,7 +7196,7 @@
"HADRIAN_ARGS": "--docs=none",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-deb13-validate+thread_sanitizer_cmm",
"TEST_WAYS": "",
"TSAN_OPTIONS": "suppressions=$CI_PROJECT_DIR/rts/.tsan-suppressions"
@@ -7263,7 +7263,7 @@
"CONFIGURE_ARGS": "--enable-ipe-data-compression --enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-deb13-zstd-validate",
"TEST_WAYS": ""
}
@@ -7329,7 +7329,7 @@
"CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-fedora43-release",
"TEST_WAYS": ""
}
@@ -7396,7 +7396,7 @@
"HADRIAN_ARGS": "--haddock-for-hackage",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-fedora43-release",
"TEST_WAYS": ""
}
@@ -7462,7 +7462,7 @@
"CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-fedora43-validate",
"TEST_WAYS": ""
}
@@ -7528,7 +7528,7 @@
"CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-fedora43-validate+debug_info",
"TEST_WAYS": ""
}
@@ -7595,7 +7595,7 @@
"HADRIAN_ARGS": "--docs=none",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-fedora43-validate+debug_info+ubsan",
"TEST_WAYS": "",
"UBSAN_OPTIONS": "suppressions=$CI_PROJECT_DIR/rts/.ubsan-suppressions"
@@ -7662,7 +7662,7 @@
"CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-rocky8-validate",
"TEST_WAYS": ""
}
@@ -7728,7 +7728,7 @@
"CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-ubuntu22_04-validate",
"TEST_WAYS": ""
}
@@ -7797,7 +7797,7 @@
"CROSS_TARGET": "loongarch64-linux-gnu",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": "-e config.timeout=900 -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
+ "RUNTEST_ARGS": "-e config.timeout=900 -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-ubuntu24_04-loongarch-cross_loongarch64-linux-gnu-validate",
"TEST_WAYS": ""
}
@@ -7863,7 +7863,7 @@
"CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-ubuntu24_04-validate",
"TEST_WAYS": ""
}
@@ -7929,7 +7929,7 @@
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
"LANG": "en_US.UTF-8",
"MSYSTEM": "CLANG64",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-windows-int_native-validate",
"TEST_WAYS": ""
}
@@ -7995,7 +7995,7 @@
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
"LANG": "en_US.UTF-8",
"MSYSTEM": "CLANG64",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-windows-validate",
"TEST_WAYS": ""
}
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/200f09cd13667a76addb40a9f8ddde2…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/200f09cd13667a76addb40a9f8ddde2…
You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
1
0
19 Oct '26
Florian Ragwitz pushed to branch wip/rafl/hpc-tixdir at Glasgow Haskell Compiler / GHC
Commits:
f1c7c3e0 by Florian Ragwitz at 2026-10-19T15:30:58-07:00
mkdir on windows, maybe
- - - - -
1 changed file:
- tix-rle-merge.c
Changes:
=====================================
tix-rle-merge.c
=====================================
@@ -460,8 +460,13 @@ static void output_name(char *buf, size_t cap, size_t group) {
if (snprintf(buf, cap, "merged-%04zu.tix", group + 1) >= (int)cap)
die("too many output groups");
}
+#ifndef _WIN32
+# define MKDIR(p) mkdir((p), 0777)
+#else
+# define MKDIR(p) mkdir((p))
+#endif
static void ensure_empty_output_dir(const char *in, const char *out) {
- if (mkdir(out, 0777) && errno != EEXIST) { perror(out); exit(1); }
+ if (MKDIR(out) && errno != EEXIST) { perror(out); exit(1); }
struct stat a, b;
if (stat(in, &a) || stat(out, &b) || !S_ISDIR(b.st_mode))
die("invalid input/output directory");
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f1c7c3e098bdd7857dcf2144c0317f5…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f1c7c3e098bdd7857dcf2144c0317f5…
You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
1
0
19 Oct '26
Florian Ragwitz pushed to branch wip/rafl/hpc-tixdir at Glasgow Haskell Compiler / GHC
Commits:
673b0008 by Florian Ragwitz at 2026-10-19T14:07:05-07:00
mkdir on windows, maybe
- - - - -
1 changed file:
- tix-rle-merge.c
Changes:
=====================================
tix-rle-merge.c
=====================================
@@ -460,8 +460,13 @@ static void output_name(char *buf, size_t cap, size_t group) {
if (snprintf(buf, cap, "merged-%04zu.tix", group + 1) >= (int)cap)
die("too many output groups");
}
+#ifndef _WIN32
+# define MKDIR(p) mkdir((p), 0777)
+#else
+# define MKDIR(p) mkdir((p))
+#endif
static void ensure_empty_output_dir(const char *in, const char *out) {
- if (mkdir(out, 0777) && errno != EEXIST) { perror(out); exit(1); }
+ if (MKDIR(out, 0777) && errno != EEXIST) { perror(out); exit(1); }
struct stat a, b;
if (stat(in, &a) || stat(out, &b) || !S_ISDIR(b.st_mode))
die("invalid input/output directory");
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/673b0008945c76ad98a482ee4ec1841…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/673b0008945c76ad98a482ee4ec1841…
You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
1
0
19 Oct '26
Florian Ragwitz pushed to branch wip/rafl/hpc-tixdir at Glasgow Haskell Compiler / GHC
Commits:
72a3fbcb by Florian Ragwitz at 2026-10-19T13:49:35-07:00
Bump timeout further
- - - - -
2 changed files:
- .gitlab/generate-ci/gen_ci.hs
- .gitlab/jobs.yaml
Changes:
=====================================
.gitlab/generate-ci/gen_ci.hs
=====================================
@@ -1003,7 +1003,7 @@ validate arch opsys bc =
covered = ignorePerfFailures
$ setVariable "RUNTEST_ARGS"
(unwords $ fromMaybe [] (mmlookup "RUNTEST_ARGS" (jobVariables j))
- ++ ["-e config.timeout+=config.timeout+config.timeout"])
+ ++ ["-e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout"])
$ setVariable "BUILD_FLAVOUR"
(flavourString (mkJobFlavour bc) ++ "+coverage") j
saveCoverage = (if opsys == Windows then "bash " else "")
=====================================
.gitlab/jobs.yaml
=====================================
@@ -65,7 +65,7 @@
"LANG": "en_US.UTF-8",
"MACOSX_DEPLOYMENT_TARGET": "11.0",
"NIX_SYSTEM": "aarch64-darwin",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "aarch64-darwin-validate",
"TEST_WAYS": ""
}
@@ -132,7 +132,7 @@
"CONFIGURE_ARGS": "--disable-ld-override --enable-ignore-build-platform-mismatch --build=aarch64-unknown-linux --host=aarch64-unknown-linux --target=aarch64-unknown-linux --enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "aarch64-linux-alpine3_23-validate",
"TEST_WAYS": ""
}
@@ -198,7 +198,7 @@
"CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "aarch64-linux-deb11-validate",
"TEST_WAYS": ""
}
@@ -264,7 +264,7 @@
"CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "aarch64-linux-deb12-validate",
"TEST_WAYS": ""
}
@@ -346,7 +346,7 @@
"OBJCOPY": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-objcopy",
"OBJDUMP": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-objdump",
"RANLIB": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-llvm-ranlib",
- "RUNTEST_ARGS": "-e config.timeout=900 -e config.timeout+=config.timeout+config.timeout",
+ "RUNTEST_ARGS": "-e config.timeout=900 -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
"SIZE": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-size",
"STRINGS": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-strings",
"STRIP": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-strip",
@@ -433,7 +433,7 @@
"OBJCOPY": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-objcopy",
"OBJDUMP": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-objdump",
"RANLIB": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-llvm-ranlib",
- "RUNTEST_ARGS": "-e config.timeout=900 -e config.timeout+=config.timeout+config.timeout",
+ "RUNTEST_ARGS": "-e config.timeout=900 -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
"SIZE": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-size",
"STRINGS": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-strings",
"STRIP": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-strip",
@@ -504,7 +504,7 @@
"CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "aarch64-linux-deb13-validate",
"TEST_WAYS": ""
}
@@ -570,7 +570,7 @@
"CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "aarch64-linux-deb13-validate+llvm",
"TEST_WAYS": "llvm optllvm"
}
@@ -637,7 +637,7 @@
"CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "i386-linux-alpine3_23-validate",
"TEST_WAYS": ""
}
@@ -703,7 +703,7 @@
"CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "i386-linux-deb11-validate",
"TEST_WAYS": ""
}
@@ -769,7 +769,7 @@
"CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "i386-linux-deb12-validate",
"TEST_WAYS": ""
}
@@ -835,7 +835,7 @@
"CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "i386-linux-deb13-validate",
"TEST_WAYS": ""
}
@@ -5711,7 +5711,7 @@
"LANG": "en_US.UTF-8",
"MACOSX_DEPLOYMENT_TARGET": "11.0",
"NIX_SYSTEM": "x86_64-darwin",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-darwin-validate",
"TEST_WAYS": "",
"ac_cv_func_clock_gettime": "no",
@@ -5783,7 +5783,7 @@
"FETCH_GHC_VERSION": "9.10.3",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-freebsd14-validate",
"TEST_WAYS": ""
}
@@ -5850,7 +5850,7 @@
"CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-alpine3_12-int_native-validate+fully_static",
"TEST_WAYS": ""
}
@@ -5917,7 +5917,7 @@
"CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-alpine3_12-validate+fully_static",
"TEST_WAYS": ""
}
@@ -5984,7 +5984,7 @@
"CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-alpine3_23-validate",
"TEST_WAYS": ""
}
@@ -6053,7 +6053,7 @@
"FIREFOX_LAUNCH_OPTS": "{\"browser\":\"firefox\",\"executablePath\":\"/usr/bin/firefox\"}",
"HADRIAN_ARGS": "--docs=no-sphinx-pdfs --docs=no-sphinx-man",
"IGNORE_PERF_FAILURES": "all",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-alpine3_23-wasm-cross_wasm32-wasi-release+host_fully_static+text_simdutf",
"TEST_WAYS": ""
}
@@ -6123,7 +6123,7 @@
"FIREFOX_LAUNCH_OPTS": "{\"browser\":\"firefox\",\"executablePath\":\"/usr/bin/firefox\"}",
"HADRIAN_ARGS": "--docs=no-sphinx-pdfs --docs=no-sphinx-man",
"IGNORE_PERF_FAILURES": "all",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-alpine3_23-wasm-int_native-cross_wasm32-wasi-release+host_fully_static+text_simdutf",
"TEST_WAYS": ""
}
@@ -6193,7 +6193,7 @@
"FIREFOX_LAUNCH_OPTS": "{\"browser\":\"firefox\",\"executablePath\":\"/usr/bin/firefox\"}",
"HADRIAN_ARGS": "--docs=no-sphinx-pdfs --docs=no-sphinx-man",
"IGNORE_PERF_FAILURES": "all",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-alpine3_23-wasm-unreg-cross_wasm32-wasi-release+host_fully_static+text_simdutf",
"TEST_WAYS": ""
}
@@ -6262,7 +6262,7 @@
"CROSS_TARGET": "javascript-unknown-ghcjs",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": "-e config.timeout=900 -e config.timeout+=config.timeout+config.timeout",
+ "RUNTEST_ARGS": "-e config.timeout=900 -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-deb11-emsdk-closure-int_native-cross_javascript-unknown-ghcjs-validate",
"TEST_WAYS": ""
}
@@ -6328,7 +6328,7 @@
"CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-deb11-validate",
"TEST_WAYS": ""
}
@@ -6394,7 +6394,7 @@
"CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-deb11-validate+debug_info",
"TEST_WAYS": ""
}
@@ -6460,7 +6460,7 @@
"CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-deb12-validate",
"TEST_WAYS": ""
}
@@ -6529,7 +6529,7 @@
"CROSS_TARGET": "aarch64-linux-gnu",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": "-e config.timeout=900 -e config.timeout+=config.timeout+config.timeout",
+ "RUNTEST_ARGS": "-e config.timeout=900 -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-deb13-cross_aarch64-linux-gnu-validate",
"TEST_WAYS": ""
}
@@ -6595,7 +6595,7 @@
"CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-deb13-int_native-validate",
"TEST_WAYS": ""
}
@@ -6662,7 +6662,7 @@
"CONFIGURE_ARGS": "--disable-tables-next-to-code --enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-deb13-no_tntc-validate",
"TEST_WAYS": ""
}
@@ -6729,7 +6729,7 @@
"ENABLE_NUMA": "1",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-deb13-numa-slow-validate",
"TEST_WAYS": ""
}
@@ -6795,7 +6795,7 @@
"CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " --config perf_path=perf -e config.timeout+=config.timeout+config.timeout",
+ "RUNTEST_ARGS": " --config perf_path=perf -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-deb13-release",
"TEST_WAYS": ""
}
@@ -6864,7 +6864,7 @@
"CROSS_TARGET": "riscv64-linux-gnu",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": "-e config.timeout=900 -e config.timeout+=config.timeout+config.timeout",
+ "RUNTEST_ARGS": "-e config.timeout=900 -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-deb13-riscv-cross_riscv64-linux-gnu-validate",
"TEST_WAYS": ""
}
@@ -6930,7 +6930,7 @@
"CONFIGURE_ARGS": "--enable-unregisterised --enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-deb13-unreg-validate",
"TEST_WAYS": ""
}
@@ -6996,7 +6996,7 @@
"CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-deb13-validate",
"TEST_WAYS": ""
}
@@ -7062,7 +7062,7 @@
"CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": "--way=nonmoving --way=nonmoving_thr --way=nonmoving_thr_sanity -e config.timeout+=config.timeout+config.timeout",
+ "RUNTEST_ARGS": "--way=nonmoving --way=nonmoving_thr --way=nonmoving_thr_sanity -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-deb13-validate+boot_nonmoving_gc",
"TEST_WAYS": ""
}
@@ -7128,7 +7128,7 @@
"CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-deb13-validate+llvm",
"TEST_WAYS": "llvm optllvm"
}
@@ -7196,7 +7196,7 @@
"HADRIAN_ARGS": "--docs=none",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-deb13-validate+thread_sanitizer_cmm",
"TEST_WAYS": "",
"TSAN_OPTIONS": "suppressions=$CI_PROJECT_DIR/rts/.tsan-suppressions"
@@ -7263,7 +7263,7 @@
"CONFIGURE_ARGS": "--enable-ipe-data-compression --enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-deb13-zstd-validate",
"TEST_WAYS": ""
}
@@ -7329,7 +7329,7 @@
"CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-fedora43-release",
"TEST_WAYS": ""
}
@@ -7396,7 +7396,7 @@
"HADRIAN_ARGS": "--haddock-for-hackage",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-fedora43-release",
"TEST_WAYS": ""
}
@@ -7462,7 +7462,7 @@
"CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-fedora43-validate",
"TEST_WAYS": ""
}
@@ -7528,7 +7528,7 @@
"CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-fedora43-validate+debug_info",
"TEST_WAYS": ""
}
@@ -7595,7 +7595,7 @@
"HADRIAN_ARGS": "--docs=none",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-fedora43-validate+debug_info+ubsan",
"TEST_WAYS": "",
"UBSAN_OPTIONS": "suppressions=$CI_PROJECT_DIR/rts/.ubsan-suppressions"
@@ -7662,7 +7662,7 @@
"CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-rocky8-validate",
"TEST_WAYS": ""
}
@@ -7728,7 +7728,7 @@
"CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-ubuntu22_04-validate",
"TEST_WAYS": ""
}
@@ -7797,7 +7797,7 @@
"CROSS_TARGET": "loongarch64-linux-gnu",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": "-e config.timeout=900 -e config.timeout+=config.timeout+config.timeout",
+ "RUNTEST_ARGS": "-e config.timeout=900 -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-ubuntu24_04-loongarch-cross_loongarch64-linux-gnu-validate",
"TEST_WAYS": ""
}
@@ -7863,7 +7863,7 @@
"CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-linux-ubuntu24_04-validate",
"TEST_WAYS": ""
}
@@ -7929,7 +7929,7 @@
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
"LANG": "en_US.UTF-8",
"MSYSTEM": "CLANG64",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-windows-int_native-validate",
"TEST_WAYS": ""
}
@@ -7995,7 +7995,7 @@
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
"LANG": "en_US.UTF-8",
"MSYSTEM": "CLANG64",
- "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout",
+ "RUNTEST_ARGS": " -e config.timeout+=config.timeout+config.timeout+config.timeout+config.timeout",
"TEST_ENV": "x86_64-windows-validate",
"TEST_WAYS": ""
}
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/72a3fbcbcc75e38d188092801d016b6…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/72a3fbcbcc75e38d188092801d016b6…
You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
1
0