Skip to content
Merged
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
31 changes: 30 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,20 @@ build --@rules_go//go/config:pure
build:gofips --//bazel:gofips=True --@rules_go//go/toolchain:sdk_name=go_sdk_with_systemcrypto
build:gofips --@rules_go//go/config:pure=false

#################
# Rust settings #
#################

# Use rules_rust's Rust-side allocator_library that defines the
# mangled `__rustc::*` allocator shim symbols (rust_alloc,
# rust_dealloc, etc.). The default cc_allocator_library predates the
# allocator-symbol mangling in rustc 1.87+ and leaves those symbols
# undefined when a Rust staticlib is linked into a cc_binary via
# cc_common.link. See bazelbuild/rules_rust#3459.
build --@rules_rust//rust/settings:experimental_use_allocator_libraries_with_mangled_symbols=True

# end of rust settings #

# Improve caching and readability of filepaths that the compiler uses by not using
# absolute paths, and instead use paths that are relative to the redpanda repo.
# https://github.com/bazel-contrib/toolchains_llvm/pull/445#issuecomment-2605443516
Expand Down Expand Up @@ -149,7 +163,22 @@ build:san-all --linkopt=-fsanitize=address,undefined,vptr,function,alignment
# PGO + release, but should work with any.
build:lto --copt -flto=thin
build:lto --linkopt -flto=thin
build:lto --@rules_rust//rust/settings:lto=fat
# Use thin LTO for Rust to match the C++ side. With fat LTO, rustc's
# LLVM Internalize pass downgrades the auto-injected `__rustc::*`
# allocator shim symbols from GLOBAL to LOCAL binding when emitting the
# empty staticlib provided by rules_rust's
# `experimental_use_allocator_libraries_with_mangled_symbols`. Nothing
# inside the empty crate references those symbols, so LTO assumes
# they're internal. The rust stdlib rlibs still emit GLOBAL undefined
# refs to them, and ELF won't bind a GLOBAL ref to a LOCAL def across
# object files, so the cc_binary link fails with:
# ld.lld: error: undefined symbol: __rustc::__rust_no_alloc_shim_is_unstable_v2
# Thin LTO doesn't run Internalize across the crate the way fat LTO
# does, so the symbols stay GLOBAL and the link succeeds. We don't
# lose any wasm performance: every wasmtime crate is an rlib (rules_rust
# emits `-Clinker-plugin-lto` regardless of -Clto mode) and the actual
# cross-language LTO happens at the C++ link step, which is thin too.
build:lto --@rules_rust//rust/settings:lto=thin
build:lto --@rules_rust//rust/settings:extra_rustc_flag=-Ccodegen-units=1
# I've seen others claim these flags help with LTO and the final binary, but these also
# require a specific version of clang and I don't really want to tie rustc version with
Expand Down
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ rust.toolchain(
"aarch64-unknown-linux-gnu",
"x86_64-unknown-linux-gnu",
],
versions = ["1.86.0"],
versions = ["1.91.0"],
)
use_repo(rust, "rust_toolchains")

Expand Down
1,190 changes: 530 additions & 660 deletions MODULE.bazel.lock

Large diffs are not rendered by default.

Loading
Loading