Meta’s Open-Source Build System: Buck2, Built on Rust

Meta's build system Buck2 is built on Rust and open source

Facebook’s parent company, Meta, has announced the release of Buck2, a newly developed build system that follows the Buck build system, which Meta has only used internally for automated software creation up to now. Buck2 is written in the Rust programming language and is said to work much faster than Buck1. It is also now freely available as open source on GitHub.

The aim of Buck2 was to make the build tool more flexible, more powerful, and more reliable. The new build tool retains Buck’s proven concepts and processes, but has also been equipped with new functions for greater efficiency. Unlike Buck1, which is comparable to the widespread build tool Bazel, Buck2 is now based on a core that does not know any rules specific to the programming language. The language rules are completely separated from the Buck core programmed in Rust, making them easier to understand and change.

In order to separate the rules, the meta development team had to abstract the relevant functions as generic reusable APIs. These in turn open up new possibilities in dealing with different patterns, such as the linking model of C++. The transitive sets (tsets) introduced in Buck2 allow a procedure that saves both memory and computing time when creating a C++ library than was possible in Buck1.

The new system is only based on a single incremental dependency graph, which allows for more parallelization and avoids redundant work steps. This also eliminates typical errors known from Buck1 and Bazel. The newly designed Rules API also contributes to higher performance by providing dynamic and monadic dependency functions.

Buck2 is already prepared for more complex application scenarios such as remote execution or access to virtual file systems. It supports Sapling-based file systems such as EdenFS for use cases in which the entire repository is not checked out, but only fetched when files are accessed. This can contribute to faster checkouts while requiring less hard disk space.

For more information on Buck2, see Facebook Engineering’s blog post, or get started in the documentation.

Leave a Reply