[PATCH] Add -fzero-init-padding-bits to bindgen_skip_cflags

Justin M. Forbes posted 1 patch 1 year ago
rust/Makefile | 1 +
1 file changed, 1 insertion(+)
[PATCH] Add -fzero-init-padding-bits to bindgen_skip_cflags
Posted by Justin M. Forbes 1 year ago
This seems to break the build when building with gcc15.

Unable to generate bindings: ClangDiagnostic("error: unknown argument: '-fzero-init-padding-bits=all'\n")

Signed-off-by: Justin M. Forbes <jforbes@fedoraproject.org>
---
 rust/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/rust/Makefile b/rust/Makefile
index 71a05a3c895a..3c3da7faebb3 100644
--- a/rust/Makefile
+++ b/rust/Makefile
@@ -240,6 +240,7 @@ bindgen_skip_c_flags := -mno-fp-ret-in-387 -mpreferred-stack-boundary=% \
 	-fzero-call-used-regs=% -fno-stack-clash-protection \
 	-fno-inline-functions-called-once -fsanitize=bounds-strict \
 	-fstrict-flex-arrays=% -fmin-function-alignment=% \
+	-fzero-init-padding-bits=% \
 	--param=% --param asan-%
 
 # Derived from `scripts/Makefile.clang`.
-- 
2.47.1
Re: [PATCH] Add -fzero-init-padding-bits to bindgen_skip_cflags
Posted by Kees Cook 1 year ago
On Wed, Jan 29, 2025 at 02:50:02PM -0700, Justin M. Forbes wrote:
> This seems to break the build when building with gcc15.
> 
> Unable to generate bindings: ClangDiagnostic("error: unknown argument: '-fzero-init-padding-bits=all'\n")
> 
> Signed-off-by: Justin M. Forbes <jforbes@fedoraproject.org>

Thanks for this! I keep forgetting to keep flags in sync. I wonder if
there is a way to automate some kind of warning for this (even when
CONFIG_RUST=n)?

Reviewed-by: Kees Cook <kees@kernel.org>

Miguel, I see you took this already -- is it planned to land for -rc2?

Thanks!

-Kees

-- 
Kees Cook
Re: [PATCH] Add -fzero-init-padding-bits to bindgen_skip_cflags
Posted by Miguel Ojeda 1 year ago
On Thu, Feb 6, 2025 at 4:45 PM Kees Cook <kees@kernel.org> wrote:
>
> Thanks for this! I keep forgetting to keep flags in sync. I wonder if
> there is a way to automate some kind of warning for this (even when
> CONFIG_RUST=n)?

You mean at editing time?

> Reviewed-by: Kees Cook <kees@kernel.org>

Thanks! I will add it.

> Miguel, I see you took this already -- is it planned to land for -rc2?

Possibly, depends on how it goes; otherwise -rc3 -- why?

Cheers,
Miguel
Re: [PATCH] Add -fzero-init-padding-bits to bindgen_skip_cflags
Posted by Kees Cook 1 year ago
On Thu, Feb 06, 2025 at 04:55:21PM +0100, Miguel Ojeda wrote:
> On Thu, Feb 6, 2025 at 4:45 PM Kees Cook <kees@kernel.org> wrote:
> >
> > Thanks for this! I keep forgetting to keep flags in sync. I wonder if
> > there is a way to automate some kind of warning for this (even when
> > CONFIG_RUST=n)?
> 
> You mean at editing time?
> 
> > Reviewed-by: Kees Cook <kees@kernel.org>
> 
> Thanks! I will add it.
> 
> > Miguel, I see you took this already -- is it planned to land for -rc2?
> 
> Possibly, depends on how it goes; otherwise -rc3 -- why?

Many subsystems base their trees on -rc2, so if it missed rc2, Rust builds
in a given subsystem will be broken under gcc 15 (but fine in -next).
But perhaps that's enough of a corner case that it doesn't matter? I
have other fixes I'm sending to Linus tomorrow, if you'd rather it go in
sooner? I'm fine either way. :)

-- 
Kees Cook
Re: [PATCH] Add -fzero-init-padding-bits to bindgen_skip_cflags
Posted by Miguel Ojeda 1 year ago
On Thu, Feb 6, 2025 at 7:48 PM Kees Cook <kees@kernel.org> wrote:
>
> Many subsystems base their trees on -rc2, so if it missed rc2, Rust builds
> in a given subsystem will be broken under gcc 15 (but fine in -next).
> But perhaps that's enough of a corner case that it doesn't matter? I
> have other fixes I'm sending to Linus tomorrow, if you'd rather it go in
> sooner? I'm fine either way. :)

Ah, I see.

The Rust-enabled-mixed-GCC/Clang builds are best-effort at the moment
(this should not affect the normal Clang ones) and GCC 15 is still at
least a couple months away as far as I understand, right?

In any case, I can send what I have for -rc2, since I think I will
have others for -rc3 anyway.

Cheers,
Miguel
Re: [PATCH] Add -fzero-init-padding-bits to bindgen_skip_cflags
Posted by Miguel Ojeda 1 year ago
On Wed, Jan 29, 2025 at 10:50 PM Justin M. Forbes
<jforbes@fedoraproject.org> wrote:
>
> This seems to break the build when building with gcc15.
>
> Unable to generate bindings: ClangDiagnostic("error: unknown argument: '-fzero-init-padding-bits=all'\n")
>
> Signed-off-by: Justin M. Forbes <jforbes@fedoraproject.org>

Applied to `rust-fixes` -- thanks!

Fixes: dce4aab8441d ("kbuild: Use -fzero-init-padding-bits=all")

[ Slightly reworded commit. - Miguel ]

Cheers,
Miguel