Thread (17 messages) 17 messages, 8 authors, 2022-09-06

Re: [PATCH v8 27/31] Kbuild: add Rust support

From: Masahiro Yamada <masahiroy@kernel.org>
Date: 2022-09-06 18:14:46
Also in: linux-arm-kernel, linux-kbuild, linux-riscv, linux-um, lkml, rust-for-linux

On Tue, Aug 2, 2022 at 10:53 AM Miguel Ojeda [off-list ref] 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 <redacted>
Signed-off-by: Alex Gaynor <redacted>
Co-developed-by: Finn Behrens <redacted>
Signed-off-by: Finn Behrens <redacted>
Co-developed-by: Adam Bratschi-Kaye <redacted>
Signed-off-by: Adam Bratschi-Kaye <redacted>
Co-developed-by: Wedson Almeida Filho <redacted>
Signed-off-by: Wedson Almeida Filho <redacted>
Co-developed-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Co-developed-by: Sven Van Asbroeck <redacted>
Signed-off-by: Sven Van Asbroeck <redacted>
Co-developed-by: Gary Guo <gary@garyguo.net>
Signed-off-by: Gary Guo <gary@garyguo.net>
Co-developed-by: Boris-Chengbiao Zhou <redacted>
Signed-off-by: Boris-Chengbiao Zhou <redacted>
Co-developed-by: Boqun Feng <redacted>
Signed-off-by: Boqun Feng <redacted>
Co-developed-by: Douglas Su <redacted>
Signed-off-by: Douglas Su <redacted>
Co-developed-by: Dariusz Sosnowski <redacted>
Signed-off-by: Dariusz Sosnowski <redacted>
Co-developed-by: Antonio Terceiro <redacted>
Signed-off-by: Antonio Terceiro <redacted>
Co-developed-by: Daniel Xu <redacted>
Signed-off-by: Daniel Xu <redacted>
Co-developed-by: Miguel Cano <redacted>
Signed-off-by: Miguel Cano <redacted>
Co-developed-by: David Gow <redacted>
Signed-off-by: David Gow <redacted>
Co-developed-by: Tiago Lam <redacted>
Signed-off-by: Tiago Lam <redacted>
Co-developed-by: Björn Roy Baron <bjorn3_gh@protonmail.com>
Signed-off-by: Björn Roy Baron <bjorn3_gh@protonmail.com>
Co-developed-by: Martin Rodriguez Reboredo <redacted>
Signed-off-by: Martin Rodriguez Reboredo <redacted>
Signed-off-by: Miguel Ojeda <ojeda@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




quoted hunk ↗ jump to hunk
@@ -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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help