rust-lang / rust-lang/rust-bindgen
SVE `__SVInt32_t` parameters become a zero-sized opaque; rustc drops the argument
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 829
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 15
Description
Input C/C++ Header
int take(__SVInt32_t a, int t);
Bindgen Invocation
$ bindgen input.h -- -std=gnu11 -march=armv9-a+sve
Actual Results
bindgen 0.72.1 and 0.73.1 both turn the sizeless SVE vector into a zero-sized opaque blob (exit 0, default layout tests rustc-ok):
// 0.73.1
pub fn take(a: __BindgenOpaqueArray16<[u8; 0]>, t: c_int) -> c_int;
// 0.72.1
pub fn take(a: __BindgenOpaqueArray<u128, 0>, t: c_int) -> c_int;
Clang's LLVM for the same header keeps the scalable vector argument:
define i32 @take(<vscale x 4 x i32> %0, i32 noundef %1)
rustc of the generated bindings drops the ZST from the FFI signature (twice on each bindgen):
declare i32 @take(i32)
This is not GNU vector_size / ext_vector_type / NEON (those become arrays of the lane type). __SVInt32_t is a sizeless ACLE builtin; libclang reports size 0, and bindgen's opaque fallback uses that layout as the FFI argument. It is also not #727 / #3475: those are calling-convention enums on functions / function pointers. Here the data type of a parameter is wrong.
from_clang_ty has no arm for SVE sizeless vector kinds; they fall through to the opaque layout path with size 0.
Expected Results
Map SVE vector parameters as a real scalable-vector ABI (or skip take with a warning), not a ZST that rustc deletes from the signature.
Environment
bindgen: 0.72.1 and 0.73.1 (rust-lang/rust-bindgen 77cbc723)
clang/libclang: Homebrew clang 21.1.8
rustc: 1.97.1
target: aarch64-apple-darwin
OS: macOS (Apple M4)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the provided input.h and bindgen invocation, then inspect from_clang_ty handling for SVE sizeless vector kinds. The fix should preserve a real scalable-vector ABI in the generated signature or skip take with a warning, and should ensure rustc does not drop the parameter as a zero-sized type.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, rust
- Domain
- compilers, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100