[PATCH v8 27/31] Kbuild: add Rust support
Masahiro Yamada
masahiroy at kernel.org
Wed Sep 7 04:08:36 AEST 2022
On Tue, Aug 2, 2022 at 10:53 AM Miguel Ojeda <ojeda at kernel.org> wrote:
>
> Having all the new files in place, we now enable Rust support
> in the build system, including `Kconfig` entries related to Rust,
> the Rust configuration printer, the target specification
> generation script, the version detection script and a few
> other bits.
>
> Co-developed-by: Alex Gaynor <alex.gaynor at gmail.com>
> Signed-off-by: Alex Gaynor <alex.gaynor at gmail.com>
> Co-developed-by: Finn Behrens <me at kloenk.de>
> Signed-off-by: Finn Behrens <me at kloenk.de>
> Co-developed-by: Adam Bratschi-Kaye <ark.email at gmail.com>
> Signed-off-by: Adam Bratschi-Kaye <ark.email at gmail.com>
> Co-developed-by: Wedson Almeida Filho <wedsonaf at google.com>
> Signed-off-by: Wedson Almeida Filho <wedsonaf at google.com>
> Co-developed-by: Michael Ellerman <mpe at ellerman.id.au>
> Signed-off-by: Michael Ellerman <mpe at ellerman.id.au>
> Co-developed-by: Sven Van Asbroeck <thesven73 at gmail.com>
> Signed-off-by: Sven Van Asbroeck <thesven73 at gmail.com>
> Co-developed-by: Gary Guo <gary at garyguo.net>
> Signed-off-by: Gary Guo <gary at garyguo.net>
> Co-developed-by: Boris-Chengbiao Zhou <bobo1239 at web.de>
> Signed-off-by: Boris-Chengbiao Zhou <bobo1239 at web.de>
> Co-developed-by: Boqun Feng <boqun.feng at gmail.com>
> Signed-off-by: Boqun Feng <boqun.feng at gmail.com>
> Co-developed-by: Douglas Su <d0u9.su at outlook.com>
> Signed-off-by: Douglas Su <d0u9.su at outlook.com>
> Co-developed-by: Dariusz Sosnowski <dsosnowski at dsosnowski.pl>
> Signed-off-by: Dariusz Sosnowski <dsosnowski at dsosnowski.pl>
> Co-developed-by: Antonio Terceiro <antonio.terceiro at linaro.org>
> Signed-off-by: Antonio Terceiro <antonio.terceiro at linaro.org>
> Co-developed-by: Daniel Xu <dxu at dxuuu.xyz>
> Signed-off-by: Daniel Xu <dxu at dxuuu.xyz>
> Co-developed-by: Miguel Cano <macanroj at gmail.com>
> Signed-off-by: Miguel Cano <macanroj at gmail.com>
> Co-developed-by: David Gow <davidgow at google.com>
> Signed-off-by: David Gow <davidgow at google.com>
> Co-developed-by: Tiago Lam <tiagolam at gmail.com>
> Signed-off-by: Tiago Lam <tiagolam at gmail.com>
> Co-developed-by: Björn Roy Baron <bjorn3_gh at protonmail.com>
> Signed-off-by: Björn Roy Baron <bjorn3_gh at protonmail.com>
> Co-developed-by: Martin Rodriguez Reboredo <yakoyoku at gmail.com>
> Signed-off-by: Martin Rodriguez Reboredo <yakoyoku at gmail.com>
> Signed-off-by: Miguel Ojeda <ojeda at kernel.org>
> ---
> .gitignore | 6 +
> .rustfmt.toml | 12 +
> Makefile | 172 +++++++-
> arch/Kconfig | 6 +
> arch/arm/Kconfig | 1 +
> arch/arm64/Kconfig | 1 +
> arch/powerpc/Kconfig | 1 +
> arch/riscv/Kconfig | 1 +
> arch/riscv/Makefile | 5 +
> arch/um/Kconfig | 1 +
> arch/x86/Kconfig | 1 +
> arch/x86/Makefile | 10 +
> include/linux/compiler_types.h | 6 +-
> init/Kconfig | 46 +-
> lib/Kconfig.debug | 82 ++++
> rust/.gitignore | 10 +
> rust/Makefile | 415 +++++++++++++++++++
> rust/bindgen_parameters | 21 +
> scripts/.gitignore | 1 +
> scripts/Kconfig.include | 6 +-
> scripts/Makefile | 3 +
> scripts/Makefile.build | 60 +++
> scripts/Makefile.debug | 10 +
> scripts/Makefile.host | 34 +-
> scripts/Makefile.lib | 12 +
> scripts/Makefile.modfinal | 8 +-
> scripts/cc-version.sh | 12 +-
> scripts/generate_rust_target.rs | 232 +++++++++++
> scripts/is_rust_module.sh | 16 +
> scripts/kconfig/confdata.c | 75 ++++
> scripts/min-tool-version.sh | 6 +
> scripts/rust-is-available-bindgen-libclang.h | 2 +
> scripts/rust-is-available.sh | 160 +++++++
> 33 files changed, 1408 insertions(+), 26 deletions(-)
> create mode 100644 .rustfmt.toml
> create mode 100644 rust/.gitignore
> create mode 100644 rust/Makefile
> create mode 100644 rust/bindgen_parameters
> create mode 100644 scripts/generate_rust_target.rs
> create mode 100755 scripts/is_rust_module.sh
> create mode 100644 scripts/rust-is-available-bindgen-libclang.h
> create mode 100755 scripts/rust-is-available.sh
>
> @@ -151,7 +162,8 @@ config WERROR
> default COMPILE_TEST
> help
> A kernel build should not cause any compiler warnings, and this
> - enables the '-Werror' flag to enforce that rule by default.
> + enables the '-Werror' (for C) and '-Dwarnings' (for Rust) flags
> + to enforce that rule by default.
>
> However, if you have a new (or very old) compiler with odd and
> unusual warnings, or you have some architecture with problems,
> @@ -1898,6 +1910,38 @@ config PROFILING
> Say Y here to enable the extended profiling support mechanisms used
> by profilers.
>
> +config RUST
> + bool "Rust support"
> + depends on HAVE_RUST
> + depends on RUST_IS_AVAILABLE
> + depends on !MODVERSIONS
> + depends on !GCC_PLUGINS
> + depends on !RANDSTRUCT
> + depends on !DEBUG_INFO_BTF
> + select CONSTRUCTORS
> + help
> + Enables Rust support in the kernel.
> +
> + This allows other Rust-related options, like drivers written in Rust,
> + to be selected.
> +
> + It is also required to be able to load external kernel modules
> + written in Rust.
> +
> + See Documentation/rust/ for more information.
> +
> + If unsure, say N.
> +
> +config RUSTC_VERSION_TEXT
> + string
> + depends on RUST
> + default $(shell,command -v $(RUSTC) >/dev/null 2>&1 && $(RUSTC) --version || echo n)
> +
> +config BINDGEN_VERSION_TEXT
> + string
> + depends on RUST
> + default $(shell,command -v $(BINDGEN) >/dev/null 2>&1 && $(BINDGEN) --version || echo n)
> +
Where are these config options used?
I grep'ed but no hit.
masahiro at zoe:~/ref/linux-next$ git grep RUSTC_VERSION_TEXT
init/Kconfig:config RUSTC_VERSION_TEXT
masahiro at zoe:~/ref/linux-next$ git grep BINDGEN_VERSION_TEXT
init/Kconfig:config BINDGEN_VERSION_TEXT
> --
> 2.37.1
>
--
Best Regards
Masahiro Yamada
More information about the Linuxppc-dev
mailing list