rust: allow to use INIT_STACK_ALL_ZERO
authorAndrea Righi <andrea.righi@canonical.com>
Fri, 10 Feb 2023 21:51:41 +0000 (22:51 +0100)
committerMiguel Ojeda <ojeda@kernel.org>
Wed, 19 Apr 2023 17:34:43 +0000 (19:34 +0200)
commitd966c3cab924fb750fefef11e77a6fa07dd5420e
treedfa6a30c407a1a5729579615b05d7a0b8284d3ab
parentccc4505454db10402d5284f22d8b7db62e636fc5
rust: allow to use INIT_STACK_ALL_ZERO

With CONFIG_INIT_STACK_ALL_ZERO enabled, bindgen passes
-ftrivial-auto-var-init=zero to clang, that triggers the following
error:

 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'

However, this additional option that is currently required by clang is
deprecated since clang-16 and going to be removed in the future,
likely with clang-18.

So, make sure bindgen is using this extra option if the major version of
the libclang used by bindgen is < 16.

In this way we can enable CONFIG_INIT_STACK_ALL_ZERO with CONFIG_RUST
without triggering any build error.

Link: https://github.com/llvm/llvm-project/issues/44842
Link: https://github.com/llvm/llvm-project/blob/llvmorg-16.0.0-rc2/clang/docs/ReleaseNotes.rst#deprecated-compiler-flags
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
[Changed to < 16, added link and reworded]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
rust/Makefile