On Mon, 19 Oct 2026 at 17:27, Gary Guo <[email protected]> wrote: > > On Thu Oct 15, 2026 at 3:56 PM BST, Marco Elver wrote: > > Rust supports ThreadSanitizer instrumentation via LLVM, which is what > > KCSAN relies on; however, Rust code is not currently instrumented. > > > > Pass -Zsanitizer=thread and the same TSan backend options used for C > > code to rustc. Wire up KCSAN_SANITIZE in scripts/Makefile.lib for parity > > with C (though rustc currently rejects linking crates with mismatched > > instrumentation). > > > > rustc only accepts -Zsanitizer=thread for targets that declare support > > for it. Of the targets used by the kernel, this is only possible for the > > generated x86_64 target specification, so restrict instrumentation of > > Rust code to x86_64 for now via HAVE_KCSAN_RUSTC. On other architectures > > Rust code remains uninstrumented as before. > > > > All TSan options used are supported by the LLVM versions of the minimum > > supported rustc, so no rustc-option checks are needed (they would also > > fail, because x86_64-unknown-none used for option checks does not > > support -Zsanitizer=thread). > > > > Unlike Clang and GCC, an equivalent to -fno-optimize-sibling-calls is > > omitted for Rust because rustc provides no corresponding option. While > > disabling tail-call optimizations helps preserve complete stacks traces > > in reports, it is optional and not required for KCSAN to function. > > > > With this enabled we can detect data races in kernel Rust code and > > between Rust and C code. > > > > Acked-by: Miguel Ojeda <[email protected]> > > Acked-by: Boqun Feng <[email protected]> > > Signed-off-by: Marco Elver <[email protected]> > > Acked-by: Gary Guo <[email protected]>
Thanks! Which tree should this go through? The Rust tree? Probably too late for this cycle.
