Skip to content

Commit 127ab7a

Browse files
author
Niko Matsakis
committed
rust-for-linux write-up
1 parent 532ba38 commit 127ab7a

File tree

1 file changed

+23
-148
lines changed

1 file changed

+23
-148
lines changed

src/2025h1/rfl.md

Lines changed: 23 additions & 148 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
1-
# Resolve the biggest blockers to Linux building on stable Rust
1+
# Stabilize tooling needed by Rust for Linux
22

3-
| Metadata | |
4-
|----------------|------------------------------------|
5-
| Short title | Rust-for-Linux |
3+
| Metadata | |
4+
|------------------|------------------------------------|
5+
| Short title | Rust-for-Linux |
66
| Point of contact | @nikomatsakis |
7-
| Teams | [lang], [libs-api], [compiler] |
8-
| Status | Flagship |
9-
| Tracking issue | [rust-lang/rust-project-goals#116] |
10-
7+
| Teams | [compiler] |
8+
| Status | Proposed for flagship |
9+
| Tracking issue | [rust-lang/rust-project-goals#116] |
1110

1211
## Summary
1312

1413
Continue working towards Rust for Linux on stable, turning focus from language features to compiler and tooling.
1514

1615
## Motivation
1716

18-
The [experimental support for Rust development in the Linux kernel][RFL.com] is a watershed moment for Rust, demonstrating to the world that Rust is indeed capable of targeting all manner of low-level systems applications. And yet today that support rests on a [number of unstable features][RFL#2], blocking the effort from ever going beyond experimental status. For 2024H2 we will work to close the largest gaps that block support.
19-
17+
This goal continues our push to support the Linux kernel building on stable Rust. The focus in 2025H1 is shifting from language features, which were largely completed in 2024H2, towards compiler flags and tooling support. The Linux Kernel makes use of a number of unstable options in the compiler for target specific optimizations, code hardening, and sanitizer integration. It also requires a custom build of the standard library and has hacky integration with rustdoc to enable the use of doctests. We are looking to put all of these items onto a stable foundation.
18+
2019
[RFL.com]: https://rust-for-linux.com/
2120
[RFL#2]: https://github.com/Rust-for-Linux/linux/issues/2
2221

@@ -44,84 +43,23 @@ For deeper background, please refer to these materials:
4443
* [Rust in the linux kernel, by Alice Ryhl](https://www.youtube.com/watch?v=CEznkXjYFb4)
4544
* [Using Rust in the binder driver, by Alice Ryhl](https://www.youtube.com/watch?v=Kt3hpvMZv8o)
4645

47-
### The next six months
48-
49-
The RFL project has a [tracking issue][rfl2] listing the unstable features that they rely upon. After discussion with the RFL team, we identified the following subgoals as the ones most urgent to address in 2024. Closing these issues gets us within striking distance of being able to build the RFL codebase on stable Rust.
50-
51-
* Stable support for RFL's customized ARC type
52-
* Labeled goto in inline assembler and extended `offset_of!` support
53-
* RFL on Rust CI ([done now!])
54-
* Pointers to statics in constants
55-
56-
#### Stable support for RFL's customized ARC type
57-
58-
One of Rust's great features is that it doesn't "bake in" the set of pointer types.
59-
The common types users use every day, such as `Box`, `Rc`, and `Arc`, are all (in principle) library defined.
60-
But in reality those types enjoy access to some unstable features that let them be used more widely and ergonomically.
61-
Since few users wish to define their own smart pointer types, this is rarely an issue and there has been relative little pressure to stabilize those mechanisms.
62-
63-
The RFL project needs to integrate with the Kernel's existing reference counting types and intrusive linked lists.
64-
To achieve these goals they've created their own variant of [`Arc`][arclk] (hereafter denoted as `rfl::Arc`),
65-
but this type cannot be used as idiomatically as the `Arc` type found in `libstd` without two features:
66-
67-
* The ability to be used in methods (e.g., `self: rfl::Arc<Self>`), aka "arbitrary self types", specified in [RFC #3519].
68-
* The ability to be coerce to dyn types like `rfl::Arc<dyn Trait>` and then support invoking methods on `Trait` through dynamic dispatch.
69-
* This requires the use of two unstable traits, `CoerceUnsized` and `DynDispatch`, neither of which are close to stabilization.
70-
* However, [RFC #3621] provides for a "shortcut" -- a stable interface using `derive` that expands to those traits, leaving room to evolve the underlying details.
71-
72-
Our goal for 2024 is to close those gaps, most likely by implementing and stabilizing [RFC #3519] and [RFC #3621].
73-
74-
[rfl2]: https://github.com/Rust-for-Linux/linux/issues/2
75-
76-
#### Labeled goto in inline assembler and extended `offset_of!` support
77-
78-
These are two smaller extensions required by the Rust-for-Linux kernel support.
79-
Both have been implemented but more experience and/or development may be needed before stabilization is accepted.
80-
81-
#### RFL on Rust CI
82-
83-
> **Update**: Basic work was completed in [PR #125209] by Jakub Beránek during the planning process!
84-
> We are however still including a team ask of T-compiler to make sure we have agreed around the policy
85-
> regarding breakage due to unstable features.
86-
87-
[PR #125209]: https://github.com/rust-lang/rust/pull/125209
88-
89-
Rust sometimes integrates external projects of particular importance or interest into its CI.
90-
This gives us early notice when changes to the compiler or stdlib impact that project.
91-
Some of that breakage is accidental, and CI integration ensures we can fix it without the project ever being impacted.
92-
Otherwise the breakage is intentional, and this gives us an early way to notify the project so they can get ahead of it.
93-
94-
Because of the potential to slow velocity and incur extra work,
95-
the bar for being integrated into CI is high, but we believe that Rust For Linux meets that bar.
96-
Given that RFL would not be the first such project to be integrated into CI,
97-
part of pursuing this goal should be establishing clearer policies on when and how we integrate external projects into our CI,
98-
as we now have enough examples to generalize somewhat.
99-
100-
#### Pointers to statics in constants
101-
102-
The RFL project has a need to create vtables in read-only memory (unique address not required). The current implementation relies on the `const_mut_refs` and `const_refs_to_static` features ([representative example](https://godbolt.org/z/r58jP6YM4)). Discussion has identified some questions that need to be resolved but no major blockers.
103-
104-
### The "shiny future" we are working towards
105-
106-
The ultimate goal is to enable smooth and ergonomic interop between Rust and the Linux kernel's idiomatic data structures.
46+
### What we have done so far
10747

108-
In addition to the work listed above, there are a few other obvious items that the Rust For Linux project needs. If we can find owners for these this year, we could even get them done as a "stretch goal":
48+
We began the push towards stable support for RFL in 2024H2 with [a project goal focused on language features](https://github.com/rust-lang/rust-project-goals/issues/116). Over the course of those six months we:
10949

110-
#### Stable sanitizer support
50+
* Stabilized the `CoercePointee` derive, supporting the kernel's use of smart pointers to model intrusive linked lists.
51+
* Stabilized basic usage of `asm_goto`. Based on a survey of the kernel's usage, we [modified the existing design](https://github.com/rust-lang/rust/issues/132078) and also proposed [two](https://github.com/rust-lang/rust/issues/128464) [extensions](https://github.com/rust-lang/rust/pull/131523).
52+
* Stabilized `offset_of` syntax applied to structs.
53+
* Added Rust-for-Linux to the Rust CI to avoid accidental breakage.
54+
* Stabilized support for pointers to static in constants.
11155

112-
Support for building and using sanitizers, in particular KASAN.
56+
The one feature which was not stabilized yet is [arbitrary self types v2](https://github.com/rust-lang/rust/issues/44874), which reached "feature complete" status in its implementation. Stabilization is expected in early 2025.
11357

114-
#### Custom builds of core/alloc with specialized configuration options
58+
We also began work on tooling stabilization with an [RFC proposing an approach to stabilizing ABI-modifying compiler flags](https://github.com/rust-lang/rfcs/pull/3716).
11559

116-
The RFL project builds the stdlib with a number of configuration options to eliminate undesired aspects of libcore (listed in [RFL#2][]). They need a standard way to build a custom version of core as well as agreement on the options that the kernel will continue using.
117-
118-
#### Code-generation features and compiler options
119-
120-
The RFL project requires various code-generation options. Some of these are related to custom features of the kernel, such as X18 support ([rust-lang/compiler-team#748]) but others are codegen options like sanitizers and the like. Some subset of the options listed on [RFL#2][] will need to be stabilized to support being built with all required configurations, but working out the precise set will require more effort.
121-
122-
#### Ergonomic improvements
60+
### The next six months
12361

124-
Looking further afield, possible future work includes more ergonomic versions of the [special patterns for safe pinned initialization](https://rust-for-linux.com/the-safe-pinned-initialization-problem) or a solution to [custom field projection for pinned types or other smart pointers](https://github.com/rust-lang/rfcs/pull/3318).
62+
Over the next six months our goal is to stabilize the major bits of tooling used by the Rust for Linux project...
12563

12664
## Design axioms
12765

@@ -134,73 +72,10 @@ Here is a detailed list of the work to be done and who is expected to do it. Thi
13472

13573
* The ![Team][] badge indicates a requirement where Team support is needed.
13674

137-
| Task | Owner(s) or team(s) | Notes |
138-
|----------------------------|------------------------------|-------|
139-
| Overall program management | @nikomatsakis, @joshtriplett | |
140-
141-
### Arbitrary self types v2
142-
143-
| Task | Owner(s) or team(s) | Notes |
144-
|------------------------|----------------------|---------------------------|
145-
| ~~author RFC~~ | | ![Complete][] [RFC #3519] |
146-
| ~~RFC decision~~ | ~~[lang]~~ | ![Complete][] |
147-
| Implementation | | |
148-
| Standard reviews | ![Team][] [compiler] | |
149-
| Stabilization decision | ![Team][] [lang] | |
150-
151-
### Derive smart pointer
152-
153-
| Task | Owner(s) or team(s) | Notes |
154-
|-----------------------------|---------------------|---------------|
155-
| ~~author RFC~~ | | [RFC #3621] |
156-
| RFC decision | ![Team][] [lang] | ![Complete][] |
157-
| Implementation | @dingxiangfei2009 | |
158-
| Author stabilization report | @dingxiangfei2009 | |
159-
| Stabilization decision | ![Team][] [lang] | |
160-
161-
### `asm_goto`
162-
163-
| Task | Owner(s) or team(s) | Notes |
164-
|----------------------------------|---------------------|---------------|
165-
| ~~implementation~~ | | ![Complete][] |
166-
| Real-world usage in Linux kernel | @Darksonn | |
167-
| Extend to cover full RFC | | |
168-
| Author stabilization report | | |
169-
| Stabilization decision | ![Team][] [lang] | |
170-
171-
### RFL on Rust CI
172-
173-
| Task | Owner(s) or team(s) | Notes |
174-
|--------------------|----------------------|-------------------------|
175-
| ~~implementation~~ | | ![Complete][] [#125209] |
176-
| Policy draft | | |
177-
| Policy decision | ![Team][] [compiler] | |
178-
179-
### Pointers to static in constants
180-
181-
| Task | Owner(s) or team(s) | Notes |
182-
|------------------------|---------------------|-------|
183-
| Stabilization report | | |
184-
| Stabilization decision | ![Team][] [lang] | |
185-
186-
187-
### Support needed from the project
188-
189-
* Lang team:
190-
* Prioritize RFC and any related design questions (e.g., the unresolved questions)
191-
192-
## Outputs and milestones
193-
194-
### Outputs
195-
196-
*Final outputs that will be produced*
197-
198-
### Milestones
199-
200-
*Milestones you will reach along the way*
75+
| Task | Owner(s) or team(s) | Notes |
76+
|----------------------------|---------------------|-------|
77+
| Overall program management | @nikomatsakis | |
20178

202-
## Frequently asked questions
20379

204-
None yet.
20580

20681

0 commit comments

Comments
 (0)