Using asm labels in function declaration produces unexpected bindings

Aperta
#3,534 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
52/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
c, rust

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
Rust
Stelle
5.3k
Fork
846
Merge medio
2g 6h
PR unite (30g)
11

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di rust-lang/rust-bindgen

Tutte le issue di rust-lang/rust-bindgen

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.