rust-lang / rust-lang/rust-bindgen

Unable to generate bindings for when the _Atomic type qualifier is used

Open
#2,127 0 comments 0 reactions 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

I've been having a few issues with a library since it started to use the _Atomic type qualifier.

Input C/C++ Header
extern _Atomic(int) foo;
Bindgen Invocation
bindgen::Builder::default()
    .header("input.h")
    .generate()
    .unwrap()
Actual Results
error: failed to run custom build command for `issue-sys v0.1.0 (/home/taaitaaiger/Projects/Rust/issue-sys)`

Caused by:
  process didn't exit successfully: `/home/taaitaaiger/Projects/Rust/issue-sys/target/debug/build/issue-sys-e97ab64c9d2c68b7/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-changed=issue.h

  --- stderr
  thread 'main' panicked at 'assertion failed: `(left == right)`
    left: `177`,
   right: `118`: Couldn't resolve constant type, and it wasn't an nondeductible auto type!', /home/taaitaaiger/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.59.2/src/ir/var.rs:318:25
  stack backtrace:
     0: rust_begin_unwind
               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panicking.rs:517:5
     1: core::panicking::panic_fmt
               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/panicking.rs:100:14
     2: core::panicking::assert_failed_inner
     3: core::panicking::assert_failed
               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/panicking.rs:138:5
     4: <bindgen::ir::var::Var as bindgen::parse::ClangSubItemParser>::parse
               at /home/taaitaaiger/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.59.2/src/ir/var.rs:318:25
     5: <bindgen::ir::item::Item as bindgen::parse::ClangItemParser>::parse
               at /home/taaitaaiger/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.59.2/src/ir/item.rs:1384:9
     6: bindgen::parse_one
               at /home/taaitaaiger/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.59.2/src/lib.rs:2553:11
     7: bindgen::parse::{{closure}}::{{closure}}
               at /home/taaitaaiger/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.59.2/src/lib.rs:2594:31
     8: bindgen::clang::visit_children
               at /home/taaitaaiger/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.59.2/src/clang.rs:901:5
     9: <unknown>
    10: <unknown>
    11: <unknown>
    12: <unknown>
    13: clang_visitChildren
    14: clang_sys::clang_visitChildren
               at /home/taaitaaiger/.cargo/registry/src/github.com-1ecc6299db9ec823/clang-sys-1.3.0/src/link.rs:165:17
    15: bindgen::clang::Cursor::visit
               at /home/taaitaaiger/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.59.2/src/clang.rs:405:13
    16: bindgen::parse::{{closure}}
               at /home/taaitaaiger/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.59.2/src/lib.rs:2594:9
    17: bindgen::ir::context::BindgenContext::with_module
               at /home/taaitaaiger/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.59.2/src/ir/context.rs:2225:9
    18: bindgen::parse
               at /home/taaitaaiger/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.59.2/src/lib.rs:2593:5
    19: bindgen::Bindings::generate
               at /home/taaitaaiger/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.59.2/src/lib.rs:2371:13
    20: bindgen::Builder::generate
               at /home/taaitaaiger/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.59.2/src/lib.rs:1478:9
    21: build_script_build::main
               at ./build.rs:11:20
    22: core::ops::function::FnOnce::call_once
               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/ops/function.rs:227:5
  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Expected Results

The existence of foo should not cause the generation of bindings to fail.

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 input.h declaration and the bindgen::Builder invocation. Start at src/ir/var.rs around line 318, then follow the parsing path through src/ir/item.rs and lib.rs; build.rs line 11 shows the caller. Done means generation no longer fails merely because foo uses _Atomic.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, rust
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.