SVE `__SVInt32_t` parameters become a zero-sized opaque; rustc drops the argument

Open
#3,477 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
c, rust

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.

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)
Dominant language
Rust
Stars
5.3k
Forks
846
Avg merge
2d 6h
Merged PRs (30d)
11

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rust-lang/rust-bindgen

All issues in rust-lang/rust-bindgen

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.