meson icon indicating copy to clipboard operation
meson copied to clipboard

rustc target argument isn't passed to bindgen

Open TheComputerGuy96 opened this issue 1 year ago • 2 comments

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 https://github.com/rust-lang/rust-bindgen/commit/4f78afa67a574383123fe306b0927eb17bd40bf6)

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

TheComputerGuy96 avatar Aug 22 '24 16:08 TheComputerGuy96

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).

sadlerap avatar Aug 24 '24 02:08 sadlerap