rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Masahiro Yamada <masahiroy@kernel.org>
To: Miguel Ojeda <ojeda@kernel.org>
Cc: "Linus Torvalds" <torvalds@linux-foundation.org>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	rust-for-linux@vger.kernel.org,
	"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
	"Linux FS-devel Mailing List" <linux-fsdevel@vger.kernel.org>,
	patches@lists.linux.dev, "Jarkko Sakkinen" <jarkko@kernel.org>,
	"Alex Gaynor" <alex.gaynor@gmail.com>,
	"Finn Behrens" <me@kloenk.de>,
	"Adam Bratschi-Kaye" <ark.email@gmail.com>,
	"Wedson Almeida Filho" <wedsonaf@google.com>,
	"Michael Ellerman" <mpe@ellerman.id.au>,
	"Sven Van Asbroeck" <thesven73@gmail.com>,
	"Gary Guo" <gary@garyguo.net>,
	"Boris-Chengbiao Zhou" <bobo1239@web.de>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"Douglas Su" <d0u9.su@outlook.com>,
	"Dariusz Sosnowski" <dsosnowski@dsosnowski.pl>,
	"Antonio Terceiro" <antonio.terceiro@linaro.org>,
	"Daniel Xu" <dxu@dxuuu.xyz>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Martin Rodriguez Reboredo" <yakoyoku@gmail.com>,
	"Michal Marek" <michal.lkml@markovi.net>,
	"Nick Desaulniers" <ndesaulniers@google.com>,
	"Linux Kbuild mailing list" <linux-kbuild@vger.kernel.org>
Subject: Re: [PATCH v9 23/27] Kbuild: add Rust support
Date: Tue, 13 Sep 2022 01:07:30 +0900	[thread overview]
Message-ID: <CAK7LNAQ=JfmrnGAUNXm_4RTz0fOhzfYC=htZ-VuEx=HAJPNtmw@mail.gmail.com> (raw)
In-Reply-To: <20220805154231.31257-24-ojeda@kernel.org>

On Sat, Aug 6, 2022 at 12:44 AM Miguel Ojeda <ojeda@kernel.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@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: 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: Boqun Feng <boqun.feng@gmail.com>
> Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
> Co-developed-by: Douglas Su <d0u9.su@outlook.com>
> Signed-off-by: Douglas Su <d0u9.su@outlook.com>
> Co-developed-by: Dariusz Sosnowski <dsosnowski@dsosnowski.pl>
> Signed-off-by: Dariusz Sosnowski <dsosnowski@dsosnowski.pl>
> Co-developed-by: Antonio Terceiro <antonio.terceiro@linaro.org>
> Signed-off-by: Antonio Terceiro <antonio.terceiro@linaro.org>
> Co-developed-by: Daniel Xu <dxu@dxuuu.xyz>
> Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
> 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 <yakoyoku@gmail.com>
> Signed-off-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
> Signed-off-by: Miguel Ojeda <ojeda@kernel.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

  parent reply	other threads:[~2022-09-12 16:10 UTC|newest]

Thread overview: 102+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-05 15:41 [PATCH v9 00/27] Rust support Miguel Ojeda
2022-08-05 15:41 ` [PATCH v9 01/27] kallsyms: use `sizeof` instead of hardcoded size Miguel Ojeda
2022-08-05 16:48   ` Geert Stappers
2022-08-05 18:46     ` Miguel Ojeda
2022-08-05 22:40   ` Konstantin Shelekhin
2022-08-17 19:36     ` Kees Cook
2022-08-18  9:03       ` Konstantin Shelekhin
2022-08-18 16:03         ` Kees Cook
2022-09-27 12:48           ` Miguel Ojeda
2022-08-05 15:41 ` [PATCH v9 02/27] kallsyms: avoid hardcoding buffer size Miguel Ojeda
2022-08-17 19:37   ` Kees Cook
2022-08-18 16:50     ` Geert Stappers
2022-08-05 15:41 ` [PATCH v9 03/27] kallsyms: add static relationship between `KSYM_NAME_LEN{,_BUFFER}` Miguel Ojeda
2022-08-17 19:39   ` Kees Cook
2022-08-17 19:50     ` Boqun Feng
2022-08-17 20:31       ` Kees Cook
2022-08-17 20:45         ` Miguel Ojeda
2022-08-05 15:41 ` [PATCH v9 04/27] kallsyms: support "big" kernel symbols Miguel Ojeda
2022-08-05 15:41 ` [PATCH v9 05/27] kallsyms: increase maximum kernel symbol length to 512 Miguel Ojeda
2022-08-05 15:41 ` [PATCH v9 06/27] rust: add C helpers Miguel Ojeda
2022-08-17 19:44   ` Kees Cook
2022-08-17 20:22     ` Miguel Ojeda
2022-08-17 20:34       ` Kees Cook
2022-08-17 21:44         ` Miguel Ojeda
2022-08-17 23:56           ` Kees Cook
2022-08-18 16:03             ` Miguel Ojeda
2022-08-18 16:08               ` Kees Cook
2022-08-18 17:01                 ` Miguel Ojeda
2022-08-05 15:41 ` [PATCH v9 08/27] rust: adapt `alloc` crate to the kernel Miguel Ojeda
2022-08-05 15:41 ` [PATCH v9 09/27] rust: add `compiler_builtins` crate Miguel Ojeda
2022-08-17 20:08   ` Kees Cook
2022-08-22 23:55   ` Nick Desaulniers
2022-08-24 18:38     ` Nick Desaulniers
2022-08-29 17:11       ` Gary Guo
2022-08-05 15:41 ` [PATCH v9 10/27] rust: add `macros` crate Miguel Ojeda
2022-08-05 15:41 ` [PATCH v9 11/27] rust: add `bindings` crate Miguel Ojeda
2022-08-05 15:41 ` [PATCH v9 12/27] rust: add `kernel` crate Miguel Ojeda
2022-08-06 10:24   ` Konstantin Shelekhin
2022-08-06 11:22     ` Miguel Ojeda
2022-08-06 12:15       ` Konstantin Shelekhin
2022-08-06 14:57       ` Matthew Wilcox
2022-09-19 14:07         ` Wedson Almeida Filho
2022-09-19 16:09           ` Linus Torvalds
2022-09-19 17:20             ` Linus Torvalds
2022-09-19 18:05               ` Wedson Almeida Filho
2022-09-19 20:42                 ` Linus Torvalds
2022-09-19 22:35                   ` Wedson Almeida Filho
2022-09-19 23:39                     ` Linus Torvalds
2022-09-19 23:50                       ` Alex Gaynor
2022-09-19 23:58                         ` Linus Torvalds
2022-09-20  0:15                           ` Linus Torvalds
2022-09-20 15:55                             ` Eric W. Biederman
2022-09-20 22:39                               ` Gary Guo
2022-09-21  6:42                                 ` comex
2022-09-21 14:19                                   ` Boqun Feng
2022-10-03  2:03                                     ` comex
2022-09-20  0:40                           ` Boqun Feng
2022-10-03  4:17                             ` Kyle Strand
2022-09-20  0:41                       ` Wedson Almeida Filho
2022-09-21 11:23       ` Konstantin Shelekhin
2022-09-21 11:46         ` Greg KH
2022-08-05 15:41 ` [PATCH v9 13/27] rust: export generated symbols Miguel Ojeda
2022-08-17 20:11   ` Kees Cook
2022-08-05 15:41 ` [PATCH v9 14/27] vsprintf: add new `%pA` format specifier Miguel Ojeda
2022-08-05 15:42 ` [PATCH v9 15/27] scripts: checkpatch: diagnose uses of `%pA` in the C side as errors Miguel Ojeda
2022-08-05 15:42 ` [PATCH v9 16/27] scripts: checkpatch: enable language-independent checks for Rust Miguel Ojeda
2022-08-17 20:12   ` Kees Cook
2022-08-05 15:42 ` [PATCH v9 17/27] scripts: decode_stacktrace: demangle Rust symbols Miguel Ojeda
2022-08-05 15:42 ` [PATCH v9 18/27] scripts: add `generate_rust_analyzer.py` Miguel Ojeda
2022-08-17 20:13   ` Kees Cook
2022-08-05 15:42 ` [PATCH v9 19/27] scripts: add `generate_rust_target.rs` Miguel Ojeda
2022-08-17 20:14   ` Kees Cook
2022-08-05 15:42 ` [PATCH v9 20/27] scripts: add `rust_is_available.sh` Miguel Ojeda
2022-08-17 20:18   ` Kees Cook
2022-08-17 20:40     ` Miguel Ojeda
2022-08-22 20:09   ` Nick Desaulniers
2022-08-23 12:12     ` Miguel Ojeda
2022-08-23 12:16       ` Miguel Ojeda
2022-08-05 15:42 ` [PATCH v9 21/27] scripts: add `is_rust_module.sh` Miguel Ojeda
2022-08-17 20:19   ` Kees Cook
2022-08-05 15:42 ` [PATCH v9 22/27] rust: add `.rustfmt.toml` Miguel Ojeda
2022-08-17 20:19   ` Kees Cook
2022-08-05 15:42 ` [PATCH v9 23/27] Kbuild: add Rust support Miguel Ojeda
2022-08-17 20:26   ` Kees Cook
2022-08-17 20:56     ` Miguel Ojeda
2022-08-22 22:35   ` Nick Desaulniers
2022-09-12 16:07   ` Masahiro Yamada [this message]
2022-09-12 16:18     ` Miguel Ojeda
2022-09-13  6:37       ` Masahiro Yamada
2022-08-05 15:42 ` [PATCH v9 24/27] docs: add Rust documentation Miguel Ojeda
2022-08-05 15:42 ` [PATCH v9 25/27] x86: enable initial Rust support Miguel Ojeda
2022-08-17 20:27   ` Kees Cook
2022-08-05 15:42 ` [PATCH v9 26/27] samples: add first Rust examples Miguel Ojeda
2022-08-06 13:14   ` Konstantin Shelekhin
2022-08-17 21:02     ` Miguel Ojeda
2022-08-18  9:04       ` Konstantin Shelekhin
2022-08-17 20:28   ` Kees Cook
2022-08-05 15:42 ` [PATCH v9 27/27] MAINTAINERS: Rust Miguel Ojeda
2022-08-17 20:28   ` Kees Cook
2022-08-17 20:43     ` Miguel Ojeda
     [not found] ` <20220805154231.31257-8-ojeda@kernel.org>
2022-08-17 20:07   ` [PATCH v9 07/27] rust: import upstream `alloc` crate Kees Cook
2022-08-17 21:00     ` Miguel Ojeda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAK7LNAQ=JfmrnGAUNXm_4RTz0fOhzfYC=htZ-VuEx=HAJPNtmw@mail.gmail.com' \
    --to=masahiroy@kernel.org \
    --cc=alex.gaynor@gmail.com \
    --cc=antonio.terceiro@linaro.org \
    --cc=ark.email@gmail.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=bobo1239@web.de \
    --cc=boqun.feng@gmail.com \
    --cc=d0u9.su@outlook.com \
    --cc=dsosnowski@dsosnowski.pl \
    --cc=dxu@dxuuu.xyz \
    --cc=gary@garyguo.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=jarkko@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=me@kloenk.de \
    --cc=michal.lkml@markovi.net \
    --cc=mpe@ellerman.id.au \
    --cc=ndesaulniers@google.com \
    --cc=ojeda@kernel.org \
    --cc=patches@lists.linux.dev \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=thesven73@gmail.com \
    --cc=torvalds@linux-foundation.org \
    --cc=wedsonaf@google.com \
    --cc=yakoyoku@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).