rust-lang / rust-lang/rust-bindgen

Generated tests are not compatible across architectures

Open
#1,213 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Input C/C++ Header
struct Foo {
   int bar;
};
Bindgen Invocation

Run on x86_64-apple-darwin:

$ bindgen input.h

Test with: cargo test --target=i686-apple-darwin

Actual Results
fn bindgen_test_layout_Foo ( ) …
Expected Results

The tests are valid only on the architecture bindgen was run on. It would be great if bindgen was able to make tests portable, e.g.:

#[cfg(target_pointer_width = "64")]
fn bindgen_test_layout_Foo ( ) …

#[cfg(target_pointer_width = "32")]
fn bindgen_test_layout_Foo ( ) …

Currently this isn't easy to do even manually, because tests are interleaved with other code, so combining of 32- and 64-bit files requires advanced regex-fu.

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

Reproduce the issue with the shown input.h, bindgen invocation, and cargo test --target=i686-apple-darwin command. Inspect the generated bindgen_test_layout_Foo functions and how layout tests are interleaved with other generated code. Done means generated tests remain valid when bindgen runs on x86_64-apple-darwin and tests run on i686-apple-darwin.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, cpp, rust
Domain
compilers, testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.