rust-lang / rust-bindgen

Automatically generates Rust FFI bindings to C (and some C++) libraries.
https://rust-lang.github.io/rust-bindgen/
BSD 3-Clause "New" or "Revised" License
4.23k stars 679 forks source link

Unable to run bindgen on ubuntu 22.04 #2837

Closed uglyoldbob closed 1 month ago

uglyoldbob commented 1 month ago

When running bindgen on an ubuntu 22.04 system, I get an assert error.

thread 'main' panicked at /home/thomas/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bindgen-0.69.4/lib.rs:899:13: assertion left == right failed: "x86_64-unknown-linux-gnu" "x86_64-unknown-linux-gnu" left: 2 right: 8 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

pvdrz commented 1 month ago

Hi!

Bindgen's CI workflows runs on ubuntu 22.04 already, which means that any issue you're seeing is related somehow to your system's configuration.

This particular assertion error points to different pointer size between the effective target (the one clang uses) and the host target. Meaning that your development environment convinced clang that pointers in x86_64 are not 8 bytes long.

uglyoldbob commented 1 month ago

Apparently bindgen was picking up clang for a totally different architecture. I just uninstalled it and its working now.