Skip to content

Commit c1831bf

Browse files
ojedafbq
authored andcommitted
docs: rust: quick-start: add section on Linux distributions
Now that we are starting to support several Rust compiler and `bindgen` versions, there is a good chance some Linux distributions work out of the box. Thus, provide some instructions on how to set the toolchain up for a few major Linux distributions. This simplifies the setup users need to build the kernel. In addition, add an introduction to the document so that it is easier to understand its structure. We may want to reorganize it or split it in the future, but I wanted to focus this commit on the new information added about each particular distribution. Finally, remove the `rustup`'s components mention in `changes.rst` since users do not need it if they install the toolchain via the distributions (and anyway it was too detailed for that main document). Cc: Jan Alexander Steffens <[email protected]> Cc: Johannes Löthberg <[email protected]> Cc: Fabian Grünbichler <[email protected]> Cc: Josh Stone <[email protected]> Cc: Randy Barlow <[email protected]> Cc: Anna Figueiredo Gomes (navi) <[email protected]> Cc: Matoro Mahri <[email protected]> Cc: Ryan Scheel <[email protected]> Cc: figsoda <[email protected]> Cc: Jörg Thalheim <[email protected]> Cc: Theodore Ni <[email protected]> Cc: Winter <[email protected]> Cc: William Brown <[email protected]> Cc: Xiaoguang Wang <[email protected]> Cc: Andrea Righi <[email protected]> Cc: Zixing Liu <[email protected]> Signed-off-by: Miguel Ojeda <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent cb6b4bf commit c1831bf

File tree

2 files changed

+78
-5
lines changed

2 files changed

+78
-5
lines changed

Documentation/process/changes.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,6 @@ Rust (optional)
9090

9191
A recent version of the Rust compiler is required.
9292

93-
Each Rust toolchain comes with several "components", some of which are required
94-
(like ``rustc``) and some that are optional. The ``rust-src`` component (which
95-
is optional) needs to be installed to build the kernel. Other components are
96-
useful for developing.
97-
9893
Please see Documentation/rust/quick-start.rst for instructions on how to
9994
satisfy the build requirements of Rust support. In particular, the ``Makefile``
10095
target ``rustavailable`` is useful to check why the Rust toolchain may not

Documentation/rust/quick-start.rst

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,84 @@ Quick Start
55

66
This document describes how to get started with kernel development in Rust.
77

8+
There are a few ways to install a Rust toolchain needed for kernel development.
9+
A simple way is to use the packages from your Linux distribution if they are
10+
suitable -- the first section below explains this approach. An advantage of this
11+
approach is that, typically, the distribution will match the LLVM used by Rust
12+
and Clang.
13+
14+
Alternatively, the next two "Requirements" sections explain each component and
15+
how to install them through ``rustup``, the standalone installers from Rust
16+
and/or building them.
17+
18+
The rest of the document explains other aspects on how to get started.
19+
20+
21+
Distributions
22+
-------------
23+
24+
Arch Linux
25+
**********
26+
27+
Arch Linux provides recent Rust releases and thus it should generally work out
28+
of the box, e.g.::
29+
30+
pacman -S rust rust-src rust-bindgen
31+
32+
33+
Debian
34+
******
35+
36+
Debian Unstable (Sid), outside of the freeze period, provides recent Rust
37+
release and thus it should generally work out of the box, e.g.::
38+
39+
apt install rustc rust-src bindgen rustfmt rust-clippy
40+
41+
42+
Fedora Linux
43+
************
44+
45+
Fedora Linux provides recent Rust releases and thus it should generally work out
46+
of the box, e.g.::
47+
48+
dnf install rust rust-src bindgen-cli rustfmt clippy
49+
50+
51+
Gentoo Linux
52+
************
53+
54+
Gentoo Linux (and especially the testing branch) provides recent Rust releases
55+
and thus it should generally work out of the box, e.g.::
56+
57+
USE='rust-src rustfmt clippy' emerge dev-lang/rust dev-util/bindgen
58+
59+
``LIBCLANG_PATH`` may need to be set.
60+
61+
62+
Nix
63+
***
64+
65+
Nix (unstable channel) provides recent Rust releases and thus it should
66+
generally work out of the box, e.g.::
67+
68+
{ pkgs ? import <nixpkgs> {} }:
69+
pkgs.mkShell {
70+
nativeBuildInputs = with pkgs; [ rustc rust-bindgen rustfmt clippy ];
71+
RUST_LIB_SRC = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
72+
}
73+
74+
75+
openSUSE
76+
********
77+
78+
openSUSE Tumbleweed provides recent Rust releases and thus it should generally
79+
work out of the box, e.g.::
80+
81+
zypper install rust rust-bindgen clang
82+
83+
The Rust standard library source code, ``rustfmt`` and Clippy are not packaged
84+
(yet), thus currently they need to be installed separately.
85+
886

987
Requirements: Building
1088
----------------------

0 commit comments

Comments
 (0)