Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AArch64 Linux va_list not FFI-safe #2845

Open
stevecapperarm opened this issue Jun 6, 2024 · 0 comments
Open

AArch64 Linux va_list not FFI-safe #2845

stevecapperarm opened this issue Jun 6, 2024 · 0 comments

Comments

@stevecapperarm
Copy link

Hello folks,
We noticed that for AArch64 Linux, va_list was being translated to a type that was not FFI-safe.
Whilst we aren't aware of any cases where va_list would be used by Rust, this does result in warnings appearing for some projects when built for Arm and not other architectures. Rather than try to block these functions from being translated in various crates, I thought it best to raise something here as a general solution may be better.

I suspect there is some subtle interaction with clang and the builtin va_list type for AArch64 Linux.

Input C/C++ Header

// typedefs below come from <stdarg.h>
typedef __builtin_va_list __gnuc_va_list;
typedef __builtin_va_list va_list;

int my_func(char *format, va_list args);

Bindgen Invocation

$ bindgen input.h

Actual Results

/* automatically generated by rust-bindgen 0.69.4 */

pub type __gnuc_va_list = [u64; 4usize];
pub type va_list = [u64; 4usize];
extern "C" {
    pub fn my_func(
        format: *mut ::std::os::raw::c_char,
        args: va_list,
    ) -> ::std::os::raw::c_int;
}

and/or

warning: `extern` block uses type `[u64; 4]`, which is not FFI-safe
 --> test.rs:8:15
  |
8 |         args: va_list,
  |               ^^^^^^^ not FFI-safe
  |
  = help: consider passing a pointer to the array
  = note: passing raw arrays by value is not FFI-safe
  = note: `#[warn(improper_ctypes)]` on by default

Expected Results

We don't expect the warning to appear. Maybe something like this would be better?

#[repr(C)]
#[repr(align(8))]
#[derive(Debug, Copy, Clone)]
pub struct va_list {
    pub _bindgen_opaque_blob: [u64; 4usize],
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant