On Tue, Aug 2, 2022 at 10:53 AM Miguel Ojeda <ojeda@xxxxxxxxxx> 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@xxxxxxxxx> > Signed-off-by: Alex Gaynor <alex.gaynor@xxxxxxxxx> > Co-developed-by: Finn Behrens <me@xxxxxxxxx> > Signed-off-by: Finn Behrens <me@xxxxxxxxx> > Co-developed-by: Adam Bratschi-Kaye <ark.email@xxxxxxxxx> > Signed-off-by: Adam Bratschi-Kaye <ark.email@xxxxxxxxx> > Co-developed-by: Wedson Almeida Filho <wedsonaf@xxxxxxxxxx> > Signed-off-by: Wedson Almeida Filho <wedsonaf@xxxxxxxxxx> > Co-developed-by: Michael Ellerman <mpe@xxxxxxxxxxxxxx> > Signed-off-by: Michael Ellerman <mpe@xxxxxxxxxxxxxx> > Co-developed-by: Sven Van Asbroeck <thesven73@xxxxxxxxx> > Signed-off-by: Sven Van Asbroeck <thesven73@xxxxxxxxx> > Co-developed-by: Gary Guo <gary@xxxxxxxxxxx> > Signed-off-by: Gary Guo <gary@xxxxxxxxxxx> > Co-developed-by: Boris-Chengbiao Zhou <bobo1239@xxxxxx> > Signed-off-by: Boris-Chengbiao Zhou <bobo1239@xxxxxx> > Co-developed-by: Boqun Feng <boqun.feng@xxxxxxxxx> > Signed-off-by: Boqun Feng <boqun.feng@xxxxxxxxx> > Co-developed-by: Douglas Su <d0u9.su@xxxxxxxxxxx> > Signed-off-by: Douglas Su <d0u9.su@xxxxxxxxxxx> > Co-developed-by: Dariusz Sosnowski <dsosnowski@xxxxxxxxxxxxx> > Signed-off-by: Dariusz Sosnowski <dsosnowski@xxxxxxxxxxxxx> > Co-developed-by: Antonio Terceiro <antonio.terceiro@xxxxxxxxxx> > Signed-off-by: Antonio Terceiro <antonio.terceiro@xxxxxxxxxx> > Co-developed-by: Daniel Xu <dxu@xxxxxxxxx> > Signed-off-by: Daniel Xu <dxu@xxxxxxxxx> > Co-developed-by: Miguel Cano <macanroj@xxxxxxxxx> > Signed-off-by: Miguel Cano <macanroj@xxxxxxxxx> > Co-developed-by: David Gow <davidgow@xxxxxxxxxx> > Signed-off-by: David Gow <davidgow@xxxxxxxxxx> > Co-developed-by: Tiago Lam <tiagolam@xxxxxxxxx> > Signed-off-by: Tiago Lam <tiagolam@xxxxxxxxx> > Co-developed-by: Björn Roy Baron <bjorn3_gh@xxxxxxxxxxxxxx> > Signed-off-by: Björn Roy Baron <bjorn3_gh@xxxxxxxxxxxxxx> > Co-developed-by: Martin Rodriguez Reboredo <yakoyoku@xxxxxxxxx> > Signed-off-by: Martin Rodriguez Reboredo <yakoyoku@xxxxxxxxx> > Signed-off-by: Miguel Ojeda <ojeda@xxxxxxxxxx> > --- > .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@zoe:~/ref/linux-next$ git grep RUSTC_VERSION_TEXT init/Kconfig:config RUSTC_VERSION_TEXT masahiro@zoe:~/ref/linux-next$ git grep BINDGEN_VERSION_TEXT init/Kconfig:config BINDGEN_VERSION_TEXT > -- > 2.37.1 > -- Best Regards Masahiro Yamada