rust-lang / rust-lang/rust-bindgen
Workaround for atomic types
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
typedef struct {
int m_rc;
unsigned m_cs_sz:16;
unsigned m_other:8;
unsigned m_tag:8;
} lean_object;
static inline _Atomic(int) * lean_get_rc_mt_addr(lean_object* o) {
return (_Atomic(int)*)(&(o->m_rc));
}
This case is narrowed down from lean.h
Bindgen Invocation
$ bindgen input.h --experimental --wrap-static-fns
Actual Results
When executing the above
panicked at main.rs:52:36:
Unable to generate bindings: Codegen(Serialize { msg: "Cannot serialize type kind Opaque", loc: "builtin definitions" })
Expected Results
The resulting type of lean_get_rc_mt_addr should be a rust atomic.
I've seen https://github.com/rust-lang/rust-bindgen/issues/2151, but is there a workaround of this other than blocklisting the above functions?
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 reproducing the panic with the provided input.h and bindgen input.h --experimental --wrap-static-fns, then compare the reduced example with the referenced lean.h definition. Investigate how the _Atomic(int)* return type is handled during binding generation. Done means the command no longer panics and the generated function uses an appropriate Rust atomic type, or a documented workaround is identified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, cpp, rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100