rust-lang / rust-lang/rust-bindgen
Support for a GCC-based backend
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 829
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 15
Description
Currently, bindgen uses libclang to understand C/C++ code. https://github.com/rust-lang/rust-bindgen/pull/1740 considers moving to a lower-level interface for LLVM, with discussion of whether keeping support for several interfaces is feasible.
It would be great to have support for non-LLVM backends as well. In particular, a GCC-based one. Clang is very compatible with GCC nowadays (in both the Clang driver and the support for GNU C language extensions), but there are still differences here and there, which means one needs to be careful when applying bindgen in complex projects compiled with GCC.
It would require compiling a GCC plugin and using callbacks like PLUGIN_PRE_GENERICIZE ("Allows to see low level AST in C and C++ frontends.") and/or others like PLUGIN_FINISH_PARSE_FUNCTION, PLUGIN_FINISH_TYPE, PLUGIN_FINISH_DECL, etc.; or perhaps another way to use GCC's parser/tooling/etc.; or possibly using other approaches that fetch the information in another way (e.g. querying the compiler via generated C files or extracting it from debug information).
Of course, tackling this would be non-trivial, and it might not be worth the maintenance cost, but it might be an interesting project to expand bindgen's capabilities, as well as relaxing the dependency on LLVM.
Related: https://github.com/rust-lang/rust-bindgen/issues/2962.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the linked rust-bindgen pull request and issue 2962, then investigate GCC plugin callbacks such as PLUGIN_PRE_GENERICIZE and PLUGIN_FINISH_TYPE. Determine whether a GCC-based parsing approach can expose the information bindgen needs without making maintenance impractical; done means a defined backend design and implementation path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, cpp, rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100