Skip to content

Commit

Permalink
bazel: Switch to Materialize rules_rust fork (#31459)
Browse files Browse the repository at this point in the history
Stacked on top of:
#31458

This PR switches to our fork of `rules_rust` to include two PRs I merged
upstream. The reason we don't use the upstream version is because the
versions of `rules_rust` that released with these PRs have issues, and I
haven't yet debugged them.

The two PRs we pickup make LTO builds faster, and adds support for
clippy.

### Motivation

Make builds faster

### Tips for reviewer

<!--
Leave some tips for your reviewer, like:

    * The diff is much smaller if viewed with whitespace hidden.
    * [Some function/module/file] deserves extra attention.
* [Some function/module/file] is pure code movement and only needs a
skim.

Delete this section if no tips.
-->

### Checklist

- [ ] This PR has adequate test coverage / QA involvement has been duly
considered. ([trigger-ci for additional test/nightly
runs](https://trigger-ci.dev.materialize.com/))
- [ ] This PR has an associated up-to-date [design
doc](https://github.com/MaterializeInc/materialize/blob/main/doc/developer/design/README.md),
is a design doc
([template](https://github.com/MaterializeInc/materialize/blob/main/doc/developer/design/00000000_template.md)),
or is sufficiently small to not require a design.
  <!-- Reference the design in the description. -->
- [ ] If this PR evolves [an existing `$T ⇔ Proto$T`
mapping](https://github.com/MaterializeInc/materialize/blob/main/doc/developer/command-and-response-binary-encoding.md)
(possibly in a backwards-incompatible way), then it is tagged with a
`T-proto` label.
- [ ] If this PR will require changes to cloud orchestration or tests,
there is a companion cloud PR to account for those changes that is
tagged with the release-blocker label
([example](MaterializeInc/cloud#5021)).
<!-- Ask in #team-cloud on Slack if you need help preparing the cloud
PR. -->
- [ ] If this PR includes major [user-facing behavior
changes](https://github.com/MaterializeInc/materialize/blob/main/doc/developer/guide-changes.md#what-changes-require-a-release-note),
I have pinged the relevant PM to schedule a changelog post.
  • Loading branch information
ParkMyCar authored Feb 11, 2025
1 parent 3628723 commit 99916e7
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
5 changes: 2 additions & 3 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ build:release --compilation_mode=opt
# We only enable Link Time Optimization for CI builds and not local release builds.
build:release-lto --copt=-flto=thin
build:release-lto --linkopt=-flto=thin
build:release-lto --@rules_rust//:extra_rustc_flag=-Clto=thin
build:release-lto --@rules_rust//rust/settings:lto=thin

# Builds from `main` or tagged builds.
#
Expand All @@ -191,8 +191,7 @@ build:optimized --config=debuginfo-none

build:optimized --copt=-fno-lto
build:optimized --linkopt=-fno-lto
build:optimized --@rules_rust//:extra_rustc_flag=-Clto=off
build:optimized --@rules_rust//:extra_rustc_flag=-Cembed-bitcode=no
build:optimized --@rules_rust//rust/settings:lto=off

# Build with the Rust Nightly Toolchain
build:rust-nightly --@rules_rust//rust/toolchain/channel=nightly
Expand Down
20 changes: 16 additions & 4 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -312,17 +312,17 @@ c_repositories()
# Rules for building Rust crates, and several convienence macros for building all transitive
# dependencies.

RULES_RUST_VERSION = "0.54.1"
RULES_RUST_VERSION = "0.54.2"

RULES_RUST_INTEGRITY = "sha256-r09Wyq5QqZpov845sUG1Cd1oVIyCBLmKt6HK/JTVuwI="
RULES_RUST_INTEGRITY = "sha256-6hXbBNIbd6EvuBc/B5RMmAEhxLy5cs8EGuHpjqwjcz4="

maybe(
http_archive,
name = "rules_rust",
integrity = RULES_RUST_INTEGRITY,
strip_prefix = "rules_rust-v{0}".format(RULES_RUST_VERSION),
urls = [
"https://github.com/bazelbuild/rules_rust/releases/download/{0}/rules_rust-v{0}.tar.gz".format(RULES_RUST_VERSION),
"https://mirror.bazel.build/bazelbuild/rules_rust/releases/download/{0}/rules_rust-v{0}.tar.gz".format(RULES_RUST_VERSION),
"https://github.com/MaterializeInc/rules_rust/releases/download/v{0}/rules_rust-v{0}.tar.zst".format(RULES_RUST_VERSION),
],
)

Expand Down Expand Up @@ -559,6 +559,18 @@ crates_repository(
},
cargo_config = "//:.cargo/config.toml",
cargo_lockfile = "//:Cargo.lock",
generator_urls = {
"aarch64-apple-darwin": "https://github.com/MaterializeInc/rules_rust/releases/download/v{0}/cargo-bazel-aarch64-apple-darwin".format(RULES_RUST_VERSION),
"x86_64-apple-darwin": "https://github.com/MaterializeInc/rules_rust/releases/download/v{0}/cargo-bazel-x86_64-apple-darwin".format(RULES_RUST_VERSION),
"aarch64-unknown-linux-gnu": "https://github.com/MaterializeInc/rules_rust/releases/download/v{0}/cargo-bazel-aarch64-unknown-linux-gnu".format(RULES_RUST_VERSION),
"x86_64-unknown-linux-gnu": "https://github.com/MaterializeInc/rules_rust/releases/download/v{0}/cargo-bazel-x86_64-unknown-linux-gnu".format(RULES_RUST_VERSION),
},
generator_sha256s = {
"aarch64-apple-darwin": "8204746334a17823bd6a54ce2c3821b0bdca96576700d568e2ca2bd8224dc0ea",
"x86_64-apple-darwin": "2ee14b230d32c05415852b7a388b76e700c87c506459e5b31ced19d6c131b6d0",
"aarch64-unknown-linux-gnu": "3792feb084bd43b9a7a9cd75be86ee9910b46db59360d6b29c9cca2f8889a0aa",
"x86_64-unknown-linux-gnu": "2b9d07f34694f63f0cc704989ad6ec148ff8d126579832f4f4d88edea75875b2",
},
# When `isolated` is true, Bazel will create a new `$CARGO_HOME`, i.e. it
# won't use `~/.cargo`, when re-pinning. This is nice but not totally
# necessary, and it makes re-pinning painfully slow, so we disable it.
Expand Down
12 changes: 12 additions & 0 deletions misc/bazel/rust_deps/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ def rust_repositories():
"x86_64-apple-darwin",
"wasm32-unknown-unknown",
],
generator_urls = {
"aarch64-apple-darwin": "https://github.com/MaterializeInc/rules_rust/releases/download/v0.54.2/cargo-bazel-aarch64-apple-darwin",
"x86_64-apple-darwin": "https://github.com/MaterializeInc/rules_rust/releases/download/v0.54.2/cargo-bazel-x86_64-apple-darwin",
"aarch64-unknown-linux-gnu": "https://github.com/MaterializeInc/rules_rust/releases/download/v0.54.2/cargo-bazel-aarch64-unknown-linux-gnu",
"x86_64-unknown-linux-gnu": "https://github.com/MaterializeInc/rules_rust/releases/download/v0.54.2/cargo-bazel-x86_64-unknown-linux-gnu",
},
generator_sha256s = {
"aarch64-apple-darwin": "8204746334a17823bd6a54ce2c3821b0bdca96576700d568e2ca2bd8224dc0ea",
"x86_64-apple-darwin": "2ee14b230d32c05415852b7a388b76e700c87c506459e5b31ced19d6c131b6d0",
"aarch64-unknown-linux-gnu": "3792feb084bd43b9a7a9cd75be86ee9910b46db59360d6b29c9cca2f8889a0aa",
"x86_64-unknown-linux-gnu": "2b9d07f34694f63f0cc704989ad6ec148ff8d126579832f4f4d88edea75875b2",
},
isolated = False,
# Only used if developing rules_rust.
# generator = "@cargo_bazel_bootstrap//:cargo-bazel",
Expand Down

0 comments on commit 99916e7

Please sign in to comment.