Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

docs: rust: quick-start: update Ubuntu instructions

Split installation instructions for Ubuntu into 2 different sections:
- For Ubuntu 25.04: this release provides easy-to-install Rust packages.
- For Ubuntu 24.10 and below: these releases provide rust-1.80 and
bindgen-0.65, which do not set their tools as defaults. The instructions
for these versions have been updated to configure Rust tools properly.

Signed-off-by: Igor Korotin <igor.korotin@yahoo.com>
Link: https://lore.kernel.org/r/20250402160047.1827500-1-igor.korotin@yahoo.com
[ Dropped 24.10 -- it is soon out of support and their `bindgen` issue
(reported as issue #2086639) was never patched anyway. Removed trailing
spaces. Split into subheaders. Added `rustfmt` link. Removed spurious
backquotes. Reworded contents slightly. - Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>

authored by

Igor Korotin and committed by
Miguel Ojeda
f7819f79 de7cd3e4

+41 -3
+41 -3
Documentation/rust/quick-start.rst
··· 90 90 Ubuntu 91 91 ****** 92 92 93 - Ubuntu LTS and non-LTS (interim) releases provide recent Rust releases and thus 94 - they should generally work out of the box, e.g.:: 93 + 25.04 94 + ~~~~~ 95 95 96 - apt install rustc-1.80 rust-1.80-src bindgen-0.65 rustfmt-1.80 rust-1.80-clippy 96 + The latest Ubuntu releases provide recent Rust releases and thus they should 97 + generally work out of the box, e.g.:: 98 + 99 + apt install rustc rust-src bindgen rustfmt rust-clippy 100 + 101 + In addition, ``RUST_LIB_SRC`` needs to be set, e.g.:: 102 + 103 + RUST_LIB_SRC=/usr/src/rustc-$(rustc --version | cut -d' ' -f2)/library 104 + 105 + For convenience, ``RUST_LIB_SRC`` can be exported to the global environment. 106 + 107 + 108 + 24.04 LTS and older 109 + ~~~~~~~~~~~~~~~~~~~ 110 + 111 + Though Ubuntu 24.04 LTS and older versions still provide recent Rust 112 + releases, they require some additional configuration to be set, using 113 + the versioned packages, e.g.:: 114 + 115 + apt install rustc-1.80 rust-1.80-src bindgen-0.65 rustfmt-1.80 \ 116 + rust-1.80-clippy 117 + ln -s /usr/lib/rust-1.80/bin/rustfmt /usr/bin/rustfmt-1.80 118 + ln -s /usr/lib/rust-1.80/bin/clippy-driver /usr/bin/clippy-driver-1.80 119 + 120 + None of these packages set their tools as defaults; therefore they should be 121 + specified explicitly, e.g.:: 122 + 123 + make LLVM=1 RUSTC=rustc-1.80 RUSTDOC=rustdoc-1.80 RUSTFMT=rustfmt-1.80 \ 124 + CLIPPY_DRIVER=clippy-driver-1.80 BINDGEN=bindgen-0.65 125 + 126 + Alternatively, modify the ``PATH`` variable to place the Rust 1.80 binaries 127 + first and set ``bindgen`` as the default, e.g.:: 128 + 129 + PATH=/usr/lib/rust-1.80/bin:$PATH 130 + update-alternatives --install /usr/bin/bindgen bindgen \ 131 + /usr/bin/bindgen-0.65 100 132 + update-alternatives --set bindgen /usr/bin/bindgen-0.65 97 133 98 134 ``RUST_LIB_SRC`` needs to be set when using the versioned packages, e.g.:: 99 135 100 136 RUST_LIB_SRC=/usr/src/rustc-$(rustc-1.80 --version | cut -d' ' -f2)/library 137 + 138 + For convenience, ``RUST_LIB_SRC`` can be exported to the global environment. 101 139 102 140 In addition, ``bindgen-0.65`` is available in newer releases (24.04 LTS and 103 141 24.10), but it may not be available in older ones (20.04 LTS and 22.04 LTS),