rust-lang / rust-lang/rust-bindgen

Feature Request: Make layout tests adaptive to word length of target arch

Open
#2,033 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Rust
Stars
5.3k
Forks
829
Avg merge
1d 1h
Merged PRs (30d)
15

Description

Currently, if I run bindgen on a 64 bit machine, the generated layout tests will fail on a 32 Bit machine. The reason is, that the layout tests test the exact layout of the machine on which the bindings where generated. I have a use case where it is quite a burden to ship the c header files with the rust crate. Thus I prefer generating the bindings once, and then shipping the generated bindings. However, if I do so, some layout tests fails, as some structures have different representation depending on the word length of the current system. I think it would be a good enhancement to make the layout tests check that the layout of the rust types matches those of the equivalent C types on the target platform (versus the current behavior, where they try to match the platform where bindgen was invoked).

To my surprise I did not find this request in the issues (maybe I overlooked something obvious?) thus I put it here. Any opinions appreciated 😄 !

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing bindgen’s generated layout tests and how they encode the host platform’s word length; compare that with the equivalent C types on the target platform. Done means bindings generated on one word length can run layout tests correctly on another without shipping the headers.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, rust
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.