Wen Kokke pushed to branch wip/fendor/full-eventlog-live at Glasgow Haskell Compiler / GHC Commits: 15866323 by Matthew Pickering at 2026-09-10T14:42:07+01:00 Support for `eventlog-socket` This adds the +eventlog-socket feature flag. If set, GHC is instrumented with Eventlog Socket. - - - - - 41ed3d90 by fendor at 2026-09-10T14:58:26+01:00 Support for `ghc-stack-profiler` This adds the +ghc-stack-profiler feature flag. If set, GHC is instrumented with GHC Stack Profiler. - - - - - 11 changed files: - .gitmodules - + eventlog-socket - + ghc-stack-profiler - ghc/Main.hs - ghc/ghc-bin.cabal.in - hadrian/src/Packages.hs - hadrian/src/Settings/Default.hs - hadrian/src/Settings/Packages.hs - + libraries/async - + libraries/hashable - + libraries/unordered-containers Changes: ===================================== .gitmodules ===================================== @@ -122,3 +122,18 @@ [submodule "libraries/libffi-clib"] path = libraries/libffi-clib url = https://gitlab.haskell.org/ghc/libffi-clib.git +[submodule "eventlog-socket"] + path = eventlog-socket + url = https://github.com/well-typed/eventlog-socket.git +[submodule "ghc-stack-profiler"] + path = ghc-stack-profiler + url = https://github.com/well-typed/ghc-stack-profiler +[submodule "libraries/async"] + path = libraries/async + url = https://github.com/fendor/async.git +[submodule "libraries/unordered-containers"] + path = libraries/unordered-containers + url = https://github.com/fendor/unordered-containers.git +[submodule "libraries/hashable"] + path = libraries/hashable + url = https://github.com/fendor/hashable ===================================== eventlog-socket ===================================== @@ -0,0 +1 @@ +Subproject commit 57ca65170bf6d264a284a047f3cb350d498fc256 ===================================== ghc-stack-profiler ===================================== @@ -0,0 +1 @@ +Subproject commit 389d886a1494cd019ee93c72c8f19cf7f9dc1664 ===================================== ghc/Main.hs ===================================== @@ -93,6 +93,28 @@ import Data.List ( isPrefixOf, partition, intercalate ) import Prelude import qualified Data.List.NonEmpty as NE +#if defined(EVENTLOG_SOCKET) +import qualified GHC.Eventlog.Socket +#endif + +#if defined(GHC_STACK_PROFILER) +import qualified GHC.Stack.Profiler +#endif + +startEventlogSocketFromEnv :: IO () +#if defined(EVENTLOG_SOCKET) +startEventlogSocketFromEnv = GHC.Eventlog.Socket.startFromEnv +#else +startEventlogSocketFromEnv = pure () +#endif + +startGhcStackProfilerFromEnv :: IO () +#if defined(GHC_STACK_PROFILER) +startGhcStackProfilerFromEnv = void GHC.Stack.Profiler.startProfilerFromEnv +#else +startGhcStackProfilerFromEnv = pure () +#endif + ----------------------------------------------------------------------------- -- ToDo: @@ -107,6 +129,9 @@ import qualified Data.List.NonEmpty as NE main :: IO () main = do + startEventlogSocketFromEnv + startGhcStackProfilerFromEnv + hSetBuffering stdout LineBuffering hSetBuffering stderr LineBuffering ===================================== ghc/ghc-bin.cabal.in ===================================== @@ -27,11 +27,21 @@ Flag interpreter Default: False Manual: True +Flag eventlog-socket + Description: Build with support for eventlog-socket + Default: False + Manual: True + Flag threaded Description: Link the ghc executable against the threaded RTS Default: True Manual: True +Flag ghc-stack-profiler + Description: Build with support for ghc-stack-profiler + Default: False + Manual: True + Executable ghc Default-Language: GHC2024 @@ -93,6 +103,14 @@ Executable ghc if flag(threaded) ghc-options: -threaded + if flag(eventlog-socket) + build-depends: eventlog-socket + CPP-OPTIONS: -DEVENTLOG_SOCKET + + if flag(ghc-stack-profiler) + build-depends: ghc-stack-profiler + CPP-OPTIONS: -DGHC_STACK_PROFILER + Other-Extensions: CPP NondecreasingIndentation ===================================== hadrian/src/Packages.hs ===================================== @@ -12,7 +12,9 @@ module Packages ( runGhc, semaphoreCompat, stm, templateHaskell, thLift, thQuasiquoter, terminfo, text, time, timeout, transformers, unlit, unix, win32, xhtml, lintersCommon, lintNotes, lintCodes, lintCommitMsg, lintSubmoduleRefs, lintWhitespace, + eventlogSocket, eventlogSocketControl, ghcPackages, isGhcPackage, + async, hashable, unorderedContainers, ghc_stack_profiler, ghc_stack_profiler_core, -- * Package information crossPrefix, programBasename, programName, nonHsMainPackage, programPath, timeoutPath, @@ -41,8 +43,11 @@ ghcPackages = , parsec, pretty, process, rts, runGhc, stm, semaphoreCompat, templateHaskell, thLift, thQuasiquoter , terminfo, text, time, transformers, unlit, unix, win32, xhtml, fileio , timeout + , eventlogSocketControl, eventlogSocket , lintersCommon - , lintNotes, lintCodes, lintCommitMsg, lintSubmoduleRefs, lintWhitespace ] + , lintNotes, lintCodes, lintCommitMsg, lintSubmoduleRefs, lintWhitespace + , async, hashable, unorderedContainers, ghc_stack_profiler_core, ghc_stack_profiler + ] -- TODO: Optimise by switching to sets of packages. isGhcPackage :: Package -> Bool @@ -58,7 +63,8 @@ array, base, binary, bytestring, cabalSyntax, cabal, changelogD, checkPpr, check osString, parsec, pretty, primitive, process, rts, runGhc, semaphoreCompat, stm, templateHaskell, thLift, thQuasiquoter, terminfo, text, time, transformers, unlit, unix, win32, xhtml, timeout, - lintersCommon, lintNotes, lintCodes, lintCommitMsg, lintSubmoduleRefs, lintWhitespace + lintersCommon, lintNotes, lintCodes, lintCommitMsg, lintSubmoduleRefs, lintWhitespace, + eventlogSocket, eventlogSocketControl :: Package array = lib "array" base = lib "base" @@ -134,6 +140,13 @@ unlit = util "unlit" unix = lib "unix" win32 = lib "Win32" xhtml = lib "xhtml" +eventlogSocket = lib "eventlog-socket" `setPath` "eventlog-socket/eventlog-socket" +eventlogSocketControl = lib "eventlog-socket-control" `setPath` "eventlog-socket/eventlog-socket-control" +async = lib "async" +hashable = lib "hashable" +unorderedContainers = lib "unordered-containers" +ghc_stack_profiler = lib "ghc-stack-profiler" `setPath` "ghc-stack-profiler/ghc-stack-profiler" +ghc_stack_profiler_core = lib "ghc-stack-profiler-core" `setPath` "ghc-stack-profiler/ghc-stack-profiler-core" lintersCommon = lib "linters-common" `setPath` "linters/linters-common" lintNotes = linter "lint-notes" ===================================== hadrian/src/Settings/Default.hs ===================================== @@ -110,6 +110,8 @@ stage0Packages = do , thQuasiquoter -- new library not yet present for boot compilers , unlit , xhtml -- new version is not backwards compat with latest + , eventlogSocket + , eventlogSocketControl , if windowsHost then win32 else unix -- We must use the in-tree `Win32` as the version -- bundled with GHC 9.6 is too old for `semaphore-compat`. @@ -190,6 +192,11 @@ stagedPackages stage = do , hpcBin , if winTarget then win32 else unix , runGhc + , ghc_stack_profiler + , ghc_stack_profiler_core + , async + , hashable + , unorderedContainers ] , when (winTarget && not cross) [ -- See Note [Hadrian's ghci-wrapper package] ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -105,6 +105,22 @@ packageArgs = do , builder (Haddock BuildPackage) ? arg ("--optghc=-I" ++ path) ] + , package ghc_stack_profiler ? mconcat + [ builder (Cabal Flags) ? mconcat + [ arg "-use-ghc-trace-events" + -- Add support for eventlog-socket commands + , arg "+control" + ] + ] + + , package eventlogSocket ? mconcat + [ builder (Cabal Flags) ? mconcat + [ + -- Add support for eventlog-socket commands + arg "+control" + ] + ] + ---------------------------------- ghc --------------------------------- , package ghc ? mconcat [ builder Ghc ? mconcat @@ -114,6 +130,8 @@ packageArgs = do , builder (Cabal Flags) ? mconcat [ andM [expr (ghcWithInterpreter stage), orM [expr (notM cross), stage1]] `cabalFlag` "interpreter" , andM [expr (ghcWithInterpreter stage), notM (expr cross)] `cabalFlag` "internal-interpreter" + , notStage0 `cabalFlag` "eventlog-socket" + , notStage0 `cabalFlag` "sampleTracer" , ifM stage0 -- We build a threaded stage 1 if the bootstrapping compiler -- supports it. ===================================== libraries/async ===================================== @@ -0,0 +1 @@ +Subproject commit 474fc7f612b74e73e24e91474fa75af18eede7b7 ===================================== libraries/hashable ===================================== @@ -0,0 +1 @@ +Subproject commit d56d62eb2a9ff4376e7119d925ececa60959d9ec ===================================== libraries/unordered-containers ===================================== @@ -0,0 +1 @@ +Subproject commit 368ea40488bf3c644e9c36d996302029fb0fc227 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/57a6a8fab1cb42f9e4c2fd98883ec11... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/57a6a8fab1cb42f9e4c2fd98883ec11... 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