Skip to content

Commit 300dff1

Browse files
thunderseethecopybara-github
authored andcommitted
Add rust and llvm toolchains in MODULE.bazel.
Update rules to more recent versions. Update .bazelversion. PiperOrigin-RevId: 846345379
1 parent 4668306 commit 300dff1

File tree

5 files changed

+53
-23
lines changed

5 files changed

+53
-23
lines changed

.bazelversion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.6.0
1+
8.5.0

MODULE.bazel

Lines changed: 49 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,43 +4,73 @@
44

55
# TODO: this needs to be paired with a refreshed patch
66
# (see WORKSPACE.bzlmod)
7-
bazel_dep(name = "rules_rust", version = "0.63.0")
8-
9-
bazel_dep(name = "rules_cc", version = "0.2.0")
10-
bazel_dep(name = "rules_shell", version = "0.5.1")
11-
7+
bazel_dep(name = "rules_rust", version = "0.68.1")
8+
bazel_dep(name = "rules_cc", version = "0.2.8")
9+
bazel_dep(name = "rules_shell", version = "0.6.1")
1210
bazel_dep(name = "abseil-cpp", version = "20250127.1")
13-
git_override( # with nullability support
11+
git_override(
12+
# with nullability support
1413
module_name = "abseil-cpp",
1514
commit = "e3a2008867c5dc5c0f4c7a4e64fb568df70f23be",
1615
remote = "https://github.com/abseil/abseil-cpp",
1716
)
1817

19-
bazel_dep(name = "bazel_skylib", version = "1.8.1")
18+
bazel_dep(name = "bazel_skylib", version = "1.8.2")
2019
bazel_dep(name = "fuzztest", version = "20250214.0")
2120
bazel_dep(name = "google_benchmark", version = "1.9.1")
2221
bazel_dep(name = "googletest", version = "1.17.0")
23-
bazel_dep(name = "platforms", version = "0.0.11")
24-
bazel_dep(name = "protobuf", version = "31.1")
22+
bazel_dep(name = "platforms", version = "1.0.0")
23+
bazel_dep(name = "protobuf", version = "33.1")
2524
bazel_dep(name = "re2", version = "2024-07-02.bcr.1")
2625
bazel_dep(name = "rules_license", version = "1.0.0")
2726
bazel_dep(name = "rules_proto", version = "7.1.0")
28-
bazel_dep(name = "rules_python", version = "1.5.3")
27+
bazel_dep(name = "rules_python", version = "1.6.0")
28+
29+
# TODO: Update this to 1.6.0 once bug in bazel 8.5.0rc1 is fixed.
30+
bazel_dep(name = "toolchains_llvm", version = "1.5.0")
31+
2932
# We don't directly use rules_foreign_cc, but *something* does, and depends on an
3033
# out of date version that doesn't work with newer Bazel releases. So here we force
3134
# it to be a newer version.
3235
bazel_dep(name = "rules_foreign_cc", version = "0.15.0")
3336

34-
crate = use_extension("@rules_rust//crate_universe:extensions.bzl", "crate")
37+
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
38+
rust.toolchain(
39+
allocator_library = "@rules_rust//ffi/rs:empty",
40+
dev_components = True,
41+
edition = "2021",
42+
versions = ["nightly/2025-11-20"],
43+
)
3544

45+
crate = use_extension("@rules_rust//crate_universe:extensions.bzl", "crate")
3646
crate.from_cargo(
37-
name = "crate_index",
38-
manifests = [
39-
"//:Cargo.toml",
40-
"//:cargo/cc_bindings_from_rs/cc_bindings_from_rs/Cargo.toml",
41-
"//:cargo/rs_bindings_from_cc/rs_bindings_from_cc/Cargo.toml",
42-
"//support/ffi_11:Cargo.toml",
43-
],
47+
name = "crate_index",
48+
manifests = [
49+
"//:Cargo.toml",
50+
],
4451
)
52+
use_repo(crate, "crate_index")
53+
54+
llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm")
4555

46-
use_repo(crate, "crate_index")
56+
# We install this toolchain to provide access to clang-format, but it also becomes our cc_toolchain.
57+
# Being our cc_toolchain means we need this to be a version of LLVM that's compatible with our Rust
58+
# toolchain, so we pin to a specific version from github (rather than rely on the versions provided
59+
# by default in the rules).
60+
llvm.toolchain(
61+
extra_llvm_distributions = {
62+
"clang+llvm-21.1.8-x86_64-pc-windows-msvc.tar.xz": "749d22f565fcd5718dbed06512572d0e5353b502c03fe1f7f17ee8b8aca21a47",
63+
"LLVM-21.1.8-Linux-ARM64.tar.xz": "65ce0b329514e5643407db2d02a5bd34bf33d159055dafa82825c8385bd01993",
64+
"LLVM-21.1.8-Linux-X64.tar.xz": "b3b7f2801d15d50736acea3c73982994d025b01c2f035b91ae3b49d1b575732b",
65+
"LLVM-21.1.8-macOS-ARM64.tar.xz": "b95bdd32a33a81ee4d40363aaeb26728a26783fcef26a4d80f65457433ea4669",
66+
},
67+
llvm_version = "21.1.8",
68+
)
69+
use_repo(llvm, "llvm_toolchain")
70+
71+
register_toolchains(
72+
"@llvm_toolchain//:all",
73+
"//common/bazel_support/toolchains:cc_bindings_from_rs_on_demand_linux",
74+
"//common/bazel_support/toolchains:cc_bindings_from_rs_on_demand_macos",
75+
"//common/bazel_support/toolchains:cc_bindings_from_rs_on_demand_ios",
76+
)

cc_bindings_from_rs/bazel_support/cc_bindings_from_rust_rule.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ cc_bindings_from_rust_aspect = aspect(
415415
attr_aspects = ["deps"],
416416
attrs = {
417417
"_clang_format": attr.label(
418-
default = Label("@llvm_toolchain//:clang-format"),
418+
default = Label("@llvm_toolchain//:bin/clang-format"),
419419
executable = True,
420420
allow_single_file = True,
421421
cfg = "exec",

rs_bindings_from_cc/bazel_support/rust_bindings_from_cc_binary.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ rust_bindings_from_cc_binary = rule(
4141
"C++ code."),
4242
),
4343
"_clang_format": attr.label(
44-
default = Label("@llvm_toolchain//:clang-format"),
44+
default = Label("@llvm_toolchain//:bin/clang-format"),
4545
executable = True,
4646
allow_single_file = True,
4747
cfg = "exec",

rs_bindings_from_cc/bazel_support/rust_bindings_from_cc_utils.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ bindings_attrs = {
210210
default = "@@//rs_bindings_from_cc/bazel_support:deps_for_bindings",
211211
),
212212
"_clang_format": attr.label(
213-
default = Label("@llvm_toolchain//:clang-format"),
213+
default = Label("@llvm_toolchain//:bin/clang-format"),
214214
executable = True,
215215
allow_single_file = True,
216216
cfg = "exec",

0 commit comments

Comments
 (0)