Skills2026年4月19日·1 分钟阅读

Buck2 — Fast Polyglot Build System by Meta

Buck2 is a large-scale build system from Meta that compiles and tests code across multiple languages with fine-grained parallelism, remote execution support, and deterministic builds powered by a Starlark-based configuration language.

Agent 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
Buck2 Overview
直接安装命令
npx -y tokrepo@latest install 5965255f-3bed-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run 确认安装计划,再运行此命令。

Introduction

Buck2 is Meta's next-generation build system, a ground-up rewrite of the original Buck. It is designed to handle massive monorepos with millions of files across multiple programming languages. Buck2 uses a Starlark-based rule definition language, supports remote execution natively, and achieves high parallelism through a fine-grained dependency graph that avoids unnecessary rebuilds.

What Buck2 Does

  • Builds and tests projects in C++, Python, Rust, Java, Go, and other languages from a single build graph
  • Executes build actions in parallel with fine-grained dependency tracking to minimize rebuild times
  • Supports remote execution to distribute build actions across a cluster of build workers
  • Uses content-based hashing rather than timestamps to determine what needs rebuilding
  • Provides a Starlark-based configuration language for defining custom build rules and macros

Architecture Overview

Buck2 models the entire repository as a directed acyclic graph of targets, each defined in BUCK files using Starlark (a Python-like language). The build engine resolves dependencies, hashes inputs, and schedules actions for execution either locally or on remote workers via the Remote Execution API (RE API, compatible with Bazel's protocol). Buck2 is written in Rust for performance and memory safety. Its incremental computation engine (DICE) caches intermediate results and invalidates only the minimal subgraph affected by changes.

Self-Hosting & Configuration

  • Download pre-built binaries from the Buck2 GitHub releases page for Linux and macOS
  • Initialize a project with buck2 init which creates the repository structure and toolchain configs
  • Define build targets in BUCK files using Starlark with language-specific rule functions
  • Configure toolchains (compilers, linkers, interpreters) in a central .buckconfig or toolchain targets
  • Set up remote execution by configuring the RE API endpoint for distributed builds in CI

Key Features

  • DICE incremental computation engine provides fast incremental builds by caching the full computation graph
  • Language-agnostic design supports adding new languages through custom Starlark rule definitions
  • Remote execution distributes build actions across a fleet of workers using the Bazel-compatible RE API
  • Virtual filesystem integration through Buck2's I/O layer avoids materializing the full repo locally
  • BXL (Buck2 Extension Language) enables writing custom introspection and analysis queries over the build graph

Comparison with Similar Tools

  • Bazel — Google's polyglot build system with a larger ecosystem; Buck2 offers a more modern incremental engine and tighter monorepo integration
  • Pants — Python-friendly build system for monorepos; Buck2 handles more languages and scales to larger repositories
  • Turborepo — JavaScript/TypeScript monorepo build tool; Buck2 targets polyglot codebases beyond the JS ecosystem
  • Gradle — JVM-focused build tool with broad plugin support; Buck2 emphasizes hermeticity and remote execution for large-scale builds
  • Nx — Monorepo build orchestration for JS/TS; Buck2 operates at a lower level with full dependency graph analysis across languages

FAQ

Q: Is Buck2 production-ready? A: Yes. Buck2 powers Meta's internal monorepo with millions of targets across dozens of languages. It has been open-sourced for external adoption.

Q: Can I use Buck2 with Bazel remote execution backends? A: Yes. Buck2 implements the Bazel Remote Execution API protocol, so it works with compatible backends like BuildBarn, Buildfarm, and EngFlow.

Q: What languages does Buck2 support out of the box? A: Buck2 ships with rules for C++, Python, Rust, Java, Go, and OCaml. Additional languages can be added through custom Starlark rules.

Q: How does Buck2 differ from the original Buck? A: Buck2 is a complete rewrite in Rust with a new incremental computation engine (DICE), native remote execution, and Starlark-only configuration replacing the Python-based system.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产