On Mon, 2025-02-03 at 09:46 +0000, JohnyTheCarrot via Gcc wrote:
> Dear GCC Developers,

Hi Tuur

> 
> I'm in the process of writing my own C compiler for educational
> purposes.
> To this end, I have decided to integrate into my compiler my own C++
> port ( https://github.com/johnythecarrot/mjolnir ) of the Rust crate
> Ariadne ( https://github.com/zesterer/ariadne ) which provides nice,
> fancy and readable diagnostics for use in compilers and the like. See
> the first link for an idea of how my library outputs diagnostics.

That output looks great, thanks!  There are some ideas in there I may
borrow for use in GCC - we're always looking for inspiration :)

How does mjolnir handle C++ template errors?  C++ compilers have an
alarming tendency to spam the user with multiple pages of output on
even simple errors, and I wonder if you've got any ideas on this.  FWIW
we're working towards addressing this in GCC; see
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116253
and an example here:
https://godbolt.org/z/xs4Gr6n6K


Have you looked into supporting SARIF as a machine-readable output
format?  GCC supports capturing most of this "rich" diagnostic
information in its SARIF output; see e.g.
https://gcc.gnu.org/wiki/SARIF

(or indeed, as a input format, for pretty output of SARIF log files?)

> 
> I had the idea of perhaps contributing this diagnostics system to GCC
> in one way or another, under a flag perhaps, but considered it might
> be an unwelcome addition. I was told that there's no harm in raising
> it with the GCC developers.
> 
> This message serves as a gauge of interest from the GCC developers
> for something of this kind. I am aware the current format of my
> diagnostics do not comply with the GNU Standards, and I'd therefore
> also like to politely ask for input on your suggestions on making it
> comply while retaining its cleanliness.

I'm the maintainer of GCC's diagnostics subsystem, and since GCC 6 (?)
have been adding things like support for underlined ranges, fix-it
hints, and so forth.

I confess that while I'm aware that there are some GNU standards for
diagnostics online somewhere, I've largely been ignoring them, to focus
on adding new features (what the kids today call "velocity") whilst
retaining compatibility within a >35 year old codebase, and to try to
improve the user-experience; FWIW I've written a UX guide here for GCC
here:
https://gcc.gnu.org/onlinedocs/gccint/User-Experience-Guidelines.html

In GCC 15 we've added some support for lines showing control flow, and
for colorized labels highlighting and contrasting different syntactic
elements; see e.g.:
https://gcc.gnu.org/wiki/cauldron2024talks?action=AttachFile&do=get&target=2024-Cauldron-diagnostics-talk.pdf

and the "ASCII" art for buffer overflows added in GCC 14 here:
https://developers.redhat.com/articles/2024/04/03/improvements-static-analysis-gcc-14-compiler#visualizing_buffer_overflows

> 
> I am the sole developer of Mjolnir and can therefore relicense it as
> necessary. Mjolnir still has a couple of issues to iron out and
> features to implement, such as multi-line span displaying.

Licensing (under a GPL-compatible license) isn't an issue so much as
implementation language.  GCC has rather conservative build
requirements, since we must be buildable of a wide variety of old
machines with hundreds of configure-time variants.  Although we
implement the very latest versions of C++ and have the beginnings of
Rust support, we implement all this in a subset of C++14 (and until
recently this was only C++11), and this subset has to be compatible
with a few other tools.

So, sadly, implementing core GCC functionality in Rust isn't an option
at this point (I wish it were, but I don't see it happening any time
soon, I'm afraid).

That said, I really like what you're doing.

>From am implementation point of view, GCC has a text_art::canvas class
for "painting" colorized text to a buffer with random access for output
to a stream, and a text_art::widget class for doing hierarchical
dynamic sizing of drawing elements.  There's also a rich_location class
which is used by diagnostics that are doing anything "fancy", though
perhaps this could be refactored into an API similar to ariadne's (or
one of the similar projects).

Hope this is constructive; thanks again for the links, and good luck
with mjolnir.

Dave

Reply via email to