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

オープン
#3,477 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
c, rust

調査の方向性

提供された input.h と bindgen の呼び出しで問題を再現し、その後、SVE のサイズレスベクトル型に対する from_clang_ty の処理を調査してください。修正では、生成されるシグネチャで実際のスケーラブルベクトル ABI を維持するか、警告を出して take をスキップし、rustc がパラメータをゼロサイズ型として削除しないようにする必要があります。

索引モデルが issue の本文から書いたものです。

説明

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)
主要言語
Rust
スター
5.3k
フォーク
846
平均マージ
2日 6時間
マージ済み PR(30日)
11

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

rust-lang/rust-bindgen のほかの issue

rust-lang/rust-bindgen の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。