Skip to content

Commit

Permalink
[bazel] update rules_rust to 0.56
Browse files Browse the repository at this point in the history
This version splits bindgen to a separate extension, so rename accordingly.

Updating rules_rust_bindgen pulls in a new version of bindgen which requires
a higher Rust version then what we currently use. So update Rust to 1.83,
which is the default version used in rules_rust 0.56. Similarly, the nightly
version is updated to 2024-11-28 which is the default nightly for rules_rust
0.56.

Signed-off-by: Gary Guo <[email protected]>
  • Loading branch information
nbdd0121 committed Jan 15, 2025
1 parent a6c89d0 commit 702b5a2
Show file tree
Hide file tree
Showing 13 changed files with 992 additions and 13,454 deletions.
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ bazel_dep(name = "abseil-cpp", version = "20240116.1")
bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "googletest", version = "1.14.0.bcr.1")
bazel_dep(name = "platforms", version = "0.0.10")
bazel_dep(name = "rules_cc", version = "0.0.14")
bazel_dep(name = "rules_cc", version = "0.0.17")
bazel_dep(name = "rules_fuzzing", version = "0.5.2")
bazel_dep(name = "rules_pkg", version = "1.0.1")

Expand Down
14,321 changes: 917 additions & 13,404 deletions MODULE.bazel.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion sw/host/hsmtool/acorn/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# SPDX-License-Identifier: Apache-2.0

load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test")
load("@rules_rust//bindgen:defs.bzl", "rust_bindgen_library")
load("@rules_rust_bindgen//:defs.bzl", "rust_bindgen_library")

package(default_visibility = ["//visibility:public"])

Expand Down
2 changes: 1 addition & 1 deletion sw/host/hsmtool/acorn/vendor/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0

load("@rules_rust//bindgen:defs.bzl", "rust_bindgen_library")
load("@rules_rust_bindgen//:defs.bzl", "rust_bindgen_library")

package(default_visibility = ["//visibility:public"])

Expand Down
2 changes: 1 addition & 1 deletion sw/host/opentitanlib/bindgen/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# SPDX-License-Identifier: Apache-2.0

load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test")
load("@rules_rust//bindgen:defs.bzl", "rust_bindgen", "rust_bindgen_library")
load("@rules_rust_bindgen//:defs.bzl", "rust_bindgen", "rust_bindgen_library")

package(default_visibility = ["//visibility:public"])

Expand Down
2 changes: 0 additions & 2 deletions sw/host/opentitanlib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0

// Stabilised in Rust 1.74, can be removed when we upgrade.
#![feature(io_error_other)]
// Used for serde_annotate.
#![feature(min_specialization)]

Expand Down
2 changes: 1 addition & 1 deletion sw/host/provisioning/perso_tlv_lib/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0

load("@rules_rust//bindgen:defs.bzl", "rust_bindgen_library")
load("@rules_rust_bindgen//:defs.bzl", "rust_bindgen_library")
load("@rules_rust//rust:defs.bzl", "rust_library")

package(default_visibility = ["//visibility:public"])
Expand Down
2 changes: 1 addition & 1 deletion sw/host/sphincsplus/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0

load("@rules_rust//bindgen:defs.bzl", "rust_bindgen_library")
load("@rules_rust_bindgen//:defs.bzl", "rust_bindgen_library")
load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test")

package(default_visibility = ["//visibility:public"])
Expand Down
2 changes: 1 addition & 1 deletion sw/host/tests/xmodem/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# SPDX-License-Identifier: Apache-2.0

load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test")
load("@rules_rust//bindgen:defs.bzl", "rust_bindgen_library")
load("@rules_rust_bindgen//:defs.bzl", "rust_bindgen_library")

package(default_visibility = ["//visibility:public"])

Expand Down
6 changes: 3 additions & 3 deletions third_party/rust/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# SPDX-License-Identifier: Apache-2.0

load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
load("@rules_rust//bindgen:defs.bzl", "rust_bindgen_toolchain")
load("@rules_rust_bindgen//:defs.bzl", "rust_bindgen_toolchain")
load("@rules_cc//cc:defs.bzl", "cc_import")

package(default_visibility = ["//visibility:public"])
Expand Down Expand Up @@ -35,7 +35,7 @@ cc_import(

rust_bindgen_toolchain(
name = "bindgen_toolchain_impl",
bindgen = "@rules_rust//bindgen/3rdparty:bindgen",
bindgen = "@rules_rust_bindgen//3rdparty:bindgen",
clang = "@llvm_toolchain_llvm//:bin/clang",
libclang = ":libclang",
libstdcxx = ":libc++",
Expand All @@ -44,5 +44,5 @@ rust_bindgen_toolchain(
toolchain(
name = "bindgen_toolchain",
toolchain = "bindgen_toolchain_impl",
toolchain_type = "@rules_rust//bindgen:toolchain_type",
toolchain_type = "@rules_rust_bindgen//:toolchain_type",
)
6 changes: 3 additions & 3 deletions third_party/rust/patches/rules_rust.bindgen_static_lib.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
diff --git a/bindgen/private/bindgen.bzl b/bindgen/private/bindgen.bzl
--- bindgen/private/bindgen.bzl
+++ bindgen/private/bindgen.bzl
diff --git a/extensions/bindgen/private/bindgen.bzl b/extensions/bindgen/private/bindgen.bzl
--- a/extensions/bindgen/private/bindgen.bzl
+++ b/extensions/bindgen/private/bindgen.bzl
@@ -152,11 +152,6 @@ def _generate_cc_link_build_info(ctx, cc_lib):
linker_search_paths.append(lib.pic_static_library.dirname)
compile_data.append(lib.pic_static_library)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,24 @@ Date: Wed Sep 13 09:56:21 2023 -0700
Signed-off-by: Tim Trippel <[email protected]>

diff --git a/BUILD.bazel b/BUILD.bazel
--- BUILD.bazel
+++ BUILD.bazel
@@ -10,6 +10,7 @@ load(
"extra_exec_rustc_flags",
"extra_rustc_flag",
"extra_rustc_flags",
+ "extra_rustc_toolchain_dirs",
"no_std",
"per_crate_rustc_flag",
"rustc_output_diagnostics",
@@ -94,6 +95,15 @@ per_crate_rustc_flag(
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -72,6 +72,12 @@ alias(
visibility = ["//visibility:public"],
)

+# This setting is to enable passing additional `-B` options to the CC toolchain driver binary to
+# aid in locating toolchain directories on systems where not all toolchain tools are installed in
+# the same system location.
+extra_rustc_toolchain_dirs(
+alias(
+ name = "extra_rustc_toolchain_dirs",
+ build_setting_default = "",
+ actual = "//rust/settings:extra_rustc_toolchain_dirs",
+ visibility = ["//visibility:public"],
+)
+
# This setting is used by the clippy rules. See https://bazelbuild.github.io/rules_rust/rust_clippy.html
label_flag(
alias(
name = "clippy.toml",
actual = "//rust/settings:clippy.toml",
diff --git a/rust/defs.bzl b/rust/defs.bzl
--- rust/defs.bzl
+++ rust/defs.bzl
--- a/rust/defs.bzl
+++ b/rust/defs.bzl
@@ -49,6 +49,7 @@ load(
_extra_exec_rustc_flags = "extra_exec_rustc_flags",
_extra_rustc_flag = "extra_rustc_flag",
Expand All @@ -69,11 +58,11 @@ diff --git a/rust/defs.bzl b/rust/defs.bzl
# See @rules_rust//rust/private:rustc.bzl for a complete description.

diff --git a/rust/private/rust.bzl b/rust/private/rust.bzl
--- rust/private/rust.bzl
+++ rust/private/rust.bzl
@@ -527,6 +527,9 @@ RUSTC_ATTRS = {
--- a/rust/private/rust.bzl
+++ b/rust/private/rust.bzl
@@ -552,6 +552,9 @@ RUSTC_ATTRS = {
"_extra_rustc_flags": attr.label(
default = Label("//:extra_rustc_flags"),
default = Label("//rust/settings:extra_rustc_flags"),
),
+ "_extra_rustc_toolchain_dirs": attr.label(
+ default = Label("//:extra_rustc_toolchain_dirs"),
Expand All @@ -82,9 +71,9 @@ diff --git a/rust/private/rust.bzl b/rust/private/rust.bzl
default = Label("//rust/private:is_proc_macro_dep"),
),
diff --git a/rust/private/rustc.bzl b/rust/private/rustc.bzl
--- rust/private/rustc.bzl
+++ rust/private/rustc.bzl
@@ -78,6 +78,11 @@ PerCrateRustcFlagsInfo = provider(
--- a/rust/private/rustc.bzl
+++ b/rust/private/rustc.bzl
@@ -79,6 +79,11 @@ PerCrateRustcFlagsInfo = provider(
fields = {"per_crate_rustc_flags": "List[string] Extra flags to pass to rustc in non-exec configuration"},
)

Expand All @@ -96,7 +85,7 @@ diff --git a/rust/private/rustc.bzl b/rust/private/rustc.bzl
IsProcMacroDepInfo = provider(
doc = "Records if this is a transitive dependency of a proc-macro.",
fields = {"is_proc_macro_dep": "Boolean"},
@@ -455,6 +460,10 @@ def get_linker_and_args(ctx, attr, crate_type, cc_toolchain, feature_configurati
@@ -449,6 +454,10 @@ def get_linker_and_args(ctx, crate_type, cc_toolchain, feature_configuration, rp
action_name = action_name,
variables = link_variables,
)
Expand All @@ -107,8 +96,8 @@ diff --git a/rust/private/rustc.bzl b/rust/private/rustc.bzl
link_env = cc_common.get_environment_variables(
feature_configuration = feature_configuration,
action_name = action_name,
@@ -2242,6 +2251,19 @@ per_crate_rustc_flag = rule(
build_setting = config.string(flag = True, allow_multiple = True),
@@ -2273,6 +2282,19 @@ per_crate_rustc_flag = rule(
build_setting = config.string_list(flag = True, repeatable = True),
)

+def _extra_rustc_toolchain_dirs_impl(ctx):
Expand All @@ -127,3 +116,31 @@ diff --git a/rust/private/rustc.bzl b/rust/private/rustc.bzl
def _no_std_impl(ctx):
value = str(ctx.attr._no_std[BuildSettingInfo].value)
if is_exec_configuration(ctx):
diff --git a/rust/settings/BUILD.bazel b/rust/settings/BUILD.bazel
--- a/rust/settings/BUILD.bazel
+++ b/rust/settings/BUILD.bazel
@@ -10,6 +10,7 @@ load(
"extra_exec_rustc_flags",
"extra_rustc_flag",
"extra_rustc_flags",
+ "extra_rustc_toolchain_dirs",
"no_std",
"per_crate_rustc_flag",
"rustc_output_diagnostics",
@@ -148,6 +149,15 @@ bool_flag(
visibility = ["//visibility:public"],
)

+# This setting is to enable passing additional `-B` options to the CC toolchain driver binary to
+# aid in locating toolchain directories on systems where not all toolchain tools are installed in
+# the same system location.
+extra_rustc_toolchain_dirs(
+ name = "extra_rustc_toolchain_dirs",
+ build_setting_default = "",
+ visibility = ["//visibility:public"],
+)
+
# This setting is used by the clippy rules. See https://bazelbuild.github.io/rules_rust/rust_clippy.html
label_flag(
name = "clippy.toml",

20 changes: 15 additions & 5 deletions third_party/rust/rust.MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,27 @@
# SPDX-License-Identifier: Apache-2.0

# Dependencies:
bazel_dep(name = "rules_rust", version = "0.49.3")
bazel_dep(name = "rules_rust", version = "0.56.0")
bazel_dep(name = "rules_rust_bindgen", version = "0.56.0")
bazel_dep(name = "toolchains_llvm", version = "1.1.2")

# Overrides and patches:
single_version_override(
module_name = "rules_rust",
patches = [
"//third_party/rust/patches:rules_rust.bindgen_static_lib.patch",
"//third_party/rust/patches:rules_rust.extra_rustc_toolchain_dirs.patch",
],
version = "0.49.3",
patch_strip = 1,
version = "0.56.0",
)

single_version_override(
module_name = "rules_rust_bindgen",
patches = [
"//third_party/rust/patches:rules_rust.bindgen_static_lib.patch",
],
patch_strip = 3,
version = "0.56.0",
)

# Rust toolchain:
Expand All @@ -32,8 +42,8 @@ rust.toolchain(
"2023-07-30/rust-std-nightly-x86_64-unknown-linux-gnu.tar.xz": "b5a589a243923c5fa2a1f08e7b902bb0a64ae08010067b9074501a6e1fb8b042",
},
versions = [
"1.71.1",
"nightly/2023-07-30",
"1.83.0",
"nightly/2024-11-28",
],
)
use_repo(rust, "rust_toolchains")
Expand Down

0 comments on commit 702b5a2

Please sign in to comment.