BUCKannotatedBUCKsource86 lines · 3.4 KB · raw

Only the toolchains this repo uses, copied from the prelude's system_demo_toolchains and configured, as that macro's docstring asks.

3load("@prelude//tests:test_toolchain.bzl", "noop_test_toolchain")
4load("@prelude//toolchains:cxx.bzl", "system_cxx_toolchain")
5load("@prelude//toolchains:genrule.bzl", "system_genrule_toolchain")
6load("@prelude//toolchains:python.bzl", "system_python_bootstrap_toolchain", "system_python_toolchain")
7load("@prelude//toolchains:remote_test_execution.bzl", "remote_test_execution_toolchain")
8load("@prelude//toolchains:rust.bzl", "system_rust_toolchain")
9load("@prelude//toolchains:zip_file.bzl", "zip_file_toolchain")
10load("@root//build:defs.bzl", "RUST_EDITION")

Tool paths come from the devshell's .buckconfig.local [nix] section.

13system_cxx_toolchain(
14    name = "cxx",
15    archiver = read_root_config("nix", "ar"),
16    compiler = read_root_config("nix", "cc"),
17    cxx_compiler = read_root_config("nix", "cxx"),
18    linker = read_root_config("nix", "cxx"),
19    visibility = ["PUBLIC"],
20)
22system_genrule_toolchain(
23    name = "genrule",
24    visibility = ["PUBLIC"],
25)

nix's python, not the prelude's downloaded cpython archive.

28system_python_toolchain(
29    name = "python",
30    interpreter = read_root_config("nix", "python"),
31    host_interpreter = read_root_config("nix", "python"),
32    visibility = ["PUBLIC"],
33)
35system_python_bootstrap_toolchain(
36    name = "python_bootstrap",
37    interpreter = read_root_config("nix", "python"),
38    visibility = ["PUBLIC"],
39)

The prelude's system toolchain invokes the bare name rustc, so the action key never records WHICH rustc compiled a crate. With the shared BuildBuddy cache, a library built by another repo's older rustc is served back and fails with E0514 "compiled by an incompatible version of rustc" (hit in ~/aifleet, 2026-09-30). The devshell writes rustc's nix store path to .buckconfig.local; passing it as an inert --cfg makes it part of every compile's key, so different compilers never share cache entries. No code reads the cfg. read_root_config, not read_config: this file is in the toolchains cell, whose own config never sees the root's .buckconfig.local. A missing value fails the build rather than falling back to a shared placeholder, which would silently reintroduce the collision.

52_RUSTC_IDENTITY = read_root_config("rust", "rustc_identity") or fail(
53    "rust.rustc_identity is unset: build inside `nix develop`, whose shellHook writes it to .buckconfig.local",
54)
55_RUSTC_IDENTITY_FLAGS = ["--cfg", 'rustc_identity="{}"'.format(_RUSTC_IDENTITY)]

Build scripts read OPT_LEVEL, and the prelude derives it only from an explicit -Copt-level here; cc-rs (ring) fails without it.

59system_rust_toolchain(
60    name = "rust",
61    default_edition = RUST_EDITION,
62    rustc_flags = [
63        "-Copt-level=3",
64        "-Cdebuginfo=line-tables-only",
65        # Dev and test builds keep debug assertions: the executor's
66        # backend-thread and one-waker-per-fd checks are debug_asserts.
67        # Release packaging (nix, contract §3) builds without them.
68        "-Cdebug-assertions=on",
69    ] + _RUSTC_IDENTITY_FLAGS,
70    visibility = ["PUBLIC"],
71)
73remote_test_execution_toolchain(
74    name = "remote_test_execution",
75    visibility = ["PUBLIC"],
76)
77
78noop_test_toolchain(
79    name = "test",
80    visibility = ["PUBLIC"],
81)
82
83zip_file_toolchain(
84    name = "zip_file",
85    visibility = ["PUBLIC"],
86)