rust-lang / rust-lang/rust-bindgen

if size_t_is_usize is set to true, and bindgen handles a size_t, and size_t ≠ uintptr_t, bindgen should abort

Open
#1,903 0 comments 1 reaction 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

Many projects (including nettle-sys, linux-kernel-module-rust, nodejs-sys, bcc-sys) are moving to revert to the pre-0.53 behavior that maps size_t and usize. These projects (and many others if #1902 is merged) will fail subtly if they use bindgen over a C API that includes size_t on a weird niche platform where size_tuintptr_t. if bindgen detects that this situation is happening, it should produce an error.

the three conditions that should produce an error (all conditions must be present) are:

  • size_t_is_usize is set to true
  • The source C API includes a size_t
  • The platform's size_t is not the same underlying type as uintptr_t

(see also #1901 and #1671 for background)

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 reviewing bindgen's size_t_is_usize option and its size_t handling, then read issues #1902, #1901, and #1671 for the surrounding behavior. Done means bindgen reports an error only when the option is true, the C API uses size_t, and size_t differs from uintptr_t on the target platform.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Bug
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.