Hi everyone. I'd like to ping this patch kit:
[PATCH 0/4] Publish/subscribe framework for typesafe loosely-coupled notifications https://gcc.gnu.org/pipermail/gcc-patches/2025-November/700681.html I can self-approve patches 3 and 4, but given that patches 1 and 2 introduce a new subsystem into GCC, they should probably be looked at by another maintainer. Thanks Dave On Fri, 2025-11-14 at 13:26 -0500, David Malcolm wrote: > This patch kit introduces a publish/subscribe mechanism to GCC's > codebase, allowing for loosely-coupled senders and receivers, with > strongly-typed messages passing between them. > > For example, a GCC subsystem could publish messages about events, > and plugins or diagnostic sinks could subscribe to them. > > This is a little like the plugin subsystem, but unlike the plugin > subsystem where callbacks receive "void *", the messages are > strongly-typed. Also, I want to have diagnostic sinks subscribe to > some messages, and these are not plugins. It seems to me that the > notification mechanism should be orthogonal to whether or not the > sender or receiver components are built in the main executable or are > in a plugin. > > Patch 1 adds generic publish/subscribe classes, and selftests. > > Patch 2 adds: > * a new gcc/topics/ source subdirectory to hold the types for > publish/subscribe topics relating to the compiler > * a new struct compiler_channels to the global gcc::context > * a pass_events_channel which issues notifications when passes > stop and start on particular functions > * a toy plugin using the above to implement a progress notification > UI > > Patch 3 uses the pass_events_channel to extend the diagnostics > subsystem > so that sinks gain a key/value pair "cfg={yes,no}" which allows > capturing > the state of GCC's internal representation in SARIF files. > > Patch 4 is an example of eliminating a plugin event > (PLUGIN_ANALYZER_INIT)in favor of a pub/sub channel, which plugins > can > subscribe to instead. > > Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. > > OK for trunk? > > I have various followups planned that add other kinds of channel, and > allow other kinds of information to be (optionally) captured in SARIF > dumps: > • callgraph > • inheritance hierarchy > • #include graph of a TU (what includes what) > * etc > but those patches aren't yet ready [1] > > Dave > > [1] see slides 33-38 of my Cauldron talk: > https://gcc.gnu.org/wiki/cauldron2025#What.27s_new_with_diagnostics_in_GCC_16 > > > David Malcolm (4): > Add pub-sub.{h,cc} > Add publish/subscribe topics and channel: pass_events > diagnostics: add optional CFG dumps to SARIF/HTML output sinks > analyzer: replace PLUGIN_ANALYZER_INIT with a pub/sub channel > > gcc/Makefile.in | 5 + > gcc/analyzer/common.h | 47 ++- > gcc/analyzer/engine.cc | 36 +- > gcc/cfghooks.cc | 30 ++ > gcc/cfghooks.h | 10 + > gcc/cfgrtl.cc | 2 + > gcc/channels.h | 45 ++ > gcc/context.cc | 7 +- > gcc/context.h | 12 + > gcc/custom-sarif-properties/cfg.cc | 69 ++++ > gcc/custom-sarif-properties/cfg.h | 64 +++ > gcc/diagnostics/digraphs-to-dot-from-cfg.cc | 323 +++++++++++++++ > gcc/diagnostics/digraphs-to-dot.cc | 202 +++++++++ > gcc/diagnostics/digraphs-to-dot.h | 84 ++++ > gcc/diagnostics/digraphs.cc | 137 +----- > gcc/diagnostics/digraphs.h | 6 + > gcc/diagnostics/html-sink.cc | 30 ++ > gcc/diagnostics/sarif-sink.cc | 40 ++ > gcc/diagnostics/sink.h | 5 + > gcc/diagnostics/text-sink.h | 7 + > gcc/doc/invoke.texi | 23 +- > gcc/doc/plugins.texi | 4 - > gcc/gimple-pretty-print.cc | 84 ++++ > gcc/gimple-pretty-print.h | 7 + > gcc/graphviz.cc | 52 +++ > gcc/graphviz.h | 3 + > gcc/libsarifreplay.cc | 5 +- > gcc/opts-common.cc | 1 + > gcc/opts-diagnostic.cc | 93 ++++- > gcc/opts-diagnostic.h | 14 + > gcc/opts.cc | 1 + > gcc/passes.cc | 12 + > gcc/plugin.cc | 2 - > gcc/plugin.def | 4 - > gcc/print-rtl.cc | 25 ++ > gcc/print-rtl.h | 7 + > gcc/pub-sub.cc | 138 +++++++ > gcc/pub-sub.h | 68 +++ > gcc/selftest-run-tests.cc | 1 + > gcc/selftest.h | 1 + > gcc/testsuite/gcc.dg/diagnostic-cfgs-html.py | 21 + > gcc/testsuite/gcc.dg/diagnostic-cfgs-sarif.py | 84 ++++ > gcc/testsuite/gcc.dg/diagnostic-cfgs.c | 18 + > .../gcc.dg/plugin/analyzer_cpython_plugin.cc | 53 +-- > .../gcc.dg/plugin/analyzer_gil_plugin.cc | 30 +- > .../gcc.dg/plugin/analyzer_kernel_plugin.cc | 43 +- > .../plugin/analyzer_known_fns_plugin.cc | 37 +- > gcc/testsuite/gcc.dg/plugin/plugin.exp | 1 + > .../plugin/progress_notifications_plugin.cc | 51 +++ > gcc/topics/pass-events.h | 59 +++ > gcc/tree-cfg.cc | 1 + > gcc/tree-diagnostic-cfg.cc | 390 > ++++++++++++++++++ > gcc/tree-diagnostic-sink-extensions.h | 32 ++ > gcc/tree-diagnostic.cc | 5 + > 54 files changed, 2256 insertions(+), 275 deletions(-) > create mode 100644 gcc/channels.h > create mode 100644 gcc/custom-sarif-properties/cfg.cc > create mode 100644 gcc/custom-sarif-properties/cfg.h > create mode 100644 gcc/diagnostics/digraphs-to-dot-from-cfg.cc > create mode 100644 gcc/diagnostics/digraphs-to-dot.cc > create mode 100644 gcc/diagnostics/digraphs-to-dot.h > create mode 100644 gcc/pub-sub.cc > create mode 100644 gcc/pub-sub.h > create mode 100644 gcc/testsuite/gcc.dg/diagnostic-cfgs-html.py > create mode 100644 gcc/testsuite/gcc.dg/diagnostic-cfgs-sarif.py > create mode 100644 gcc/testsuite/gcc.dg/diagnostic-cfgs.c > create mode 100644 > gcc/testsuite/gcc.dg/plugin/progress_notifications_plugin.cc > create mode 100644 gcc/topics/pass-events.h > create mode 100644 gcc/tree-diagnostic-cfg.cc > create mode 100644 gcc/tree-diagnostic-sink-extensions.h >
