Thessaloniki GNOME+Rust Hackfest 2018

- gnome, rust

A couple of weeks ago we had the fourth GNOME+Rust hackfest, this time in Thessaloniki, Greece. This is the beautiful city that will host next year's GUADEC, but fortunately GUADEC will be in summertime!

We held the hackfest at the CoHo coworking space, a small, cozy office between the University and the sea.

Every such hackfest I am overwhelmed by the kind hackers who work on [gnome-class], the code generator for GObject implementations in Rust.

Mredlek has been working on generalizing the code generators in gnome-class, so that we can have the following from the same run:

  • Rust code generation, for the GObject implementations themselves. Thanks to mredlek, this is much cleaner than it was before; now both classes and interfaces share the same code for most of the boilerplate.

  • GObject Introspection (.gir) generation, so that language bindings can be generated automatically.

  • C header files (.h), so the generated GObjects can be called from C code as usual.

So far, Rust and GIR work; C header files are not generated yet.

Mredlek is a new contributor to gnome-class, but unfortunately was not able to attend the hackfest. Not only did he rewrite the gnome-class parser using the new version of syn; he also added support for passing owned types to GObject methods, such as String and Variant. But the biggest thing is probably that mredlek made it a lot easier to debug the generated Rust source; see the documentation on debugging for details.

Speaking of which, thanks to Jordan Petridis for making the documentation be published automatically from Gitlab's Continuous Integration pipelines.

Alex Crichton kindly refactored our error propagation code, and even wrote docs on it! Along with Jordan, they updated the code for the Rust 2018 edition, and generally wrangled the build process to conform with the lastest Rust nightlies. Alex also made code generation a lot faster, by offloading auto-indentation to an external rustfmt process, instead of using it as a crate: using the rustfmt crate meant that the compiler had a lot more work to do. During the whole hackfest, Alex was very helpful with Rust questions in general. While my strategy to see what the compiler does is to examine the disassembly in gdb, his strategy seems to be to look at the LLVM intermediate representation instead... OMG.

And we can derive very simple GtkWidgets now!

Saving the best for last... Antoni Boucher, the author of relm, has been working on making it possible to derive from gtk::Widget. Once this merge request is done, we'll have an example of deriving from gtk::DrawingArea from Rust with very little code.

Normally, the gtk-rs bindings work as a statically-generated binding for GObject, which really is a type hierarchy defined at runtime. The static binding really wants to know what is a subclass of what: it needs to know in advance that Button's hierarchy is Button → Bin → Container → Widget → Object, plus all the GTypeInterfaces supported by any of those classes. Antoni has been working on making gnome-class extract that information automatically from GIR files, so that the gtk-rs macros that define new types will get all the necessary information.

Future work

There are still bugs in the GIR pipeline that prevent us from deriving, say, from gtk::Container, but hopefully these will be resolved soon.

Sebastian Dröge has been refactoring his Rust tools to create GObject subclasses with very idiomatic and refined Rust code. This is now at a state where gnome-class itself could generate that sort of code, instead of generating all the boilerplate from scratch. So, we'll start doing that, and integrating the necessary bits into gtk-rs as well.

Finally, during the last day I took a little break from gnome-class to work on librsvg. Julian Sparber has been updating the code to use new bindings in cairo-rs, and is also adding a new API to fetch an SVG element's geometry precisely.


Oh, boy, I wish the weather had been warmer. The city looks delightful to walk around, especially in the narrow streets on the hills. Can't wait to see it in summer during GUADEC.


Finally, thanks to CoHo for hosting the hackfest, and to the GNOME Foundation for sponsoring my travel and accomodation. And to Centricular for taking us all to dinner!

Special thanks to Jordan Petridis for being on top of everything build-wise all the time.

Sponsored by the GNOME Foundation