rust-lang / rust-lang/rust-bindgen

Unable to generate bindings: ()

Open
#995 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-C++ A-libclang A-spe A-templates I-panic
Dominant language
Rust
Stars
5.3k
Forks
829
Avg merge
1d 1h
Merged PRs (30d)
15

Description

I am using this script https://gist.github.com/fitzgen/187381e358f60efa8194d0b276b4d11a.

The hashtag for my bindgen version is 4dd4ac7 .
The header file compiles with clang++ -std=c++11

$ ./b.sh bindgen abc.h

clang-4.0: warning: treating 'c-header' input as 'c++-header' when in C++ mode, this behavior is deprecated [-Wdeprecated]
abc.h:2:11: error: no member named 'c' in 'a<int>::(anonymous union at abc.h:3:3)'
abc.h:6:18: note: in instantiation of member function 'a<int>::a' requested here
abc.h:2:11: error: no member named 'c' in 'a<int>::(anonymous union at abc.h:3:3)', err: true
thread 'main' panicked at 'Unable to generate bindings: ()', /checkout/src/libcore/result.rs:860:4
stack backtrace:
   0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
             at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::_print
             at /checkout/src/libstd/sys_common/backtrace.rs:71
   2: std::panicking::default_hook::{{closure}}
             at /checkout/src/libstd/sys_common/backtrace.rs:60
             at /checkout/src/libstd/panicking.rs:380
   3: std::panicking::default_hook
             at /checkout/src/libstd/panicking.rs:396
   4: std::panicking::rust_panic_with_hook
             at /checkout/src/libstd/panicking.rs:611
   5: std::panicking::begin_panic_new
             at /checkout/src/libstd/panicking.rs:553
   6: std::panicking::begin_panic_fmt
             at /checkout/src/libstd/panicking.rs:521
   7: rust_begin_unwind
             at /checkout/src/libstd/panicking.rs:497
   8: core::panicking::panic_fmt
             at /checkout/src/libcore/panicking.rs:92
   9: core::result::unwrap_failed
             at /checkout/src/libcore/macros.rs:41
  10: <core::result::Result<T, E>>::expect
             at /checkout/src/libcore/result.rs:762
  11: bindgen::main::{{closure}}
             at src/main.rs:55
  12: std::panicking::try::do_call
             at /checkout/src/libstd/panicking.rs:479
  13: __rust_maybe_catch_panic
             at /checkout/src/libpanic_unwind/lib.rs:98
  14: std::panicking::try
             at /checkout/src/libstd/panicking.rs:458
  15: std::panic::catch_unwind
             at /checkout/src/libstd/panic.rs:361
  16: bindgen::main
             at src/main.rs:54
  17: __rust_maybe_catch_panic
             at /checkout/src/libpanic_unwind/lib.rs:98
  18: std::rt::lang_start
             at /checkout/src/libstd/panicking.rs:458
             at /checkout/src/libstd/panic.rs:361
             at /checkout/src/libstd/rt.rs:59
  19: main
  20: __libc_start_main
  21: _start
Interesting: bindgen failed to generate bindings for the test case!

$ cat abc.h

template <typename = int> struct a {
  a() { b.c; }
  union {
  } b;
};
a<> d() { return {}; }

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 failure with the linked script, clang++ command, and abc.h, then inspect src/main.rs where the binding-generation result is unwrapped. Trace why the clang diagnostic for the empty anonymous union becomes the "Unable to generate bindings" panic. Done means the case is handled without this panic and its behavior is covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, rust
Domain
compilers, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.