Skip to content
File

Blob: build/deps/rust.MODULE.bazel

2.3 KB
1RUST_STABLE_VERSION = "1.95.0" # LLVM 22
2 
3RUST_NIGHTLY_VERSION = "nightly/2026-04-16"
4 
5RUST_TARGET_TRIPLES = [
6 "x86_64-apple-darwin",
7 "aarch64-unknown-linux-gnu",
8 "aarch64-apple-darwin",
9 "x86_64-unknown-linux-gnu",
10 "x86_64-pc-windows-msvc",
11]
12 
13rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
14rust.toolchain(
15 allocator_library = "@rules_rust//ffi/rs:empty",
16 edition = "2024",
17 extra_rustc_flags_triples = {
18 # Enable ISA extensions matching the ones used for C++. The clmul feature is not included as
19 # it is still "unstable" as of 1.86.0.
20 "x86_64-unknown-linux-gnu": ["-Ctarget-feature=+sse4.2"],
21 "x86_64-apple-darwin": ["-Ctarget-feature=+sse4.2"],
22 "x86_64-pc-windows-msvc": ["-Ctarget-feature=+sse4.2"],
23 "aarch64-unknown-linux-gnu": ["-Ctarget-feature=+crc"],
24 # No options needed for aarch64-apple-darwin: CRC feature is enabled by default.
25 },
26 extra_target_triples = RUST_TARGET_TRIPLES,
27 rustfmt_version = RUST_NIGHTLY_VERSION,
28 versions = [
29 RUST_STABLE_VERSION,
30 RUST_NIGHTLY_VERSION,
31 ],
32)
33use_repo(rust, "rust_toolchains")
34 
35register_toolchains("@rust_toolchains//:all")
36 
37# rust-based lolhtml dependency, including the API header.
38# Presented as a separate repository to allow overrides.
39new_local_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:local.bzl", "new_local_repository")
40 
41new_local_repository(
42 name = "com_cloudflare_lol_html",
43 build_file = "@workerd//deps/rust:BUILD.lolhtml",
44 path = "empty",
45)
46 
47# workerd-cxx
48http = use_extension("@//:build/exts/http.bzl", "http")
49 
50inject_repo(
51 http,
52 **{"crates.io": "crates_vendor"}
53)
54 
55crate = use_extension("@rules_rust//crate_universe:extensions.bzl", "crate")
56crate.annotation(
57 crate = "lol_html_c_api",
58 extra_aliased_targets = {"lol_html_c_api_include_lol_html_h": "include/lol_html.h"},
59)
60crate.annotation(
61 crate = "capnpc",
62 gen_binaries = ["capnpc-rust"],
63)
64crate.from_cargo(
65 # TODO(cleanup): This name is a bit misleading now that we don't vendor. We can clean it up as a
66 # followup.
67 name = "crates_vendor",
68 cargo_lockfile = "//deps/rust:Cargo.lock",
69 manifests = ["//deps/rust:Cargo.toml"],
70 supported_platform_triples = RUST_TARGET_TRIPLES,
71)
72use_repo(
73 crate,
74 "crates_vendor",
75)