Introducing Meson++

I've been semi-quietly working on a new project for the last few months on and off, and today I've gotten far enough that I want to talk about it more widely: Meson++.

Meson++ is now capable of compiling very simply projects, if they meet the following criteria: 

  • they use only C++
  • they don't have any external dependencies
  • they only build executables
  • they don't do any code generation
  • you're okay using ninja
  • you're using clang or gcc
This may seem like a lot of restrictions, and it is, but there's a lot of code that has gone into getting to this point. I'd like to thank stackoverflow for answering a lot of questions.

Motivation

My primary motivation is to solve bootstrapping issues, imagine if python wanted to use Meson, currently that would create a bootstrap loop, where you need an old version of python to run an old version of Meson, etc. Or, imagine you want to build something like your compiler with Meson, now you need to build python before you can build your compiler.

Meson++ in Detail

Meson++ is architected very differently than Meson (or Muon, another cool Meson implementation in C11). Meson++ treats the Meson DSL as a const-evaluated compilation, and acts more like a compiler, with an IR and transformation passes that attempts to lower the DSL until only targets remain, and then passes that lowered IR to backends that further refine the IR into a form it likes, then writes out the backend file(s). This is contrast to Meson which acts as an interpreter, consuming the AST and emitting state.

In detail Meson++ uses a Flex/Bison lexer/parser, has a C++ mid-level IR that is SSA-like (it's flat, with each block having only two exits. It runs and optimizer that walks over the IR performing various optimizations.

It's written in C++17, which gives access to some very nice features, resource manager (formerly called smart pointers), the filesystem additions to the standard library, and well tested containers. I know for a lot of people spending hours crafting list and map implementations that are subtly broken in C is the best part of writing something, but I don't :)

What's next?

My next goal is to get Meson++ self-hosting, which means adding support for custom targets, static libraries, linking, and include directories. Lot's to do, but now that I've got a basic program compiling, it's all incremental changes on the way there.

Comments

Popular posts from this blog

This Weekend in Meson++ (February 6th)

Rust in Meson — 0.57 Edition