mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] rust: kbuild: add `no_io_statics` to `core-cfgs`
@ 2026-09-04  9:31 Alice Ryhl
  2026-09-04 10:59 ` Gary Guo
  2026-10-02 13:30 ` Miguel Ojeda
  0 siblings, 2 replies; 3+ messages in thread
From: Alice Ryhl @ 2026-09-04  9:31 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Trevor Gross, Danilo Krummrich, Daniel Almeida,
	Tamir Duberstein, Alexandre Courbot, Onur Özkan,
	rust-for-linux, linux-kernel, Alice Ryhl

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@google.com>
---
 rust/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/rust/Makefile b/rust/Makefile
index da1a7409d984..8cbee5b6b0bd 100644
--- a/rust/Makefile
+++ b/rust/Makefile
@@ -75,7 +75,8 @@ endif
 cfgs-to-flags = $(patsubst %,--cfg='%',$1)
 
 core-cfgs := \
-    no_fp_fmt_parse
+    no_fp_fmt_parse \
+    no_io_statics
 
 core-edition := $(if $(call rustc-min-version,108700),2024,2021)
 

---
base-commit: cee9395acd8043be0644b25c34bfa86623f2b935
change-id: 20260904-no-io-statics-ab07a70358c8

Best regards,
-- 
Alice Ryhl <aliceryhl@google.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-02 13:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-04  9:31 [PATCH] rust: kbuild: add `no_io_statics` to `core-cfgs` Alice Ryhl
2026-09-04 10:59 ` Gary Guo
2026-10-02 13:30 ` Miguel Ojeda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®