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

Fix warnings about non-FFI-safe u128 #1

Closed
ldm0 opened this issue Jun 10, 2020 · 0 comments · Fixed by #13
Closed

Fix warnings about non-FFI-safe u128 #1

ldm0 opened this issue Jun 10, 2020 · 0 comments · Fixed by #13
Assignees
Labels
enhancement New feature or request

Comments

@ldm0
Copy link
Collaborator

ldm0 commented Jun 10, 2020

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.

@ldm0 ldm0 self-assigned this Jun 10, 2020
@ldm0 ldm0 added the enhancement New feature or request label Jun 10, 2020
@ldm0 ldm0 mentioned this issue Jun 11, 2020
4 tasks
@ldm0 ldm0 closed this as completed in #13 Jun 22, 2020
cfsmp3 pushed a commit that referenced this issue Mar 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant