RUST_STABLE_VERSION = "1.95.0" # LLVM 22 RUST_NIGHTLY_VERSION = "nightly/2026-04-16" RUST_TARGET_TRIPLES = [ "x86_64-apple-darwin", "aarch64-unknown-linux-gnu", "aarch64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-pc-windows-msvc", ] rust = use_extension("@rules_rust//rust:extensions.bzl", "rust") rust.toolchain( allocator_library = "@rules_rust//ffi/rs:empty", edition = "2024", extra_rustc_flags_triples = { # Enable ISA extensions matching the ones used for C++. The clmul feature is not included as # it is still "unstable" as of 1.86.0. "x86_64-unknown-linux-gnu": ["-Ctarget-feature=+sse4.2"], "x86_64-apple-darwin": ["-Ctarget-feature=+sse4.2"], "x86_64-pc-windows-msvc": ["-Ctarget-feature=+sse4.2"], "aarch64-unknown-linux-gnu": ["-Ctarget-feature=+crc"], # No options needed for aarch64-apple-darwin: CRC feature is enabled by default. }, extra_target_triples = RUST_TARGET_TRIPLES, rustfmt_version = RUST_NIGHTLY_VERSION, versions = [ RUST_STABLE_VERSION, RUST_NIGHTLY_VERSION, ], ) use_repo(rust, "rust_toolchains") register_toolchains("@rust_toolchains//:all") # rust-based lolhtml dependency, including the API header. # Presented as a separate repository to allow overrides. new_local_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:local.bzl", "new_local_repository") new_local_repository( name = "com_cloudflare_lol_html", build_file = "@workerd//deps/rust:BUILD.lolhtml", path = "empty", ) # workerd-cxx http = use_extension("@//:build/exts/http.bzl", "http") inject_repo( http, **{"crates.io": "crates_vendor"} ) crate = use_extension("@rules_rust//crate_universe:extensions.bzl", "crate") crate.annotation( crate = "lol_html_c_api", extra_aliased_targets = {"lol_html_c_api_include_lol_html_h": "include/lol_html.h"}, ) crate.annotation( crate = "capnpc", gen_binaries = ["capnpc-rust"], ) crate.from_cargo( # TODO(cleanup): This name is a bit misleading now that we don't vendor. We can clean it up as a # followup. name = "crates_vendor", cargo_lockfile = "//deps/rust:Cargo.lock", manifests = ["//deps/rust:Cargo.toml"], supported_platform_triples = RUST_TARGET_TRIPLES, ) use_repo( crate, "crates_vendor", )