`aarch64_vector_pcs` function pointers become a zero-sized opaque; rustc drops the argument
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
CXCallingConv_AArch64VectorCall が Abi::Vectorcall になる get_abi から始め、関数ポインター型とフィールドで UnsupportedAbi がどのように表現されるかを追ってください。提供されたヘッダーを bindgen で再現し、生成された Rust と LLVM のシグネチャを調べてください。非対応の vectorcall ポインターがポインターサイズのままになるか、引数を失う代わりに警告付きで宣言がスキップされれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Input C/C++ Header
typedef int (*fp)(int) __attribute__((aarch64_vector_pcs));
int apply(fp f, int x);
Bindgen Invocation
$ bindgen input.h -- -std=gnu11
Actual Results
bindgen 0.72.1 and 0.73.1 both turn the function-pointer type into a zero-sized opaque blob:
pub type fp = __BindgenOpaqueArray<[u32; 0]>;
pub fn apply(f: fp, x: c_int) -> c_int;
aarch64_vector_pcs is CXCallingConv_AArch64VectorCall, which get_abi maps to Abi::Vectorcall. On a stable rustc that ABI is UnsupportedAbi, so the function-pointer type becomes a 0-size opaque instead of *mut c_void / Option<unsafe extern "C" fn(i32) -> i32>. rustc then drops the ZST from the FFI signature:
; clang
define i32 @apply(ptr noundef %0, i32 noundef %1)
; rustc of the generated bindings (twice)
declare i32 @apply(i32)
A C caller apply(dummy, 7) passes the function pointer and 7. Generated Rust apply(Default::default(), 7) becomes apply(7) and the 7 lands in the pointer register.
This is not #727 / #2693: those abort or skip when the function itself has an unknown/unsupported CC. Here bindgen exits 0 and emits a callable apply with the wrong arity.
The same 0-size opaque happens for an aarch64_vector_pcs function-pointer field (struct S { int (*fp)(int,int) __attribute__((aarch64_vector_pcs)); int t; } — fp is [u32; 0] at offset 0 with t still at offset 8).
Expected Results
If vectorcall is not available, still emit a pointer-sized function-pointer type (or skip apply 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
- 主要言語
- Rust
- スター
- 5.3k
- フォーク
- 846
- 平均マージ
- 2日 6時間
- マージ済み PR(30日)
- 11
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
rust-lang/rust-bindgen のほかの issue
-
--enable-cxx-namespaces panics on namespace [[deprecated]] { ("[" is not a valid Ident)対応中かも @lwz23 が 47 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
rust-lang/rust-bindgen#3485 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
rust-lang/rust-bindgen#3483 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
rust-lang/rust-bindgen#3370 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
rust-lang/rust-bindgen#3363 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
rust-lang/rust-bindgen#3540 ·
メンテナーはふだん 1 日以内に返信
rust-lang/rust-bindgen の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
area:frontend kind:bug priority:p3 ready
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
bug priority: medium ui
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
storytold/vectorcraft#6333 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug lexer
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
yara-x fails to build with rsa 0.10.0: unresolved import rsa::Pkcs1v15Sign対応中かも @CfirTsabari が今日担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 87/100
VirusTotal/yara-x#865 ·
メンテナーはふだん 1 日以内に返信