From: Christian Schrefl <chrisi.schrefl@gmail.com>
To: "Gary Guo" <gary@garyguo.net>,
lkp@intel.com, "Miguel Ojeda" <ojeda@kernel.org>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Wedson Almeida Filho" <wedsonaf@gmail.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <benno.lossin@proton.me>,
"Andreas Hindborg" <a.hindborg@samsung.com>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>
Cc: conor.dooley@microchip.com, linux-kernel@vger.kernel.org,
llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev,
palmer@rivosinc.com, rust-for-linux@vger.kernel.org
Subject: Re: [PATCH] rust: fix `ARCH_SLAB_MINALIGN` multiple definition error
Date: Thu, 19 Sep 2024 18:58:52 +0200 [thread overview]
Message-ID: <f994bff3-6e0a-4d57-9c86-257c304f513c@gmail.com> (raw)
In-Reply-To: <20240916003347.1744345-1-gary@garyguo.net>
On 16.09.24 2:33 AM, Gary Guo 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@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202409160804.eSg9zh1e-lkp@intel.com/
> Signed-off-by: Gary Guo <gary@garyguo.net>
> ---
> rust/bindgen_parameters | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/rust/bindgen_parameters b/rust/bindgen_parameters
> index a721d466bee4b..b7c7483123b7a 100644
> --- a/rust/bindgen_parameters
> +++ b/rust/bindgen_parameters
> @@ -24,3 +24,8 @@
> # These functions use the `__preserve_most` calling convention, which neither bindgen
> # nor Rust currently understand, and which Clang currently declares to be unstable.
> --blocklist-function __list_.*_report
> +
> +# These constants are sometimes not recognized by bindgen depending on config.
> +# We use const helpers to aid bindgen, to avoid conflicts when constants are
> +# recognized, block generation of the non-helper constants.
> +--blocklist-item ARCH_SLAB_MINALIGN
>
> base-commit: d077242d68a31075ef5f5da041bf8f6fc19aa231
This is also needed for 32-bit ARM support.
Reviewed-by: Christian Schrefl <chrisi.schrefl@gmail.com>
next prev parent reply other threads:[~2024-09-19 16:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <202409160804.eSg9zh1e-lkp@intel.com>
2024-09-16 0:33 ` [PATCH] rust: fix `ARCH_SLAB_MINALIGN` multiple definition error Gary Guo
2024-09-19 16:58 ` Christian Schrefl [this message]
2024-09-26 21:18 ` Miguel Ojeda
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f994bff3-6e0a-4d57-9c86-257c304f513c@gmail.com \
--to=chrisi.schrefl@gmail.com \
--cc=a.hindborg@samsung.com \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=benno.lossin@proton.me \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=conor.dooley@microchip.com \
--cc=gary@garyguo.net \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=llvm@lists.linux.dev \
--cc=oe-kbuild-all@lists.linux.dev \
--cc=ojeda@kernel.org \
--cc=palmer@rivosinc.com \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
--cc=wedsonaf@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).