Rust for Linux List
 help / color / mirror / Atom feed
* [PATCH] rust: allow to use INIT_STACK_ALL_ZERO
@ 2023-02-10 17:22 Andrea Righi
  2023-02-10 17:39 ` Nathan Chancellor
  0 siblings, 1 reply; 3+ messages in thread
From: Andrea Righi @ 2023-02-10 17:22 UTC (permalink / raw)
  To: Miguel Ojeda, Alex Gaynor, Wedson Almeida Filho
  Cc: Boqun Feng, Gary Guo, bjorn3_gh, Nathan Chancellor,
	Nick Desaulniers, Tom Rix, rust-for-linux, llvm, linux-kernel

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>
---
 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-02-10 21:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-10 17:22 [PATCH] rust: allow to use INIT_STACK_ALL_ZERO Andrea Righi
2023-02-10 17:39 ` Nathan Chancellor
2023-02-10 21:37   ` Andrea Righi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox