rust-lang / rust-lang/rust-bindgen

Making ir publicly accessible

Open
#2,198 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Hi, I'd like to use bindgen to parse headers into ir without the codegen part, and then with ir I can generate bindings in other languages.

There is --emit-ir, but that's in debug format which is not easily readable by machines.

I think we can make the ir module public (may need some cleanup though), and/or add a --emit-ir-jsonoption to emit ir in json represetantion, something like:

{
   "kind": "function",
   "name": "foo",
   "mangledName": "_foo",
   "signature": {
      "returnType": ...,
      "params": [ ... ]
   },
}

I'd be happy to work on a PR, if such change doesn't fall out of bindgen's scope.

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 inspecting the existing --emit-ir entry point and the ir module to understand how the current debug representation is produced. Compare the two proposed directions—making ir public or adding JSON emission—and define the supported machine-readable interface, including its scope and cleanup needs. Done means the chosen interface is usable for parsing bindgen IR without invoking code generation.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.