Re: [PATCH] rust: fix `ARCH_SLAB_MINALIGN` multiple definition error

From: Miguel Ojeda
Date: Thu Sep 26 2024 - 17:20:15 EST


On Mon, Sep 16, 2024 at 1:09 PM Gary Guo <gary@xxxxxxxxxxx> wrote:
>
> 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@xxxxxxxxx>
> Closes: https://lore.kernel.org/oe-kbuild-all/202409160804.eSg9zh1e-lkp@xxxxxxxxx/
> Signed-off-by: Gary Guo <gary@xxxxxxxxxxx>

Applied to `rust-fixes` -- thanks!

Cheers,
Miguel