Skip to content

Commit 4d53d9e

Browse files
authored
Fix examples with Bazel@HEAD (#658)
This PR fixes multiple errors from [the Downstream](https://buildkite.com/bazel/bazel-at-head-plus-downstream/builds/5194#_): 1. Error with catch2 (mentioned in #657) - Fix is updating its version. 2. Error with loads in toolchains_llvm - Fix is updating its version. 3. Error with toolchains_protoc (`name 'proto_library' is not defined`) - Fix is removing `toolchains_protoc` since it was overriding an incompatible version of toolchain. 4. Error with `incompatible_use_toolchain_transition` - Seemed to be fixed with upgrade of toolchains_llvm. Also, updated links for documentation which were not working.
1 parent 2a8db58 commit 4d53d9e

File tree

10 files changed

+32
-52
lines changed

10 files changed

+32
-52
lines changed

rust-examples/.bazelversion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8.1.1
1+
9.*

rust-examples/02-hello-cross/MODULE.bazel

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ module(
66
###############################################################################
77
# B A Z E L D E P E N D E N C I E S # https://registry.bazel.build/
88
###############################################################################
9-
bazel_dep(name = "rules_rust", version = "0.65.0")
9+
bazel_dep(name = "rules_rust", version = "0.68.1")
1010
bazel_dep(name = "platforms", version = "0.0.11")
1111

12-
bazel_dep(name = "toolchains_llvm", version = "1.2.0", dev_dependency = True)
12+
bazel_dep(name = "toolchains_llvm", version = "1.6.0", dev_dependency = True)
1313

1414
###############################################################################
1515
# Small (clang) LLVM toolchain
@@ -38,24 +38,14 @@ http_archive(
3838

3939
llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm")
4040
llvm.toolchain(
41-
llvm_version = "19.1.6-1",
42-
sha256 = {
43-
# Generate checksums with shasum -a 256 filename.tar.zst
44-
"darwin-aarch64": "94ed965925dbdc25b29e6fcfa9a84b28d915d5c9da7c71405fc20bbcf8396bd1",
45-
"darwin-x86_64": "9395b07fd5018816bcaee84522d9c9386fdbefe62fdf8afff89b57e1b7095463",
46-
"linux-aarch64": "24fd3405f65ccbc39f0d14a5126ee2edb5904d7a9525ae483f34a510a1bdce3e",
47-
"linux-x86_64": "bad3d776c222c99056eba8b64c085a1e08edd783cb102e1b6eba43b78ce2fe2b",
48-
},
49-
stdlib = {
50-
"linux-x86_64": "stdc++",
51-
"linux-aarch64": "stdc++",
52-
},
53-
urls = {
54-
"darwin-aarch64": ["https://github.com/MaterializeInc/toolchains/releases/download/clang-19.1.6-1/darwin_aarch64.tar.zst"],
55-
"darwin-x86_64": ["https://github.com/MaterializeInc/toolchains/releases/download/clang-19.1.6-1/darwin_x86_64.tar.zst"],
56-
"linux-aarch64": ["https://github.com/MaterializeInc/toolchains/releases/download/clang-19.1.6-1/linux_aarch64.tar.zst"],
57-
"linux-x86_64": ["https://github.com/MaterializeInc/toolchains/releases/download/clang-19.1.6-1/linux_x86_64.tar.zst"],
41+
name = "llvm_toolchain",
42+
extra_llvm_distributions = {
43+
"LLVM-20.1.4-Linux-ARM64.tar.xz": "4de80a332eecb06bf55097fd3280e1c69ed80f222e5bdd556221a6ceee02721a",
44+
"LLVM-20.1.4-Linux-X64.tar.xz": "113b54c397adb2039fa45e38dc8107b9ec5a0baead3a3bac8ccfbb65b2340caa",
45+
"LLVM-20.1.4-macOS-ARM64.tar.xz": "debb43b7b364c5cf864260d84ba1b201d49b6460fe84b76eaa65688dfadf19d2",
46+
"clang+llvm-20.1.4-x86_64-pc-windows-msvc.tar.xz": "2b12ac1a0689e29a38a7c98c409cbfa83f390aea30c60b7a06e4ed73f82d2457",
5847
},
48+
llvm_version = "20.1.4",
5949
)
6050
llvm.sysroot(
6151
name = "llvm_toolchain",

rust-examples/02-hello-cross/README.md

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ You add the required rules for cross compilation to your MODULE.bazel as shown b
4040
# https://github.com/bazelbuild/platforms/releases
4141
bazel_dep(name = "platforms", version = "0.0.10")
4242
# https://github.com/bazel-contrib/toolchains_llvm
43-
bazel_dep(name = "toolchains_llvm", version = "1.2.0", dev_dependency = True)
43+
bazel_dep(name = "toolchains_llvm", version = "1.6.0", dev_dependency = True)
4444
```
4545

4646
## LLVM Configuration
@@ -89,24 +89,14 @@ needs to be configured and to do that, please add the following to your MODULE.b
8989
```Starlark
9090
llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm")
9191
llvm.toolchain(
92-
llvm_version = "19.1.6-1",
93-
sha256 = {
94-
# Generate checksums with shasum -a 256 filename.tar.zst
95-
"darwin-aarch64": "",
96-
"darwin-x86_64": "",
97-
"linux-aarch64": "",
98-
"linux-x86_64": "",
99-
},
100-
stdlib = {
101-
"linux-x86_64": "stdc++",
102-
"linux-aarch64": "stdc++",
103-
},
104-
urls = {
105-
"darwin-aarch64": ["https://github.com/MaterializeInc/toolchains/releases/download/clang-19.1.6-1/darwin_aarch64.tar.zst"],
106-
"darwin-x86_64": ["https://github.com/MaterializeInc/toolchains/releases/download/clang-19.1.6-1/darwin_x86_64.tar.zst"],
107-
"linux-aarch64": ["https://github.com/MaterializeInc/toolchains/releases/download/clang-19.1.6-1/linux_aarch64.tar.zst"],
108-
"linux-x86_64": ["https://github.com/MaterializeInc/toolchains/releases/download/clang-19.1.6-1/linux_x86_64.tar.zst"],
92+
name = "llvm_toolchain",
93+
extra_llvm_distributions = {
94+
"LLVM-20.1.4-Linux-ARM64.tar.xz": "4de80a332eecb06bf55097fd3280e1c69ed80f222e5bdd556221a6ceee02721a",
95+
"LLVM-20.1.4-Linux-X64.tar.xz": "113b54c397adb2039fa45e38dc8107b9ec5a0baead3a3bac8ccfbb65b2340caa",
96+
"LLVM-20.1.4-macOS-ARM64.tar.xz": "debb43b7b364c5cf864260d84ba1b201d49b6460fe84b76eaa65688dfadf19d2",
97+
"clang+llvm-20.1.4-x86_64-pc-windows-msvc.tar.xz": "2b12ac1a0689e29a38a7c98c409cbfa83f390aea30c60b7a06e4ed73f82d2457",
10998
},
99+
llvm_version = "20.1.4",
110100
)
111101
llvm.sysroot(
112102
name = "llvm_toolchain",

rust-examples/08-grpc-client-server/MODULE.bazel

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ bazel_dep(name = "rules_rust_prost", version = "0.65.0")
1313
bazel_dep(name = "rules_proto", version = "7.1.0")
1414

1515
# Toolchains
16-
bazel_dep(name = "toolchains_protoc", version = "0.3.7", dev_dependency = True)
17-
bazel_dep(name = "toolchains_llvm", version = "1.2.0", dev_dependency = True)
16+
bazel_dep(name = "toolchains_llvm", version = "1.6.0", dev_dependency = True)
1817

1918
###############################################################################
2019
# Small (clang) LLVM toolchain

rust-examples/08-grpc-client-server/README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ bazel_dep(name = "rules_rust_prost", version = "0.57.1")
6060
bazel_dep(name = "rules_proto", version = "7.1.0")
6161

6262
# Toolchains
63-
bazel_dep(name = "toolchains_protoc", version = "0.3.7", dev_dependency = True)
64-
bazel_dep(name = "toolchains_llvm", version = "1.2.0", dev_dependency = True)
63+
bazel_dep(name = "toolchains_llvm", version = "1.6.0", dev_dependency = True)
6564
```
6665

6766
### Configure clang/LLVM
@@ -231,7 +230,7 @@ load("@rules_proto//proto:defs.bzl", "proto_library")
231230
load("@rules_rust_prost//:defs.bzl", "rust_prost_library")
232231

233232
# Build proto files
234-
# https://bazelbuild.github.io/rules_rust/rust_proto.html#rust_proto_library
233+
# https://bazelbuild.github.io/rules_rust/rust_prost.html#rust_proto_library
235234
proto_library(
236235
name = "proto_bindings",
237236
srcs = [
@@ -240,7 +239,7 @@ proto_library(
240239
)
241240

242241
# Generate Rust bindings from the generated proto files
243-
# https://bazelbuild.github.io/rules_rust/rust_proto.html#rust_prost_library
242+
# https://bazelbuild.github.io/rules_rust/rust_prost.html#rust_prost_library
244243
rust_prost_library(
245244
name = "rust_proto",
246245
proto = ":proto_bindings",

rust-examples/08-grpc-client-server/proto_bindings/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ load("@rules_proto//proto:defs.bzl", "proto_library")
22
load("@rules_rust_prost//:defs.bzl", "rust_prost_library")
33

44
# Build proto files
5-
# https://bazelbuild.github.io/rules_rust/rust_proto.html#rust_proto_library
5+
# https://bazelbuild.github.io/rules_rust/rust_prost.html#rust_proto_library
66
proto_library(
77
name = "proto_bindings",
88
srcs = [
@@ -11,7 +11,7 @@ proto_library(
1111
)
1212

1313
# Generate Rust bindings from the generated proto files
14-
# https://bazelbuild.github.io/rules_rust/rust_proto.html#rust_prost_library
14+
# https://bazelbuild.github.io/rules_rust/rust_prost.html#rust_prost_library
1515
rust_prost_library(
1616
name = "rust_proto",
1717
proto = ":proto_bindings",

rust-examples/09-oci-container/MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ bazel_dep(name = "rules_rust", version = "0.65.0")
1111
bazel_dep(name = "rules_oci", version = "2.2.6")
1212
bazel_dep(name = "rules_pkg", version = "1.0.1")
1313

14-
bazel_dep(name = "toolchains_llvm", version = "1.2.0", dev_dependency = True)
14+
bazel_dep(name = "toolchains_llvm", version = "1.6.0", dev_dependency = True)
1515

1616
###############################################################################
1717
# Small (clang) LLVM toolchain

rust-examples/09-oci-container/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,15 @@ also use the LLVM toolchain to keep the build hermetic.
4949

5050
```Starlark
5151
# https://github.com/bazel-contrib/toolchains_llvm
52-
bazel_dep(name = "toolchains_llvm", version = "1.0.0")
52+
bazel_dep(name = "toolchains_llvm", version = "1.6.0", dev_dependency = True)
5353

5454
# OCI Container rules
55+
# https://github.com/bazelbuild/rules_rust/releases
56+
bazel_dep(name = "rules_rust", version = "0.65.0")
5557
# https://github.com/bazel-contrib/rules_oci/releases
56-
bazel_dep(name = "rules_oci", version = "1.7.6")
58+
bazel_dep(name = "rules_oci", version = "2.2.6")
5759
# https://github.com/bazelbuild/rules_pkg/releases
58-
bazel_dep(name = "rules_pkg", version = "0.10.1")
60+
bazel_dep(name = "rules_pkg", version = "1.0.1")
5961
```
6062

6163
The LLVM toolchain is configured just as in the previous example for

rust-examples/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ Links:
126126

127127
Documentation:
128128
* [rules_rust](https://bazelbuild.github.io/rules_rust/)
129-
* [rust_proto](https://bazelbuild.github.io/rules_rust/rust_proto.html#rust_proto_libraryhttps://bazelbuild.github.io/rules_rust/rust_proto.html#rust_proto_library)
129+
* [rust_prost](https://bazelbuild.github.io/rules_rust/rust_prost.html#rust_proto_library)
130130
* [Protocol Buffers](https://protobuf.dev/)
131131

132132

third-party-dependencies/MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
bazel_dep(name = "buildifier_prebuilt", version = "6.3.3", dev_dependency = True)
44

55
bazel_dep(name = "rules_cc", version = "0.2.8")
6-
bazel_dep(name = "catch2", version = "3.4.0")
6+
bazel_dep(name = "catch2", version = "3.12.0")
77
bazel_dep(name = "googletest", version = "1.17.0.bcr.2", repo_name = "gtest")

0 commit comments

Comments
 (0)