Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for both packed and aligned (in repr(C) #118018

Closed
koverstreet opened this issue Nov 17, 2023 · 1 comment
Closed

Support for both packed and aligned (in repr(C) #118018

koverstreet opened this issue Nov 17, 2023 · 1 comment
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue. T-opsem Relevant to the opsem team

Comments

@koverstreet
Copy link

bcachefs uses types that are both packed and aligned (to 4 or 8 bytes). We're looking to expand our use of Rust, and we need these types available via bindgen - they're our on disk format, so not easily changed.

Right now we're making this work via a bindgen patch that strips off aligned when packed is specified; however, this is incorrect and a lurking bug since specifying the alignment of at type can change the size - thus, Rust and C may end up disagreeing about the size and layout of these types.

Additionally, specifying aligned may give rustc additional useful information - in a packed, aligned(4) type, members up to 4 byte alignment may still be aligned correctly (depending on struct layout), whereas in a packed type rustc would not be able to assume that.

@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 17, 2023
@saethlin saethlin added T-lang Relevant to the language team, which will review and decide on the PR/issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-feature-request Category: A feature request, i.e: not implemented / a PR. T-opsem Relevant to the opsem team and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Nov 18, 2023
@RalfJung
Copy link
Member

Closing as duplicate of #100743

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue. T-opsem Relevant to the opsem team
Projects
None yet
Development

No branches or pull requests

4 participants