summaryrefslogtreecommitdiff
path: root/Documentation/rust/quick-start.rst
AgeCommit message (Collapse)AuthorFilesLines
2023-08-21docs: rust: clarify what 'rustup override' doesTrevor Gross1-1/+3
The behavior of 'rustup override' is not very well known. Add a small note about what it does, so users have a better understanding of how it affects their system toolchain (i.e., it does not affect system toolchain and only sets a directory-specific override). Signed-off-by: Trevor Gross <tmgross@umich.edu> Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Link: https://lore.kernel.org/r/20230803060437.12157-3-tmgross@umich.edu [ Undid the `:` to `::` change. ] Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2023-08-21docs: rust: update instructions for obtaining 'core' sourceTrevor Gross1-7/+8
The source for Rust's 'core' library is needed to build the kernel with Rust support. This sometimes needs to be obtained by hand when using a standalone version of 'rustc' not managed by 'rustup'. Currently, the documentation suggests cloning the 'rust' repository to obtain these sources, but this is quite slow (on the order of a multiple minutes). Change this documentation to suggest using the source tarball instead. The tarball includes only needed files (<5M) and is significantly faster to download; this is more in line with what 'rustup' does. Also simplify wording of the relevant section. Link: https://github.com/Rust-for-Linux/linux/pull/1024 Signed-off-by: Trevor Gross <tmgross@umich.edu> Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Link: https://lore.kernel.org/r/20230803060437.12157-2-tmgross@umich.edu Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2023-08-21docs: rust: add command line to rust-analyzer sectionGuillaume Plourde1-1/+3
Add command line to rust-analyzer section for convenience purposes. Signed-off-by: Guillaume Plourde <gplourde@protonmail.com> Link: https://lore.kernel.org/r/y4jBalhfESeCZDShmVaGwrdlIRoIHroqNVUUYLck6qGNwB5e7wbIJO5DoiLBTPpTNYtdneWRODjhXwlIl9VzokqxffdNU7y__1wIa7BBl94=@protonmail.com [ Fixed indentation to tab and reworded title. ] Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2023-08-15rust: bindgen: upgrade to 0.65.1Aakash Sen Sharma1-1/+1
In LLVM 16, anonymous items may return names like `(unnamed union at ..)` rather than empty names [1], which breaks Rust-enabled builds because bindgen assumed an empty name instead of detecting them via `clang_Cursor_isAnonymous` [2]: $ make rustdoc LLVM=1 CLIPPY=1 -j$(nproc) RUSTC L rust/core.o BINDGEN rust/bindings/bindings_generated.rs BINDGEN rust/bindings/bindings_helpers_generated.rs BINDGEN rust/uapi/uapi_generated.rs thread 'main' panicked at '"ftrace_branch_data_union_(anonymous_at__/_/include/linux/compiler_types_h_146_2)" is not a valid Ident', .../proc-macro2-1.0.24/src/fallback.rs:693:9 ... thread 'main' panicked at '"ftrace_branch_data_union_(anonymous_at__/_/include/linux/compiler_types_h_146_2)" is not a valid Ident', .../proc-macro2-1.0.24/src/fallback.rs:693:9 ... This was fixed in bindgen 0.62.0. Therefore, upgrade bindgen to a more recent version, 0.65.1, to support LLVM 16. Since bindgen 0.58.0 changed the `--{white,black}list-*` flags to `--{allow,block}list-*` [3], update them on our side too. In addition, bindgen 0.61.0 moved its CLI utility into a binary crate called `bindgen-cli` [4]. Thus update the installation command in the Quick Start guide. Moreover, bindgen 0.61.0 changed the default functionality to bind `size_t` to `usize` [5] and added the `--no-size_t-is-usize` flag to not bind `size_t` as `usize`. Then bindgen 0.65.0 removed the `--size_t-is-usize` flag [6]. Thus stop passing the flag to bindgen. Finally, bindgen 0.61.0 added support for the `noreturn` attribute (in its different forms) [7]. Thus remove the infinite loop in our Rust panic handler after calling `BUG()`, since bindgen now correctly generates a `BUG()` binding that returns `!` instead of `()`. Link: https://github.com/llvm/llvm-project/commit/19e984ef8f49bc3ccced15621989fa9703b2cd5b [1] Link: https://github.com/rust-lang/rust-bindgen/pull/2319 [2] Link: https://github.com/rust-lang/rust-bindgen/pull/1990 [3] Link: https://github.com/rust-lang/rust-bindgen/pull/2284 [4] Link: https://github.com/rust-lang/rust-bindgen/commit/cc78b6fdb6e829e5fb8fa1639f2182cb49333569 [5] Link: https://github.com/rust-lang/rust-bindgen/pull/2408 [6] Link: https://github.com/rust-lang/rust-bindgen/issues/2094 [7] Signed-off-by: Aakash Sen Sharma <aakashsensharma@gmail.com> Closes: https://github.com/Rust-for-Linux/linux/issues/1013 Tested-by: Ariel Miculas <amiculas@cisco.com> Reviewed-by: Gary Guo <gary@garyguo.net> Link: https://lore.kernel.org/r/20230612194311.24826-1-aakashsensharma@gmail.com [ Reworded commit message. Mentioned the `bindgen-cli` binary crate change, linked to it and updated the Quick Start guide. Re-added a deleted "as" word in a code comment and reflowed comment to respect the maximum length. ] Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2023-08-09docs: rust: add paragraph about finding a suitable `libclang`Miguel Ojeda1-0/+17
Sometimes users need to tweak the finding process of `libclang` for `bindgen` via the `clang-sys`-provided environment variables. Thus add a paragraph to the setting up guide, including a reference to `clang-sys`'s relevant documentation. Link: https://lore.kernel.org/rust-for-linux/CAKwvOdm5JT4wbdQQYuW+RT07rCi6whGBM2iUAyg8A1CmLXG6Nw@mail.gmail.com/ Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> Reviewed-by: Nathan Chancellor <nathan@kernel.org> Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com> Link: https://lore.kernel.org/r/20230616001631.463536-4-ojeda@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2023-05-31docs: rust: point directly to the standalone installersMiguel Ojeda1-2/+2
The Quick Start guide points to the Rust programming language front page when it mentions the possibility of using the standalone installers instead of `rustup`. This was done to have a hopefully stable link, but it is not too helpful: readers need to figure out how to reach the standalone installers from there. Thus point directly to the page (and anchor) with the table that contains the standalone installers (plus signing key etc.). If the link breaks in the future, we can always update it as needed. And anyway having the full link includes the domain and gives more information about where the old docs were in such a broken link case, which may help. Link: https://lore.kernel.org/linux-doc/CANiq72=gpzQyh1ExGbBWWNdgH-mTATdG5F600jKD1=NLLCn7wg@mail.gmail.com/ Reviewed-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com> Link: https://lore.kernel.org/r/20230306220959.240235-1-ojeda@kernel.org [ Removed "install ``rustup``" ] Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2022-09-28docs: add Rust documentationMiguel Ojeda1-0/+232
Most of the documentation for Rust is written within the source code itself, as it is idiomatic for Rust projects. This applies to both the shared infrastructure at `rust/` as well as any other Rust module (e.g. drivers) written across the kernel. However, these documents contain general information that does not fit particularly well in the source code, like the Quick Start guide. It also contains a few other small changes elsewhere in the documentation folder. Reviewed-by: Kees Cook <keescook@chromium.org> Co-developed-by: Alex Gaynor <alex.gaynor@gmail.com> Signed-off-by: Alex Gaynor <alex.gaynor@gmail.com> Co-developed-by: Finn Behrens <me@kloenk.de> Signed-off-by: Finn Behrens <me@kloenk.de> Co-developed-by: Adam Bratschi-Kaye <ark.email@gmail.com> Signed-off-by: Adam Bratschi-Kaye <ark.email@gmail.com> Co-developed-by: Wedson Almeida Filho <wedsonaf@google.com> Signed-off-by: Wedson Almeida Filho <wedsonaf@google.com> Co-developed-by: Michael Ellerman <mpe@ellerman.id.au> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Co-developed-by: Sven Van Asbroeck <thesven73@gmail.com> Signed-off-by: Sven Van Asbroeck <thesven73@gmail.com> Co-developed-by: Wu XiangCheng <bobwxc@email.cn> Signed-off-by: Wu XiangCheng <bobwxc@email.cn> Co-developed-by: Gary Guo <gary@garyguo.net> Signed-off-by: Gary Guo <gary@garyguo.net> Co-developed-by: Boris-Chengbiao Zhou <bobo1239@web.de> Signed-off-by: Boris-Chengbiao Zhou <bobo1239@web.de> Co-developed-by: Yuki Okushi <jtitor@2k36.org> Signed-off-by: Yuki Okushi <jtitor@2k36.org> Co-developed-by: Wei Liu <wei.liu@kernel.org> Signed-off-by: Wei Liu <wei.liu@kernel.org> Co-developed-by: Daniel Xu <dxu@dxuuu.xyz> Signed-off-by: Daniel Xu <dxu@dxuuu.xyz> Co-developed-by: Julian Merkle <me@jvmerkle.de> Signed-off-by: Julian Merkle <me@jvmerkle.de> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>