diff options
| author | David Rheinsberg <david@readahead.eu> | 2025-09-08 14:12:21 +0200 |
|---|---|---|
| committer | Dylan Baker <dylan@pnwbakers.com> | 2025-10-15 08:32:38 -0700 |
| commit | 2780f41723967f63b91a2999a79bb009d00b6065 (patch) | |
| tree | 295e71a903ab06e6c261103dfbc2ccc1974885ef /docs/markdown | |
| parent | 39ebb8598206d92b1f1f49b7589b7e299175683c (diff) | |
| download | meson-2780f41723967f63b91a2999a79bb009d00b6065.tar.gz | |
module/rust: set _FILE_OFFSET_BITS=64 for bindgen
Meson sets 64-bit offsets as the default for all platforms but MSVC.
Lets do the same for bindgen, to ensure we get compatible definitions.
Do this by calling `get_always_args()` on the first C'ish host compiler
we can find.
Note that the `libc` crate does not expose 64-bit types as the default
and there is no intention to do so. Instead, it exposes 32-bit default
types, plus the 64-bit extended types with the `*64` suffix. This is
quite unfortunate, but it seems unlikely to change [1].
However, use of `bindgen` is usually not tied to the `libc` crate.
Instead, it is tied to whatever other C code in the same project does.
And Meson sets `_FILE_OFFSET_BITS=64` unconditionally for all this C
code. It thus seems much more plausible for Meson to also imply it for
bindgen.
Given that Rust code that uses the `libc` crate very likely already uses
the `*64` suffixed variants, they are unaffected by whether
`_FILE_OFFSET_BITS=64` is set. If they use `libc::off_t`, they already
explicitly state that they use the 32-bit variant on 32-bit platforms.
Hence, it is inherently incompatible to C code that uses
`_FILE_OFFSET_BITS=64`.
And lastly, if a Meson project is Rust-only, but generates its internal
code from its public C headers, then it is better suited to actually
call `add_language('c')` and ensure that Meson knows what the compiler
configuration for the target platform actually is. Otherwise, bindgen
cannot know what platform options to enable. Hence, warn loudly if
`rust.bindgen()` is used without a configured C compiler (even if the
compiler used by bindgen does not necessarily match the configured one).
[1] https://github.com/rust-lang/libc/issues/3223#issuecomment-2033298952
Diffstat (limited to 'docs/markdown')
0 files changed, 0 insertions, 0 deletions
