- Notifications
You must be signed in to change notification settings - Fork249
Build system, successor to Buck
License
Apache-2.0, MIT licenses found
Licenses found
facebook/buck2
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Buck2 is a fast, hermetic, multi-language build system, and a direct successorto the originalBuck build system ("Buck1") — bothdesigned by Meta.
But what do those words really mean for a build system — and why mightthey interest you? "But why Buck2?" you might ask, when so many build systemsalready exist?
- Fast. It doesn't matter whether a single build command takes 60 seconds tocomplete, or 0.1 seconds: when you have to build things, Buck2 doesn't wastetime — it calculates the critical path and gets out of the way, withminimal overhead. It's not just the core design, but also careful attention todetail that makes Buck2 so snappy. Buck2 is up to 2x faster than Buck1inpractice1. So you spend more time iterating, and less timewaiting.
- Hermetic. When using Remote Execution2, Buck2 becomeshermetic: it is required for a build rule to correctly declare all of itsinputs; if they aren't specified correctly (e.g. a
.c
file needs a.h
filethat isn't correctly specified), the build will fail. This enforcedcorrectness helps avoids entire classes of errors that most build systemsallow, and helps ensure builds work everywhere for all users. And Buck2correctly tracks dependencies with far better accuracy than Buck1, in morelanguages, across more scenarios. That means "it compiles on my machine" canbecome a thing of the past. - Multi-language. Many teams have to deal with multiple programminglanguages that have complex inter-dependencies, and struggle to express that.Most people settle with
make
and tie togetherdune
topip
andcargo
.But then how do you run test suites, code coverage, or query code databases?Buck2 is designed to support multiple languages from the start, withabstractions for interoperation. And because it's completely scriptable, andusers can implement language support — it's incredibly flexible. Nowyour Python library can depend on an OCaml library, and your OCaml library candepend on a Rust crate — and with a single build tool, you have aconsistent UX to build and test and integrate all of these components.
If you're familiar with systems like Buck1,Bazel, orPants — then Buck2 will feel warm and cozy,and these ideas will be familiar. But then why create Buck2 if those alreadyexist? Because that isn't all — the page"Why Buck2?" on our website goes intomore detail on several other important design critera that separate Buck2 fromthe rest of the pack, including:
- Support for ultra-large repositories, through filesystem virtualization andwatching for changes to the filesystem.
- Totally language-agnostic core executable, with a small API — even C/C++support is written as a library. You can write everything from scratch, if youwanted.
- "Buck Extension Language" (BXL) can be used for self-introspection of thebuild system, allowing automation tools to inspect and run actions in thebuild graph. This allows you to more cleanly support features that need graphintrospection, like LSPs or compilation databases.
- Support for distributed compilation, using the same Remote Execution API thatis supported by Bazel. Existing solutions like BuildBarn, BuildBuddy, EngFlow,and NativeLink all work today.
- An efficient, robust, and sound design — inspired by modern theory ofbuild systems and incremental computation.
- And more!
If these headline features make you interested — check out theGetting Started guide!
Buck2 was released recently and currentlydoes not have a stable release tagat this time. Pre-release tags/binaries, and stable tags/binaries, will comeat later dates. Despite that, it is used extensively inside of Meta on vastamounts of code every day, andbuck2-prelude is the same code usedinternally for all these builds, as well.
Meta just uses the latest committedHEAD
version of Buck2 at all times. Yourmileage may vary — but at the moment, trackingHEAD
is ideal forsubmitting bug reports and catching regressions.
The short of this is that you should consider this project and its code to bebattle-tested and working, but outside consumers will encounter quite a lot ofrough edges right now — several features are missing or in progress, sometoolchains from Buck1 are missing, and you'll probably have to fiddle withthings more than necessary to get it nice and polished.
Please provide feedback by submittingissues and questions!
You can get started by downloading thelatest buck2 binary foryour platform. Thelatest
tag always refers to a recent commit; it is updatedon every single push to the GitHub repository, so it will always be a recentversion.
You can also compile Buck2 from source, if a binary isn't immediately availablefor your use; check out theHACKING.md file for information.
Frequently used terms and their definitions can be found on theglossary page.
Buck2 is licensed under both the MIT license and Apache-2.0 license; the exactterms can be found in theLICENSE-MIT andLICENSE-APACHE files, respectively.
Footnotes
This number comes from internal usage of Buck1 versus Buck2 at Meta. Pleasenote thatappropriate comparisons with systems like Bazel have yet to beperformed; Buck1 is the baseline because it's simply what existed and whathad to be replaced. Please benchmark Buck2 against your favorite tools andlet us know how it goes!↩
Buck2 currently does not sandboxlocal-only build steps; in contrast,Buck2 using Remote Execution isalways hermetic by design. The vastmajority of build rules are remote compatible, as well. Despite that, wehope to lift this restriction in the (hopefully short-term) future so thatlocal-only builds are hermetic as well.↩
About
Build system, successor to Buck