Rules reference
One page per family. A family is "built" when its rules exist and have been run on a farm; "planned" means it is not built. A release is a source archive and the command line for three platforms, tagged automatically: see Releases.
| Family | Status | Load from | Main entry points |
|---|---|---|---|
| Rust | built | @buildrules//rules/rust:defs.bzl, or //:buildrules.bzl from the CLI | cargo_workspace, cargo_package, rust_library, rust_binary, rust_test |
| Node | built | @buildrules//rules/node:modules.bzl, defs.bzl | npm_package, npm_modules, tsc_check, tsc_build, jest_test, node_tree_test, node_tree_build, cdk_synth, node_test, esbuild_bundle |
| Zig | built | @buildrules//rules/zig:zig.bzl | zig_exe, zig_test, zig_module, zig_dist |
| C/C++ | built | @buildrules//rules/cxx:toolchain.bzl, defs.bzl | cxx_toolchains, the prelude's cxx_library and cxx_binary, c_exe, checked_cxx_library |
| Mojo | built | //pkg:buildrules.mojo.bzl, written by buildrules mojo sync | mojo_package |
| Python | planned | not released | none yet |
How the rules fit together #
- All rules run on the Linux x86_64 execution platform. The macros set that constraint for you.
- The tools a rule runs are pinned downloads and inputs of the action. See hermetic pinned toolchains.
- Tests are part of the build wherever the family has them: a test's result is an input of the artifact it guards, so the artifact cannot exist unless the test passed on those inputs. This is called a weld.
- The execution platform is configured by
buildrules_execution_platformsin yourplatforms/BUCK; the worker properties come from your gitignored.buckconfig.local. See Remote execution.
Platforms #
| Platform | Status |
|---|---|
| Linux x86_64 | built; the only platform that runs |
| CPU levels x86-64-v1 to v4 | built; see CPU levels |
| CPU levels armv8.0-a to armv8.4-a | planned; the flags are data and no Arm worker has run them |
| macOS | planned; nothing is built |
| Windows | planned; nothing is built |
Releases #
Every push to main is built and tested, and a green one that changes more than documentation or CI is released with no human action. A release is a tag vMAJOR.MINOR.PATCH, a GitHub release carrying the source archive buildrules-<version>.tar.gz, the command line for three platforms (buildrules-cli-<version>-<target>.tar.gz for linux-x86_64, linux-aarch64 and macos-arm64), their SHA256SUMS and the notes, and a keyless signature and a build provenance attestation of each of those files. MAJOR.MINOR is the VERSION file, changed by a pull request; PATCH is the highest existing patch of that line plus one.
The command line is a static program: unpack the tarball of your platform and put buildrules on your PATH. The three are built from one source behind the same tests, and a second build in the release must give the same bytes; the linux-x86_64 program is the file the beta stage runs, and the other two are checked for their file header and their version but not yet run by a user beta. The rules themselves build on Linux x86_64 farms only. To pin a release for the rules, name the tag and the sha256 of the archive, or the commit the tag names in your .buckconfig; the archive is the same bytes for the same tag, and the release job checks that before it publishes. RELEASING.md has the steps, the checks and the commands.
A release is made only after two more stages. In the beta stage, hello-world repositories (Rust, C and C++, Zig, Node, and one that mixes them) consume the candidate commit as an external cell, the way you do: buildrules init, cargo new, npm sync, then a build, a run of what was built, and a second build from nothing, in a copy of the repository at another path, that must give the same bytes. The Mojo leg builds a Mojo package with the pinned mopm 0.0.48 release, the same way, and two native legs run the command line the release ships for Arm Linux and for macOS on a runner of that kind, up to the build: the version it says, init writing the same bytes at two paths, Buck2 loading the candidate. They do not build, because no toolchain of the rules runs on those hosts yet. In the gamma stage our own repositories are built with the candidate on the farm, and a farm that is not configured fails the release rather than letting it pass. Each release also gets a page with the tag, the commit to pin, the archive URL and its sha256.
mopm 0.0.48 is released and pinned: the Mojo rules run the published mopm release (see Mojo). a buildrules release holds the source archive and the command line.
CPU levels #
A CPU level is a Buck2 constraint, isa_level. A target platform per level, buildrules//platforms:linux_<id> (for example linux_x86_64_v3), adds the level to the configuration. The compilers of every family get the flags below, so a v1 build and a v3 build have different output paths and different cache keys. A platform without a level, linux_x86_64, passes no CPU flag. native is never passed: a farm schedules on "at least this level", so host-tuned code would be cached under a lower level's key.
| Level | ISA property | rustc | zig cc | Status |
|---|---|---|---|---|
x86-64-v1 | x86-64 | -C target-cpu=x86-64 | -mcpu=x86_64 | built |
x86-64-v2 | x86-64-v2 | -C target-cpu=x86-64-v2 | -mcpu=x86_64_v2 | built |
x86-64-v3 | x86-64-v3 | -C target-cpu=x86-64-v3 | -mcpu=x86_64_v3 | built |
x86-64-v4 | x86-64-v4 | -C target-cpu=x86-64-v4 | -mcpu=x86_64_v4 | built |
armv8.0-a | armv8.0-a | -C target-cpu=generic | -mcpu=generic | planned |
armv8.1-a | armv8.1-a | -C target-cpu=generic -C target-feature=+v8.1a | -mcpu=generic+v8_1a | planned |
armv8.2-a | armv8.2-a | -C target-cpu=generic -C target-feature=+v8.2a | -mcpu=generic+v8_2a | planned |
armv8.3-a | armv8.3-a | -C target-cpu=generic -C target-feature=+v8.3a | -mcpu=generic+v8_3a | planned |
armv8.4-a | armv8.4-a | -C target-cpu=generic -C target-feature=+v8.4a | -mcpu=generic+v8_4a | planned |
Test execution requirements. Compile actions run on any worker: the first execution platform is level-agnostic (ISA=x86-64). A test is two targets, <name>__bin (the compile) and <name> (the run). The run lists exec_compatible_with = test_exec_compatible_with(), which selects an execution platform whose ISA property is the test's level, so a v3 test runs on a worker that reports ISA=x86-64-v3. There is one such platform for each of v2, v3 and v4; v1 needs none. If a test is left without that setting, analysis fails with built for ISA x86-64-v3 but its execution platform reports ISA=x86-64.
isa_audit reads the machine code, not the command line: it disassembles the binary with the pinned llvm-objdump and fails unless the binary holds 256-bit ymm instructions at v3 or v4 and none below. A flag that never reached the compiler would otherwise leave a green, cached, wrong build.
The CI matrix #
//ci:matrix is every cell of the matrix, built and tested in one command on the farm. A test of these examples is a build action, so building a cell tests it.
| Target | Builds and tests |
|---|---|
//ci:rust_default | the hand-written Rust example, the generated-unit examples (build scripts, links, tests) and the Zig examples, with the default Rust and the default Zig |
//ci:rust_oldest | the same Rust targets with the oldest supported Rust, through a configuration transition (rust_at) |
//ci:zig_next | the Zig examples with the other pinned Zig |
//ci:isa_v1, //ci:isa_v3 | the CPU-level example at the baseline and at x86-64-v3 (isa_at): the machine code is audited and the test runs on a worker of the level |
//ci:refusals | what the rules must refuse, as analysis tests: an unpinned Rust version, a wrong hash, a user pin that shadows a reviewed one |
//ci:crates | the example with crates.io dependencies, a build script and a native library, and sync --check over it |
//ci:gitcrates | the example whose dependency is a git repository pinned by commit (a build script and a proc-macro from GitHub's archive of the commit) |
//ci:matrix | all of the above |
Reproduce one cell by hand with a target platform: buck2 build --target-platforms buildrules//platforms:linux_x86_64_rust_1_85_0 //examples/hello:hello_runs. A Rust version added to the version table needs its line in rules/matrix.bzl, or loading fails.
//ci:mojo builds the Mojo examples. It is not part of //ci:matrix: it needs a mirror of the example registry (buildrules.url_map).