Skip to content

Commit 732cd68

Browse files
nbdd0121ojeda
authored andcommitted
rust: fix ARCH_SLAB_MINALIGN multiple definition error
We use const helpers in form of const size_t RUST_CONST_HELPER_ARCH_SLAB_MINALIGN = ARCH_SLAB_MINALIGN; to aid generation of constants by bindgen because it is otherwise a macro definition of an expression and bindgen doesn't expand the constant. The helpers are then have `RUST_CONST_HELPER` prefix stripped and exposed to Rust code as if `ARCH_SLAB_MISALIGN` is generated natively by bindgen. This works well for most constants, but on RISC-V, `ARCH_SLAB_MINALIGN` is defined directly as literal constant if `!CONFIG_MMU`, and bindgen would generate `ARCH_SLAB_MINALIGN` directly, thus conflict with the one generated through the helper. To fix this, we simply need to block bindgen from generating directly without going through helper. Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202409160804.eSg9zh1e-lkp@intel.com/ Signed-off-by: Gary Guo <gary@garyguo.net> Reviewed-by: Christian Schrefl <chrisi.schrefl@gmail.com> Link: https://lore.kernel.org/r/20240916003347.1744345-1-gary@garyguo.net Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
1 parent a8ee30f commit 732cd68

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

rust/bindgen_parameters

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,8 @@
2424
# These functions use the `__preserve_most` calling convention, which neither bindgen
2525
# nor Rust currently understand, and which Clang currently declares to be unstable.
2626
--blocklist-function __list_.*_report
27+
28+
# These constants are sometimes not recognized by bindgen depending on config.
29+
# We use const helpers to aid bindgen, to avoid conflicts when constants are
30+
# recognized, block generation of the non-helper constants.
31+
--blocklist-item ARCH_SLAB_MINALIGN

0 commit comments

Comments
 (0)