[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAK7LNAQ=JfmrnGAUNXm_4RTz0fOhzfYC=htZ-VuEx=HAJPNtmw@mail.gmail.com>
Date: Tue, 13 Sep 2022 01:07:30 +0900
From: Masahiro Yamada <masahiroy@...nel.org>
To: Miguel Ojeda <ojeda@...nel.org>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
rust-for-linux@...r.kernel.org,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Linux FS-devel Mailing List <linux-fsdevel@...r.kernel.org>,
patches@...ts.linux.dev, Jarkko Sakkinen <jarkko@...nel.org>,
Alex Gaynor <alex.gaynor@...il.com>,
Finn Behrens <me@...enk.de>,
Adam Bratschi-Kaye <ark.email@...il.com>,
Wedson Almeida Filho <wedsonaf@...gle.com>,
Michael Ellerman <mpe@...erman.id.au>,
Sven Van Asbroeck <thesven73@...il.com>,
Gary Guo <gary@...yguo.net>,
Boris-Chengbiao Zhou <bobo1239@....de>,
Boqun Feng <boqun.feng@...il.com>,
Douglas Su <d0u9.su@...look.com>,
Dariusz Sosnowski <dsosnowski@...snowski.pl>,
Antonio Terceiro <antonio.terceiro@...aro.org>,
Daniel Xu <dxu@...uu.xyz>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Martin Rodriguez Reboredo <yakoyoku@...il.com>,
Michal Marek <michal.lkml@...kovi.net>,
Nick Desaulniers <ndesaulniers@...gle.com>,
Linux Kbuild mailing list <linux-kbuild@...r.kernel.org>
Subject: Re: [PATCH v9 23/27] Kbuild: add Rust support
On Sat, Aug 6, 2022 at 12:44 AM Miguel Ojeda <ojeda@...nel.org> wrote:
>
> Having most of the new files in place, we now enable Rust support
> in the build system, including `Kconfig` entries related to Rust,
> the Rust configuration printer and a few other bits.
>
> Co-developed-by: Alex Gaynor <alex.gaynor@...il.com>
> Signed-off-by: Alex Gaynor <alex.gaynor@...il.com>
> Co-developed-by: Finn Behrens <me@...enk.de>
> Signed-off-by: Finn Behrens <me@...enk.de>
> Co-developed-by: Adam Bratschi-Kaye <ark.email@...il.com>
> Signed-off-by: Adam Bratschi-Kaye <ark.email@...il.com>
> Co-developed-by: Wedson Almeida Filho <wedsonaf@...gle.com>
> Signed-off-by: Wedson Almeida Filho <wedsonaf@...gle.com>
> Co-developed-by: Michael Ellerman <mpe@...erman.id.au>
> Signed-off-by: Michael Ellerman <mpe@...erman.id.au>
> Co-developed-by: Sven Van Asbroeck <thesven73@...il.com>
> Signed-off-by: Sven Van Asbroeck <thesven73@...il.com>
> Co-developed-by: Gary Guo <gary@...yguo.net>
> Signed-off-by: Gary Guo <gary@...yguo.net>
> Co-developed-by: Boris-Chengbiao Zhou <bobo1239@....de>
> Signed-off-by: Boris-Chengbiao Zhou <bobo1239@....de>
> Co-developed-by: Boqun Feng <boqun.feng@...il.com>
> Signed-off-by: Boqun Feng <boqun.feng@...il.com>
> Co-developed-by: Douglas Su <d0u9.su@...look.com>
> Signed-off-by: Douglas Su <d0u9.su@...look.com>
> Co-developed-by: Dariusz Sosnowski <dsosnowski@...snowski.pl>
> Signed-off-by: Dariusz Sosnowski <dsosnowski@...snowski.pl>
> Co-developed-by: Antonio Terceiro <antonio.terceiro@...aro.org>
> Signed-off-by: Antonio Terceiro <antonio.terceiro@...aro.org>
> Co-developed-by: Daniel Xu <dxu@...uu.xyz>
> Signed-off-by: Daniel Xu <dxu@...uu.xyz>
> Co-developed-by: Björn Roy Baron <bjorn3_gh@...tonmail.com>
> Signed-off-by: Björn Roy Baron <bjorn3_gh@...tonmail.com>
> Co-developed-by: Martin Rodriguez Reboredo <yakoyoku@...il.com>
> Signed-off-by: Martin Rodriguez Reboredo <yakoyoku@...il.com>
> Signed-off-by: Miguel Ojeda <ojeda@...nel.org>
> ---
> .gitignore | 2 +
> Makefile | 172 ++++++++++++++-
> arch/Kconfig | 6 +
> include/linux/compiler_types.h | 6 +-
> init/Kconfig | 46 +++-
> kernel/configs/rust.config | 1 +
> lib/Kconfig.debug | 34 +++
> rust/.gitignore | 8 +
> rust/Makefile | 381 +++++++++++++++++++++++++++++++++
> rust/bindgen_parameters | 21 ++
> 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/kconfig/confdata.c | 75 +++++++
> scripts/min-tool-version.sh | 6 +
> 20 files changed, 877 insertions(+), 26 deletions(-)
> create mode 100644 kernel/configs/rust.config
> create mode 100644 rust/.gitignore
> create mode 100644 rust/Makefile
> create mode 100644 rust/bindgen_parameters
>
> diff --git a/.gitignore b/.gitignore
> index 97e085d613a2..5da004814678 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -37,6 +37,8 @@
> *.o
> *.o.*
> *.patch
> +*.rmeta
> +*.rsi
> *.s
> *.so
> *.so.dbg
> diff --git a/Makefile b/Makefile
> index df92892325ae..a105cb893b4c 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -120,6 +120,15 @@ endif
>
> export KBUILD_CHECKSRC
>
> +# Enable "clippy" (a linter) as part of the Rust compilation.
> +#
> +# Use 'make CLIPPY=1' to enable it.
> +ifeq ("$(origin CLIPPY)", "command line")
> + KBUILD_CLIPPY := $(CLIPPY)
> +endif
> +
> +export KBUILD_CLIPPY
> +
> # Use make M=dir or set the environment variable KBUILD_EXTMOD to specify the
> # directory of external module to build. Setting M= takes precedence.
> ifeq ("$(origin M)", "command line")
> @@ -267,14 +276,14 @@ no-dot-config-targets := $(clean-targets) \
> cscope gtags TAGS tags help% %docs check% coccicheck \
> $(version_h) headers headers_% archheaders archscripts \
> %asm-generic kernelversion %src-pkg dt_binding_check \
> - outputmakefile
> + outputmakefile rustavailable rustfmt rustfmtcheck
> # Installation targets should not require compiler. Unfortunately, vdso_install
> # is an exception where build artifacts may be updated. This must be fixed.
> no-compiler-targets := $(no-dot-config-targets) install dtbs_install \
> headers_install modules_install kernelrelease image_name
> no-sync-config-targets := $(no-dot-config-targets) %install kernelrelease \
> image_name
> -single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.s %.symtypes %/
> +single-targets := %.a %.i %.rsi %.ko %.lds %.ll %.lst %.mod %.o %.s %.symtypes %/
>
> config-build :=
> mixed-build :=
> @@ -436,6 +445,7 @@ else
> HOSTCC = gcc
> HOSTCXX = g++
> endif
> +HOSTRUSTC = rustc
> HOSTPKG_CONFIG = pkg-config
>
> KBUILD_USERHOSTCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \
> @@ -444,8 +454,26 @@ KBUILD_USERHOSTCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \
> KBUILD_USERCFLAGS := $(KBUILD_USERHOSTCFLAGS) $(USERCFLAGS)
> KBUILD_USERLDFLAGS := $(USERLDFLAGS)
>
> +# These flags apply to all Rust code in the tree, including the kernel and
> +# host programs.
> +export rust_common_flags := --edition=2021 \
> + -Zbinary_dep_depinfo=y \
Let me ask a question about the host_rust rule.
If I directly run the build command from the command line,
I get an error, like follows:
$ rustc --edition=2021 -Zbinary_dep_depinfo=y -Dunsafe_op_in_unsafe_fn
-Drust_2018_idioms -Dunreachable_pub -Dnon_ascii_idents -Wmissing_docs
-Drustdoc::missing_crate_level_docs -Dclippy::correctness
-Dclippy::style -Dclippy::suspicious -Dclippy::complexity
-Dclippy::perf -Dclippy::let_unit_value -Dclippy::mut_mut
-Dclippy::needless_bitwise_bool -Dclippy::needless_continue
-Wclippy::dbg_macro -O -Cstrip=debuginfo -Zallow-features=
--emit=dep-info,link --out-dir=scripts/
../scripts/generate_rust_target.rs
error: the option `Z` is only accepted on the nightly compiler
This is the same command recorded as in
scripts/.generate_rust_target.cmd
Why no error when it is invoked from Makefile?
I have not figured out where this difference comes from.
--
Best Regards
Masahiro Yamada
Powered by blists - more mailing lists