Using asm labels in function declaration produces unexpected bindings

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

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

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

評価

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

調査の方向性

Start by reading bindgen's handling of C function declarations and asm labels, then reproduce the provided syslog example with the stated bindgen version and compare the generated declarations. The issue does not name a source file or test; trace the parsing and code generation paths involved and add a regression test for the example. Done means the renamed function produces one binding instead of two.

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

説明

gcc (and clang which I guess inherited the extension) allows a function to be declared with one name, but redirect calls to a function of a different name [1]. glibc makes heavy use of the feature to support multiple versions of long double on multiple targets. Some powerpc64le distros have switched the long double format, which turns on these awkward redirections.

A simplified and preprocessed example of syslog from syslog.h on powerpc64le on fedora 44 looks like:

extern void syslog (int __pri, const char *__fmt, ...);
extern __typeof (syslog) syslog __asm ("__syslogieee128");

Which produces the following from bindgen:

/* automatically generated by rust-bindgen 0.72.1 */

unsafe extern "C" {
    pub fn syslog(__pri: ::std::os::raw::c_int, __fmt: *const ::std::os::raw::c_char, ...);
}
unsafe extern "C" {
    #[link_name = "\u{1}__syslogieee128"]
    pub fn syslog1(arg1: ::std::os::raw::c_int, arg2: *const ::std::os::raw::c_char, ...);
}

Ideally, there should be one binding to the renamed function. In this case, it's harmless as long as Rust does not support long double.

[1] https://gcc.gnu.org/onlinedocs/gcc/Asm-Labels.html

主要言語
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 を短くまとめたダイジェスト。