Fix warnings about non-FFI-safe u128
ldm0 opened this issue · comments
FFmpeg includes math.h
, which contains function&type related to long double
.
Rust once have support for f128(long double)
support but removed it because of ABI issues with it(check https://github.com/rust-lang/meeting-minutes/blob/master/weekly-meetings/2014-06-24.md#removing-f128 and rust-lang/rust#15160 for the removal and check rust-lang/rust#54341 for the ABI issues).
This directly cause abstacles for creating FFI bindings for function&types that uses long double
. Bindgen currently choose to generate u128
for long double
as a workaround(rust-lang/rust-bindgen#1391). However u128
itself is not FFI-safe(but at least better than f128
), which is why warnings like this emit:
warning: `extern` block uses type `u128`, which is not FFI-safe
--> /home/donoughliu/ffmpeg_sources/rusty_ffmpeg/target/debug/build/rusty_ffmpeg-1e9d8c55b6509bde/out/binding.rs:2708:33
|
2708 | pub fn floorl(__x: u128) -> u128;
| ^^^^ not FFI-safe
|
= note: 128-bit integers don't currently have a known stable ABI
There are discussions of it in the rust-bindgen
repo: rust-lang/rust-bindgen#1549. And there is no good way for us to solve this linting.
A good news is FFmpeg seems to be not using the insane long double
, so theoretically we can safely filter out all the functions and types using the long double
and these warnings will gone.
A bad news is bindgen haven't give us the functionality to filter out things related to primitive types.
But another good news is bindgen have a feature that can ignore specific macros and we are currently using it. So I think the feature above can be implemented. And currently we are blocked on this unimplemented primitive type filtering feature of rust-bindgen
.