Nothing Special   »   [go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_Atomic crashes bindgen even when blocklisted #2920

Closed
Kriskras99 opened this issue Sep 2, 2024 · 3 comments · Fixed by #2921
Closed

_Atomic crashes bindgen even when blocklisted #2920

Kriskras99 opened this issue Sep 2, 2024 · 3 comments · Fixed by #2921

Comments

@Kriskras99
Copy link
Contributor

Input C/C++ Header

_Atomic(int) a;
int b;

Bindgen Invocation

$ bindgen --blocklist-item "a" input.h

Actual Results

$ RUST_BACKTRACE=1 bindgen --blocklist-item "a" input.h
panicked at /home/kriskras99/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bindgen-0.70.1/ir/var.rs:319:25:
Couldn't resolve constant type, and it wasn't an nondeductible auto type or unexposed type!
panicked at core/src/panicking.rs:221:5:
panic in a function that cannot unwind
thread caused non-unwinding panic. aborting.
[1]    21518 IOT instruction (core dumped)  RUST_BACKTRACE=1 bindgen --blocklist-item "a" input.h

Expected Results

I expect bindgen to ignore the _Atomic type as it is on a blocklist:

/* automatically generated by rust-bindgen 0.70.1 */

extern "C" {
    pub static mut b: ::std::os::raw::c_int;
}

In addition, I think the panic message is confusing and should be more like "_Atomic types are not supported" or something similar.

@Kriskras99
Copy link
Contributor Author
Kriskras99 commented Sep 2, 2024

Potential solution could be generating _Atomic types as compile_error!("_Atomic types are not supported by bindgen").
This would give a clear error message to users (instead of Couldn't resolve constant type, ...) and would allow blocklist_.* and opaque_type to remove it.
Downside is that this would push the error to the Rust compilation step instead of the Bindgen step.

@emilio
Copy link
Contributor
emilio commented Sep 2, 2024

We should probably just generate the underlying type for now. Maybe we should do something smarter but rust doesn't have generic atomics so it's going to be a bit of a whack-a-mole.

emilio added a commit to emilio/rust-bindgen that referenced this issue Sep 2, 2024
emilio added a commit to emilio/rust-bindgen that referenced this issue Sep 2, 2024
@emilio
Copy link
Contributor
emilio commented Sep 2, 2024

#2921 has an initial pass at not crashing here at least.

emilio added a commit to emilio/rust-bindgen that referenced this issue Sep 2, 2024
emilio added a commit to emilio/rust-bindgen that referenced this issue Sep 2, 2024
github-merge-queue bot pushed a commit that referenced this issue Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants