]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
rust: kbuild: treat `build_error` and `rustdoc` as kernel objects
authorMiguel Ojeda <ojeda@kernel.org>
Sun, 2 Nov 2025 21:28:52 +0000 (22:28 +0100)
committerMiguel Ojeda <ojeda@kernel.org>
Mon, 3 Nov 2025 23:00:03 +0000 (00:00 +0100)
commit16c43a56b79e2c3220b043236369a129d508c65a
treed37c052629ec25968bed7d064f709033c8b83898
parent09b1704f5b02c18dd02b21343530463fcfc92c54
rust: kbuild: treat `build_error` and `rustdoc` as kernel objects

Even if normally `build_error` isn't a kernel object, it should still
be treated as such so that we pass the same flags. Similarly, `rustdoc`
targets are never kernel objects, but we need to treat them as such.

Otherwise, starting with Rust 1.91.0 (released 2025-10-30), `rustc`
will complain about missing sanitizer flags since `-Zsanitizer` is a
target modifier too [1]:

    error: mixing `-Zsanitizer` will cause an ABI mismatch in crate `build_error`
     --> rust/build_error.rs:3:1
      |
    3 | //! Build-time error.
      | ^
      |
      = help: the `-Zsanitizer` flag modifies the ABI so Rust crates compiled with different values of this flag cannot be used together safely
      = note: unset `-Zsanitizer` in this crate is incompatible with `-Zsanitizer=kernel-address` in dependency `core`
      = help: set `-Zsanitizer=kernel-address` in this crate or unset `-Zsanitizer` in `core`
      = help: if you are sure this will not cause problems, you may use `-Cunsafe-allow-abi-mismatch=sanitizer` to silence this error

Thus explicitly mark them as kernel objects.

Cc: stable@vger.kernel.org # Needed in 6.12.y and later (Rust is pinned in older LTSs).
Link: https://github.com/rust-lang/rust/pull/138736
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Tested-by: Justin M. Forbes <jforbes@fedoraproject.org>
Link: https://patch.msgid.link/20251102212853.1505384-1-ojeda@kernel.org
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
rust/Makefile