diff options
| author | Alice Ryhl <aliceryhl@google.com> | 2026-09-04 09:31:09 +0000 |
|---|---|---|
| committer | Miguel Ojeda <ojeda@kernel.org> | 2026-10-02 15:26:52 +0200 |
| commit | 547948954f1ca78d3bb0b38201d205a16dc52d56 (patch) | |
| tree | bd88bca23864d89e8bafab9a091fec4e3df33589 /tools/lib/python | |
| parent | 948440b3f429f84680db58b4bf529b1ed2a20e15 (diff) | |
| download | linux-next-547948954f1ca78d3bb0b38201d205a16dc52d56.tar.gz linux-next-547948954f1ca78d3bb0b38201d205a16dc52d56.zip | |
rust: kbuild: add `no_io_statics` to `core-cfgs`
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`.
[ Pass `-Aunused_variables` to `core` to avoid:
error: unused variable: `f`
--> .../library/core/src/io/error/os_functions.rs:9:36
|
9 | pub(super) unsafe fn set_functions(f: &'static OsFunctions) {
| ^ help: if this is intentional, prefix it with an underscore: `_f`
|
= note: `-D unused-variables` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(unused_variables)]`
I sent a PR upstream [1] to clean it up and to add a test to check
that `core` builds are warning-free with the `cfg` enabled, similar
to what I added for other `cfg`s.
Link: https://github.com/rust-lang/rust/pull/163633 [1]
- Miguel ]
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@google.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
Link: https://patch.msgid.link/20260904-no-io-statics-v1-1-a2386eb0d255@google.com
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Diffstat (limited to 'tools/lib/python')
0 files changed, 0 insertions, 0 deletions
