Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,10 @@ build:asan --test_env=KJ_CLEAN_SHUTDOWN=1
# Enable ASan, LSan support in V8
build:asan --copt="-DV8_USE_ADDRESS_SANITIZER"
build:asan --per_file_copt='external/.*v8@-DADDRESS_SANITIZER,-DLEAK_SANITIZER'
# One toolchain per host; resolution picks the one matching the (host-parented) asan platform.
# One toolchain per host, plus its cargo toolchain; resolution picks the one matching the
# (host-parented) asan platform.
build:asan --extra_toolchains=//build/rust:asan_toolchain_linux_x86_64,//build/rust:asan_toolchain_linux_aarch64,//build/rust:asan_toolchain_macos_aarch64
build:asan --extra_toolchains=//build/rust:asan_toolchain_linux_x86_64_cargo,//build/rust:asan_toolchain_linux_aarch64_cargo,//build/rust:asan_toolchain_macos_aarch64_cargo
build:asan --@rules_rust//:extra_rustc_flag=-Zsanitizer=address

# thread sanitizer (https://github.com/google/sanitizers/wiki/ThreadSanitizerCppManual)
Expand Down Expand Up @@ -305,8 +307,10 @@ build:tsan-common --copt="-DV8_IS_TSAN"
build:tsan-common --per_file_copt='external/.*v8@-DTHREAD_SANITIZER'
# Perfetto also requires this define to enable its shared-memory scraping annotations.
build:tsan-common --per_file_copt='external/.*perfetto@-DTHREAD_SANITIZER'
# One toolchain per host; resolution picks the one matching the (host-parented) tsan platform.
# One toolchain per host, plus its cargo toolchain; resolution picks the one matching the
# (host-parented) tsan platform.
build:tsan-common --extra_toolchains=//build/rust:tsan_toolchain_linux_x86_64,//build/rust:tsan_toolchain_macos_aarch64
build:tsan-common --extra_toolchains=//build/rust:tsan_toolchain_linux_x86_64_cargo,//build/rust:tsan_toolchain_macos_aarch64_cargo
build:tsan-common --@rules_rust//:extra_rustc_flag=-Zsanitizer=thread

# Linux x86_64.
Expand Down
6 changes: 3 additions & 3 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 16 additions & 12 deletions build/deps/formatters/rustfmt_repository.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,6 @@ def _rustfmt_standalone_repository_impl(repository_ctx):
iso_date = repository_ctx.attr.iso_date
proxy = PROXY_URL

# Download the rustfmt component (contains bin/rustfmt and bin/cargo-fmt).
rustfmt_url = proxy + _URL_TEMPLATE.format(
iso_date = iso_date,
component = "rustfmt",
triple = triple,
)
repository_ctx.download_and_extract(
url = rustfmt_url,
sha256 = repository_ctx.attr.rustfmt_sha256,
stripPrefix = "rustfmt-nightly-{}/rustfmt-preview".format(triple),
)

# Download the rustc component (contains shared libraries that rustfmt
# dynamically links against, e.g. librustc_driver-*.so / .dylib).
rustc_url = proxy + _URL_TEMPLATE.format(
Expand All @@ -40,6 +28,22 @@ def _rustfmt_standalone_repository_impl(repository_ctx):
stripPrefix = "rustc-nightly-{}/rustc".format(triple),
)

# Delete binaries to reduce disk space usage, we only need librustc_driver
repository_ctx.delete("bin")
repository_ctx.delete("lib/rustlib")

# Download the rustfmt component (contains bin/rustfmt and bin/cargo-fmt).
rustfmt_url = proxy + _URL_TEMPLATE.format(
iso_date = iso_date,
component = "rustfmt",
triple = triple,
)
repository_ctx.download_and_extract(
url = rustfmt_url,
sha256 = repository_ctx.attr.rustfmt_sha256,
stripPrefix = "rustfmt-nightly-{}/rustfmt-preview".format(triple),
)

# Create a wrapper script that sets the library path so the dynamically-linked
# rustfmt binary can find its libraries. We embed absolute paths because the
# wrapper may be copied to bazel-bin by native_binary.
Expand Down
2 changes: 1 addition & 1 deletion build/deps/gen/build_deps.MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ bazel_dep(name = "rules_oci", version = "2.3.0")
bazel_dep(name = "rules_python", version = "2.4.5")

# rules_rust
bazel_dep(name = "rules_rust", version = "0.74.0")
bazel_dep(name = "rules_rust", version = "0.75.0")
single_version_override(
module_name = "rules_rust",
patch_strip = 1,
Expand Down
21 changes: 20 additions & 1 deletion build/rust/sanitizer_toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

"""Per-host sanitizer-instrumented Rust toolchains (see //build/rust:BUILD.bazel)."""

load("@rules_rust//cargo:cargo_toolchain.bzl", "cargo_toolchain")
load("@rules_rust//rust:toolchain.bzl", "rust_toolchain")
load("//build/deps:gen/build_deps.bzl", "RUST_NIGHTLY_DATE", "RUST_NIGHTLY_VERSION")
load(":build_std.bzl", "compiler_runtime_files", "instrumented_rust_std")
Expand Down Expand Up @@ -109,7 +110,6 @@ def sanitizer_rust_toolchain(name, sanitizer, host):
name = name + "_impl",
allocator_library = "@rules_rust//ffi/rs:empty",
binary_ext = "",
cargo = h.rust_tools + "//:cargo",
cargo_clippy = h.rust_tools + "//:cargo_clippy_bin",
channel = "nightly",
clippy_driver = h.rust_tools + "//:clippy_driver_bin",
Expand Down Expand Up @@ -147,3 +147,22 @@ def sanitizer_rust_toolchain(name, sanitizer, host):
toolchain = ":" + name + "_impl",
toolchain_type = "@rules_rust//rust:toolchain",
)

cargo_toolchain(
name = name + "_cargo_impl",
cargo = h.rust_tools + "//:cargo",
channel = "nightly",
iso_date = RUST_NIGHTLY_DATE,
tags = ["manual"],
version = RUST_NIGHTLY_VERSION,
)

native.toolchain(
name = name + "_cargo",
exec_compatible_with = host_constraints,
tags = ["manual"],
target_compatible_with = host_constraints + [constraint],
target_settings = ["@rules_rust//rust/toolchain/channel:nightly"],
toolchain = ":" + name + "_cargo_impl",
toolchain_type = "@rules_rust//cargo:toolchain_type",
)
Loading
Loading