diff options
| author | Marco Elver <elver@google.com> | 2026-10-10 08:47:49 +0000 |
|---|---|---|
| committer | Marco Elver <elver@google.com> | 2026-11-03 13:53:38 +0000 |
| commit | b23b8d7059795a7744a7d5e4d3c25dd15759a903 (patch) | |
| tree | 1e2df1108c51652c59e7c7d3bc806642820c6298 /scripts/Makefile.thinlto | |
| parent | 880748cd41fc7c7ca112bbd509d050f68466b88a (diff) | |
| download | linux-next-b23b8d7059795a7744a7d5e4d3c25dd15759a903.tar.gz linux-next-b23b8d7059795a7744a7d5e4d3c25dd15759a903.zip | |
kbuild: rust: enable KCSAN support
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 <ojeda@kernel.org>
Acked-by: Boqun Feng <boqun@kernel.org>
Acked-by: Gary Guo <gary@garyguo.net>
Signed-off-by: Marco Elver <elver@google.com>
Diffstat (limited to 'scripts/Makefile.thinlto')
0 files changed, 0 insertions, 0 deletions
