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

rustc target argument isn't passed to bindgen #13591

Open
TheComputerGuy96 opened this issue Aug 22, 2024 · 1 comment
Open

rustc target argument isn't passed to bindgen #13591

TheComputerGuy96 opened this issue Aug 22, 2024 · 1 comment
Assignees
Labels
bug module:rust Specific to the Rust module

Comments

@TheComputerGuy96
Copy link

Describe the bug
So the rustc --target argument (which is usually included in the rust value of cross
files) isn't passed to the bindgen command line

This isn't a problem in non-cross builds, but with cross builds the struct size validation
fails with variable-length types like pointers (which was an optional thing but now it's
enabled by default with rust-lang/rust-bindgen@4f78afa)

This issue was also reported on https://gitlab.freedesktop.org/mesa/mesa/-/issues/11735

To reproduce
https://gist.github.com/TheComputerGuy96/8069e05f5db26a304bc11026ca07c290

To compile those files on Arch Linux: meson setup --cross-file lib32 build && meson compile -C build
(you possibly need to make a cross file in other distros)

Expected behavior
The rustc target argument should be passed to bindgen (with the correct struct sizes for 32-bit cross build)

System parameters

  • I'm building x86 code on an AMD64 system (so it's definitely a 32-bit on 64-bit cross build)
  • Arch Linux
  • Python 3.12.4
  • Meson 1.5.1
  • Ninja 1.12.1
@sadlerap
Copy link

sadlerap commented Aug 24, 2024

As a bit of a workaround, I found setting the env var BINDGEN_EXTRA_CLANG_ARGS to either --target=i686-unknown-linux-gnu or -target i686-unknown-linux-gnu got things compiling correctly. You'll need to set it during the build process (when you call meson compile -C build).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug module:rust Specific to the Rust module
Projects
None yet
Development

No branches or pull requests

3 participants