Rust for Linux List
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: Andrea Righi <andrea.righi@canonical.com>
Cc: Miguel Ojeda <ojeda@kernel.org>,
	Alex Gaynor <alex.gaynor@gmail.com>,
	Wedson Almeida Filho <wedsonaf@gmail.com>,
	Boqun Feng <boqun.feng@gmail.com>, Gary Guo <gary@garyguo.net>,
	bjorn3_gh@protonmail.com,
	Nick Desaulniers <ndesaulniers@google.com>,
	Tom Rix <trix@redhat.com>,
	rust-for-linux@vger.kernel.org, llvm@lists.linux.dev,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] rust: allow to use INIT_STACK_ALL_ZERO
Date: Fri, 10 Feb 2023 10:39:27 -0700	[thread overview]
Message-ID: <Y+aBT8AD9RXde24X@dev-arch.thelio-3990X> (raw)
In-Reply-To: <20230210172203.101331-1-andrea.righi@canonical.com>

On Fri, Feb 10, 2023 at 06:22:03PM +0100, Andrea Righi wrote:
> With CONFIG_INIT_STACK_ALL_ZERO enabled, bindgen is passing
> -ftrivial-auto-var-init=zero to clang, that triggers the following:
> 
>   error: '-ftrivial-auto-var-init=zero' hasn't been enabled; enable it at your own peril for benchmarking purpose only with '-enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang'
> 
> This flag should be dropped in clang-17, but at the moment it seems more
> reasonable to add it to the bindgen CFLAGS to prevent the error above.
> 
> In this way we can enable CONFIG_INIT_STACK_ALL_ZERO with CONFIG_RUST
> without triggering any build error.
> 
> Link: https://reviews.llvm.org/D125142
> Signed-off-by: Andrea Righi <andrea.righi@canonical.com>

If this went via the kbuild tree, would we be able to use
$(CC_AUTO_VAR_INIT_ZERO_ENABLER)?

https://git.kernel.org/masahiroy/linux-kbuild/c/4e3feaad6ff8a7a57e3bf3308a93c93e3a2e17a6

Although, I suppose this could be a problem if the version of clang
being used to build the kernel does not support this flag while the
version of libclang in bindgen requires it?

> ---
>  rust/Makefile | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/rust/Makefile b/rust/Makefile
> index ff70c4c916f8..5e26db07a1dc 100644
> --- a/rust/Makefile
> +++ b/rust/Makefile
> @@ -267,7 +267,8 @@ BINDGEN_TARGET		:= $(BINDGEN_TARGET_$(SRCARCH))
>  # All warnings are inhibited since GCC builds are very experimental,
>  # many GCC warnings are not supported by Clang, they may only appear in
>  # some configurations, with new GCC versions, etc.
> -bindgen_extra_c_flags = -w --target=$(BINDGEN_TARGET)
> +bindgen_extra_c_flags = -w --target=$(BINDGEN_TARGET) \
> +			-enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
>  
>  bindgen_c_flags = $(filter-out $(bindgen_skip_c_flags), $(c_flags)) \
>  	$(bindgen_extra_c_flags)
> -- 
> 2.37.2
> 

  reply	other threads:[~2023-02-10 17:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-10 17:22 [PATCH] rust: allow to use INIT_STACK_ALL_ZERO Andrea Righi
2023-02-10 17:39 ` Nathan Chancellor [this message]
2023-02-10 21:37   ` Andrea Righi

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=Y+aBT8AD9RXde24X@dev-arch.thelio-3990X \
    --to=nathan@kernel.org \
    --cc=alex.gaynor@gmail.com \
    --cc=andrea.righi@canonical.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=gary@garyguo.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=ndesaulniers@google.com \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=trix@redhat.com \
    --cc=wedsonaf@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