@@ -33,8 +33,7 @@ bazel_dep(name = "rules_proto_grpc_doc", version = "5.6.0")
3333bazel_dep (name = "rules_proto_grpc_java" , version = "5.6.0" )
3434bazel_dep (name = "rules_proto_grpc_python" , version = "5.6.0" )
3535bazel_dep (name = "rules_python" , version = "1.6.3" )
36- bazel_dep (name = "rules_rust" , version = "0.69.0" )
37- bazel_dep (name = "rules_rust_prost" , version = "0.69.0" )
36+ bazel_dep (name = "rules_rs" , version = "0.0.94" )
3837bazel_dep (name = "rules_shell" , version = "0.6.1" )
3938bazel_dep (name = "aspect_rules_py" , version = "1.8.4" )
4039bazel_dep (name = "toolchains_protoc" , version = "0.4.3" )
@@ -63,10 +62,12 @@ single_version_override(
6362 version = "1.19.1" ,
6463)
6564
66- # Patch gRPC v1.74.1 to fix RBE build with strict header checking.
67- # The issue: xds_route_config target is missing upb library dependencies,
68- # which causes undeclared inclusion errors for envoy upb-generated headers
69- # when building with RBE's strict header checking.
65+ # grpc is pulled in transitively by rules_proto_grpc_*. Pin and patch it to match
66+ # the monorepo. The upb-gen include-shadowing patch drops grpc's committed
67+ # upb-gen include dirs, which otherwise shadow protobuf's generated upb headers
68+ # and cause "undeclared inclusion" failures under strict header checking (e.g.
69+ # when compiling cygrpc). The rbe_xds patch supplies header deps needed for
70+ # RBE + xDS builds.
7071single_version_override (
7172 module_name = "grpc" ,
7273 patch_strip = 0 ,
@@ -214,57 +215,40 @@ RUST_EDITION = "2024"
214215
215216RUST_VERSION = "1.94.1"
216217
217- rust = use_extension ("@rules_rust//rust:extensions.bzl" , "rust" )
218- rust .toolchain (
218+ # rules_rs provides hermetic Rust toolchains and the patched rules_rust facade.
219+ rs_toolchains = use_extension ("@rules_rs//rs/toolchains:module_extension.bzl" , "toolchains" )
220+ rs_toolchains .toolchain (
219221 edition = RUST_EDITION ,
220- extra_exec_rustc_flags = ["-Clink-self-contained=no" ],
221- extra_rustc_flags = ["-Clink-self-contained=no" ],
222- versions = [RUST_VERSION ],
222+ # -Clink-self-contained=no: link with the registered cc toolchain's linker.
223+ # rules_rs's rustc does not ship the self-contained linker (rust-lld) in its
224+ # sysroot, so self-contained linking (the default) fails for tool/bin targets.
225+ extra_exec_rustc_flags = {
226+ "x86_64-unknown-linux-gnu" : ["-Clink-self-contained=no" ],
227+ },
228+ extra_rustc_flags = {
229+ "x86_64-unknown-linux-gnu" : ["-Clink-self-contained=no" ],
230+ },
231+ version = RUST_VERSION ,
223232)
224- use_repo (rust , "rust_toolchains " )
233+ use_repo (rs_toolchains , "default_rust_toolchains " )
225234
226- register_toolchains ("@rust_toolchains//:all" )
235+ # Re-export the pinned, patched @rules_rust so existing @rules_rust// loads keep
236+ # working. rules_rs bundles the prost extension under @rules_rust//extensions/prost.
237+ rules_rust = use_extension ("@rules_rs//rs:rules_rust.bzl" , "rules_rust" )
238+ use_repo (rules_rust , "rules_rust" )
239+
240+ register_toolchains ("@default_rust_toolchains//:all" )
227241
228242register_toolchains (
229243 "//api/build_tools/prost_toolchain" ,
230244)
231245
232- # All of these crates come from crates.io, hence the "crates_io" name.
233- # The "st_" (spacetime) prefix is required to avoid a collision with the
234- # nmts submodule, which defines its own "crates_io" (and "crates") repo:
235- # rules_rust's crate extension is shared across the whole module graph,
236- # so two modules generating a repo of the same name would error.
237- crate = use_extension ("@rules_rust//crate_universe:extension.bzl" , "crate" )
238- crate .spec (
239- package = "prost" ,
240- version = "0.14.3" ,
241- )
242- crate .spec (
243- default_features = False ,
244- package = "prost-types" ,
245- version = "0.14.3" ,
246- )
247- crate .spec (
248- package = "protoc-gen-prost" ,
249- version = "0.5.0" ,
250- )
251- crate .spec (
252- package = "protoc-gen-tonic" ,
253- version = "0.5.0" ,
254- )
255- crate .spec (
256- features = ["transport" ],
257- package = "tonic" ,
258- version = "0.14.4" ,
259- )
260- crate .spec (
261- package = "tonic-build" ,
262- version = "0.14.4" ,
263- )
264- crate .spec (
265- package = "tonic-prost" ,
266- version = "0.14.4" ,
267- )
246+ # Rust crate dependencies via rules_rs crate_universe (from_cargo). The
247+ # dependency set lives in Cargo.toml / Cargo.lock (rules_rs supports only
248+ # from_cargo). The "st_" (spacetime) prefix keeps this hub distinct from the
249+ # nmts submodule's crate hub: the crate extension is shared across the module
250+ # graph, so two hubs of the same name would collide.
251+ crate = use_extension ("@rules_rs//rs:extensions.bzl" , "crate" )
268252crate .annotation (
269253 crate = "protoc-gen-prost" ,
270254 gen_binaries = ["protoc-gen-prost" ],
@@ -273,10 +257,13 @@ crate.annotation(
273257 crate = "protoc-gen-tonic" ,
274258 gen_binaries = ["protoc-gen-tonic" ],
275259)
276- crate .from_specs (
277- name = "st_crates_io" ,
260+ crate .from_cargo (
261+ name = "st_crates" ,
262+ cargo_lock = "//:Cargo.lock" ,
263+ cargo_toml = "//:Cargo.toml" ,
264+ platform_triples = ["x86_64-unknown-linux-gnu" ],
278265)
279- use_repo (crate , "st_crates_io " )
266+ use_repo (crate , "st_crates " )
280267
281268bazel_dep (name = "org_outernetcouncil_nmts" )
282269archive_override (
0 commit comments