Skip to content

Commit 344b6c0

Browse files
Andrea Righiojeda
Andrea Righi
authored andcommitted
rust: fix bindgen build error with fstrict-flex-arrays
Commit df8fc4e ("kbuild: Enable -fstrict-flex-arrays=3") enabled '-fstrict-flex-arrays=3' globally, but bindgen does not recognized this compiler option, triggering the following build error: error: unknown argument: '-fstrict-flex-arrays=3', err: true [ Miguel: Commit df8fc4e ("kbuild: Enable -fstrict-flex-arrays=3") did it so only conditionally (i.e. only if the C compiler supports it). This explains what Andrea was seeing: he was compiling with a modern enough GCC, which enables the option, but with an old enough Clang. Andrea confirmed this was the case: he was using Clang 14 with GCC 13; and that Clang 15 worked for him. While it is possible to construct code (see mailing list for an example I came up with) where this could break, it is fairly contrived, and anyway GCC-built kernels with Rust enabled should only be used for experimentation until we get support for `rustc_codegen_gcc` and/or GCC Rust. So let's add this for the time being in case it helps somebody. ] Add '-fstrict-flex-arrays' to the list of cflags that should be ignored by bindgen. Fixes: df8fc4e ("kbuild: Enable -fstrict-flex-arrays=3") Signed-off-by: Andrea Righi <[email protected]> Tested-by: Gary Guo <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
1 parent 2a7e0a5 commit 344b6c0

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

rust/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ bindgen_skip_c_flags := -mno-fp-ret-in-387 -mpreferred-stack-boundary=% \
290290
-fno-reorder-blocks -fno-allow-store-data-races -fasan-shadow-offset=% \
291291
-fzero-call-used-regs=% -fno-stack-clash-protection \
292292
-fno-inline-functions-called-once -fsanitize=bounds-strict \
293+
-fstrict-flex-arrays=% \
293294
--param=% --param asan-%
294295

295296
# Derived from `scripts/Makefile.clang`.

0 commit comments

Comments
 (0)