Description
Note: there is the "A-rust-for-linux" label in the rust
repository: https://github.com/rust-lang/rust/labels/A-rust-for-linux.
Features that we would like to see
Required (we almost certainly want them)
- C string equivalents (nul-terminated) for
core::panic::Location
(or a flag to ensure there is a\0
after thestr
s).- For the macros like
file!()
, it is fine, since we can easily transform those withc_str!
(which we already do), so it is a nice to have (see the related item below). - Lore: https://lore.kernel.org/rust-for-linux/CAH5fLgjk5koTwMOcdsnQjTVWQehjCDPoD2M3KboGZsxigKdMfA@mail.gmail.com/.
- Rust Zulip: https://rust-lang.zulipchat.com/#narrow/stream/425075-rust-for-linux/topic/Caller.20location.20with.20nul-terminated.20filename/near/477164522.
- ACP: ACP: Add nul-terminated version of
core::panic::Location::file
rust-lang/libs-team#466. - PR: Add Location::file_with_nul rust-lang/rust#135054.
- PR: Add unstable option to nul-terminate location strings rust-lang/rust#135240.
- PR: Add nul-terminated filename for #[track_caller] rust-lang/rust#131828.
- PR: Null terminate
core::panic::Location
file strings rust-lang/rust#117431.
- For the macros like
Nice to have (not critical, we could workaround if needed, etc.)
-
Disabling 128-bit features.
-
Disabling floating-point features.
- Currently we provide weak symbols that panics, but generally we should not even compile floating point support (in the kernel, very little code needs it, and it is compiled differently in the C side). Ideally, we would have a compiler flag to disable all that where not needed (possibly even not accepting code referring to
f32
etc.).Maybe we should add a check, perhaps by compiling against softfp and link against compile-rt with hardfp to see if no symbols are unresolved?
- Cc: @nbdd0121.
- PR (a
cfg
to disable formatting of floating point): core: add unstable no_fp_fmt_parse to disable float formatting code rust-lang/rust#86048.
- Currently we provide weak symbols that panics, but generally we should not even compile floating point support (in the kernel, very little code needs it, and it is compiled differently in the C side). Ideally, we would have a compiler flag to disable all that where not needed (possibly even not accepting code referring to
-
Disabling Unicode features / a way to use external tables.
-
Clarify invariants of the
Layout
type.- i.e. lift requirements to the type from the constructors / how does one connect
Layout
to "a layout suitable to an allocated object"? Is it library / language UB? (currently it appears to be the former). - After [ptr] Document maximum allocation size rust-lang/rust#116675, a reference could be added to that from
Layout
type documentation. - Rust Zulip: https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Document.20.60Layout.60.20Type.20Invariant.3F/near/412607198.
- From: discussion in Rust for Linux Zulip between Valentin, Benno and Miguel.
- Related issue in UCG: Where to document allocation size upper bound? rust-lang/unsafe-code-guidelines#465.
- Related PR: Enforce that layout size fits in isize in Layout rust-lang/rust#95295.
- i.e. lift requirements to the type from the constructors / how does one connect
-
c_stringify!
,c_concat!
,c_file!
macros.- Instead of having to provide a
c_str!
macro to then doc_str!(stringify!(...))
orc_str!(concat!(...))
. - Lore: https://lore.kernel.org/rust-for-linux/CANiq72nbbtNp4vGGHkXVSgSW+WU=5Z9uGRO_LLg7+ezTqrZ_tQ@mail.gmail.com/
- Rust Zulip: https://rust-lang.zulipchat.com/#narrow/stream/404510-wg-macros/topic/May.20we.20need.20a.20.60c_stringify!.60.20and.20.60c_concat!.60.20macros.3F/near/466691443.
- Cc: @vincenzopalazzo @y86-dev.
- It could prevent mistakes where one assumes it is nul-terminated, perhaps disallowing the usual one in Clippy: https://lore.kernel.org/rust-for-linux/20241016035214.2229-8-fujita.tomonori@gmail.com/#iZ31rust:kernel:io:poll.rs.
- Instead of having to provide a
-
Clarify
addr_of!
documentation about whether it creates read-only pointers or not. -
Moving towards
core::ffi::CStr
(fromkernel::str::CStr
).- Rust for Linux Issue: Replace
kernel::str::CStr
bycore::ffi::CStr
#1075. - PR: Implement Deref<Target=ByteStr> for CStr rust-lang/rust#138498.
impl Display for CStr
ACP:impl Display for CStr
rust-lang/libs-team#550.impl Display for CStr
Tracking Issue: Tracking Issue forimpl Display for CStr
rust-lang/rust#139984.impl Display for CStr
PR:impl Display for CStr{,ing}
rust-lang/rust#139994.ByteStr
Tracking Issue: Tracking Issue for ByteStr/ByteString rust-lang/rust#134915.- Related PR: Improve the documentation of
Display
andFromStr
, and their interactions rust-lang/rust#136687. - Lore ("rust: replace kernel::str::CStr w/ core::ffi::CStr"): https://lore.kernel.org/rust-for-linux/20250317-cstr-core-v9-0-51d6cc522f62@gmail.com/.
- Lore (Gary's suggestion): https://lore.kernel.org/all/20250221142816.0c015e9f@eugeo/.
- Rust for Linux Issue: Replace
Low priority (we will likely not use them in the end)
- Generic atomics.
- We are considering whether to use a generic API for our atomics, thus we will be watching any progress on the
core
ones. - Issue: Tracking Issue for generic
Atomic
rust-lang/rust#130539. - ACP (API Change Proposal): ACP: Generic
Atomic<T>
rust-lang/libs-team#443. - Initial PR: Create
Atomic<T>
type alias rust-lang/rust#130543. - LPC Rust MC topic: https://lpc.events/event/18/contributions/1788/
- Cc: @fbq.
- We are considering whether to use a generic API for our atomics, thus we will be watching any progress on the
Done (stabilized, fixed, not needed anymore, etc.)
-
Ensure
no_fp_fmt_parse
builds are warning-free. -
Ensure
no_global_oom_handling
builds are warning-free.
Bugs that we would like to see fixed
Required (we almost certainly want them)
Nice to have (probably not critical, we could workaround if needed, etc.)
Low priority (we will likely not use them in the end)
Done (stabilized, fixed, or not needed anymore, etc.)
-
Fix warning when libcore is compiled with no_fp_fmt_parse rust-lang/rust#105434.
-
Fix
no_global_oom_handling
build. -
Inline floating-point methods to avoid requiring intrinsics.
midpoint
,next_up
,next_down
are not marked as#[inline]
, which makes them appear under-Os
arm64, see Zulip: https://rust-for-linux.zulipchat.com/#narrow/stream/288089-General/topic/v6.2E11-rc1.20doesn't.20build.20for.20arm64/near/455637364.- PR: Mark
{f32,f64}::{next_up,next_down,midpoint}
inline rust-lang/rust#128749.
-
CFI failure on
core::fmt::write()
when FineIBT is enabled.- Issue: CFI: core and std have explict CFI violations rust-lang/rust#115199.
- PR (point 2 of the issue above): cfi: do not transmute function pointers in formatting code rust-lang/rust#139632 (1.88).
- PR (previous approach): cfi: Store type erasure witness for Argument rust-lang/rust#115954.
- Patch to restrict FineIBT with Rust: https://lore.kernel.org/rust-for-linux/20250410115420.366349-1-panikiel@google.com/.