From: Borislav Petkov <bp@alien8.de>
To: Alexander Altman <alexanderaltman@me.com>
Cc: kernel test robot <lkp@intel.com>,
llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev,
rust-for-linux@vger.kernel.org,
lkml <linux-kernel@vger.kernel.org>
Subject: Re: [bp:tip-x86-alternatives 1/1] error[E0588]: packed type cannot transitively contain a `#[repr(align)]` type
Date: Tue, 27 Dec 2022 22:14:24 +0100 [thread overview]
Message-ID: <Y6tgMM/qOnePXBQF@zn.tnic> (raw)
In-Reply-To: <76353487-736A-4470-AD31-77F47F8C08F6@me.com>
On Tue, Dec 27, 2022 at 12:31:17PM -0800, Alexander Altman wrote:
> That caused Rust’s bindgen (bindings generator) to generate a type for the
> altered field that indirectly included a representation of the
> bitfields...which have a greater-than-natural alignment because of their
> encoding (they’re represented as an array of 4 8-bit unsigned integers, but
> aligned as if they’re a single 16-bit unsigned integer). This interacts
> badly with the top-level command to make the alt_instr struct packed, which
> bindgen faithfully translates from C __packed to Rust #[repr(packed)].
This sounds like a rust problem to me. Because, AFAICT, this is
perfectly valid C and both compilers haven't complained even with all
the possible warnings turned on.
> One way to resolve this temporarily would be to add the following line above
> the offending struct:
> /// <div rustbindgen hide></div>
Nah, I don't think I'll accept a fix for the shortcomings of yet another tool.
> This will cause bindgen to ignore the struct entirely and not translate it. If it’s
> actually needed for Rust code, now or later, then we can’t do that and need
> to actually replace it with something translatable, or else leave it hidden and
> manually create its translation on the Rust side. For the latter, just using a
> u32 for the entire bitfield-containing union would be sufficient.
Yap, that sounds like the right thing to do.
Thx.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
next prev parent reply other threads:[~2022-12-27 21:15 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <202212272003.rgQDX8DQ-lkp@intel.com>
[not found] ` <Y6r4mXz5NS0+HVXo@zn.tnic>
2022-12-27 14:16 ` [bp:tip-x86-alternatives 1/1] error[E0588]: packed type cannot transitively contain a `#[repr(align)]` type Borislav Petkov
2022-12-27 20:31 ` Alexander Altman
2022-12-27 21:14 ` Borislav Petkov [this message]
2023-01-06 23:26 ` Miguel Ojeda
2023-01-07 0:42 ` Miguel Ojeda
2023-01-06 23:25 ` Miguel Ojeda
2023-01-06 23:57 ` Borislav Petkov
2023-01-07 0:38 ` Miguel Ojeda
2023-01-12 16:14 ` Borislav Petkov
2023-01-14 2:18 ` Gary Guo
2023-01-14 12:29 ` Miguel Ojeda
2023-01-14 11:54 ` Miguel Ojeda
2023-01-14 15:35 ` David Laight
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=Y6tgMM/qOnePXBQF@zn.tnic \
--to=bp@alien8.de \
--cc=alexanderaltman@me.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=llvm@lists.linux.dev \
--cc=oe-kbuild-all@lists.linux.dev \
--cc=rust-for-linux@vger.kernel.org \
/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).