Re: [PATCH] rust: kbuild: add `no_io_statics` to `core-cfgs`

From: Gary Guo

Date: Fri Sep 04 2026 - 07:37:56 EST


On Fri Sep 4, 2026 at 10:31 AM BST, Alice Ryhl wrote:
> In upstream Rust, PR #155625 moved `std::io::Error` into `core` under
> the `core_io` feature gate. To support decoding and formatting raw OS
> errors (`RawOsError`) from within `core` without depending on OS
> facilities, `core` introduced a global atomic pointer:
>
> static OS_FUNCTIONS: atomic::AtomicPtr<OsFunctions>
>
> At runtime, `std` registers its OS error vtable with this pointer via
> `set_functions()`, which uses `core::sync::atomic` to modify the value
> of this atomic variable.
>
> To ensure that `core` does not introduce usage of `core::sync::atomic`
> into the kernel image, set the `no_io_statics` cfg, which removes this
> logic from the build.
>
> Note that changing the `OS_FUNCTIONS` global is only possible via the
> unstable `from_raw_os_error_with_functions()` function from `core`,
> which is called by `std`. There is no way for us to invoke it from the
> kernel, as we do not use `std`.
>
> Link: https://github.com/rust-lang/rust/pull/155625
> Link: https://github.com/rust-lang/rust/issues/154046
> Link: https://github.com/rust-lang/libs-team/issues/755
> Signed-off-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>

Didn't know that this already exists :)

Reviewed-by: Gary Guo <gary@xxxxxxxxxxx>

> ---
> rust/Makefile | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)