Skip to content
This repository has been archived by the owner on Jun 8, 2021. It is now read-only.
This repository has been archived by the owner on Jun 8, 2021. It is now read-only.

Build Error on armv7l (RasperryPI): glib::translate::ToGlibPtr<'_, *mut i8> is not implemented for std::path::Path #137

Closed
meldron opened this issue Jul 20, 2018 · 10 comments

Comments

@meldron
Copy link

meldron commented Jul 20, 2018

Hi there,

I am trying to build https://github.com/centricular/gstwebrtc-demos/tree/master/sendrecv/gst-rust on a raspberry pi armv7l and just ran in the following error which i did not get on x86_64.

cargo build

Compiling gio v0.4.0 (https://github.com/gtk-rs/gio#b95e3d5d)
error[E0277]: the trait bound `std::path::Path: glib::translate::ToGlibPtr<'_, *mut i8>` is not satisfied
  --> /home/pi/.cargo/git/checkouts/gio-a4b825b310a073b9/b95e3d5/src/unix_socket_address.rs:56:37
   |
56 |                 Path(path) => (path.to_glib_none().0, path.as_os_str().len()),
   |                                     ^^^^^^^^^^^^ the trait `glib::translate::ToGlibPtr<'_, *mut i8>` is not implemented for 
`std::path::Path`
   |
   = help: the following implementations were found:
             <std::path::Path as glib::translate::ToGlibPtr<'a, *const u8>>
             <std::path::Path as glib::translate::ToGlibPtr<'a, *mut u8>>

error[E0308]: mismatched types
  --> /home/pi/.cargo/git/checkouts/gio-a4b825b310a073b9/b95e3d5/src/unix_socket_address.rs:61:84
   |
61 |             SocketAddress::from_glib_full(ffi::g_unix_socket_address_new_with_type(path, len as i32, type_.to_glib()))
   |                                                                                    ^^^^ expected u8, found i8
   |
   = note: expected type `*mut u8`
              found type `*mut i8`

error: aborting due to 2 previous errors

Some errors occurred: E0277, E0308.
For more information about an error, try `rustc --explain E0277`.
error: Could not compile `gio`.

To learn more, run the command again with --verbose.

I built the gio library with gstreamers cerbero installation (both on armv7l and x86_64) and pkg-config --modversion gio-2.0 returns version 2.56.1 on both machines.

@meldron
Copy link
Author

meldron commented Jul 20, 2018

I just tried to build gstreamer-rtsp-server by itself and i got even more errors:

error[E0308]: mismatched types
  --> /home/pi/.cargo/git/checkouts/gio-a4b825b310a073b9/98d1501/src/desktop_app_info.rs:23:41
   |
23 |                 let tmp: *mut *mut i8 = *out.offset(it);
   |                                         ^^^^^^^^^^^^^^^ expected i8, found u8
   |
   = note: expected type `*mut *mut i8`
              found type `*mut *mut u8`
error[E0277]: the trait bound `std::string::String: glib::translate::FromGlibPtrArrayContainerAsVec<_, *mut *mut i8>` is not satisfied
  --> /home/pi/.cargo/git/checkouts/gio-a4b825b310a073b9/98d1501/src/desktop_app_info.rs:28:38
   |
28 |                 let v: Vec<String> = FromGlibPtrContainer::from_glib_full(tmp);
   |                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `glib::translate::FromGlibPtrArrayContainerAsVec<_, *mut *mut i8>` is not implemented for `std::string::String`
   |
   = help: the following implementations were found:
             <std::string::String as glib::translate::FromGlibPtrArrayContainerAsVec<*const u8, *mut *const u8>>
             <std::string::String as glib::translate::FromGlibPtrArrayContainerAsVec<*const u8, *const *const u8>>
             <std::string::String as glib::translate::FromGlibPtrArrayContainerAsVec<*mut u8, *mut *mut u8>>
             <std::string::String as glib::translate::FromGlibPtrArrayContainerAsVec<*mut u8, *const *mut u8>>
   = note: required because of the requirements on the impl of `glib::translate::FromGlibPtrContainer<_, *mut *mut i8>` for `std::vec::Vec<std::string::String>`
   = note: required by `glib::translate::FromGlibPtrContainer::from_glib_full`
error[E0277]: the trait bound `std::path::Path: glib::translate::ToGlibPtr<'_, *mut i8>` is not satisfied
  --> /home/pi/.cargo/git/checkouts/gio-a4b825b310a073b9/98d1501/src/unix_socket_address.rs:56:37
   |
56 |                 Path(path) => (path.to_glib_none().0, path.as_os_str().len()),
   |                                     ^^^^^^^^^^^^ the trait `glib::translate::ToGlibPtr<'_, *mut i8>` is not implemented for `std::path::Path`
   |
   = help: the following implementations were found:
             <std::path::Path as glib::translate::ToGlibPtr<'a, *const u8>>
             <std::path::Path as glib::translate::ToGlibPtr<'a, *mut u8>>
error[E0308]: mismatched types
  --> /home/pi/.cargo/git/checkouts/gio-a4b825b310a073b9/98d1501/src/unix_socket_address.rs:61:84
   |
61 |             SocketAddress::from_glib_full(ffi::g_unix_socket_address_new_with_type(path, len as i32, type_.to_glib()))
   |                                                                                    ^^^^ expected u8, found i8
   |
   = note: expected type `*mut u8`
              found type `*mut i8`
error[E0308]: mismatched types
   --> gstreamer/src/tags.rs:197:39   
    |
197 |                 ffi::gst_tag_get_type(tag_name.as_ptr() as *const i8)
    |                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected u8, found i8
    |
    = note: expected type `*const u8` 
               found type `*const i8` 

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
error: Could not compile `gstreamer`. 
warning: build failed, waiting for other jobs to finish...
error: aborting due to 4 previous errors

Some errors occurred: E0277, E0308.
For more information about an error, try `rustc --explain E0277`.
error: Could not compile `gio`.

@sdroege
Copy link
Member

sdroege commented Jul 20, 2018

Ok, mismatch between signed and unsigned everywhere. See
https://github.com/rust-lang/libc/blob/master/src/unix/notbsd/linux/musl/b32/arm.rs#L1
vs
https://github.com/rust-lang/libc/blob/master/src/unix/notbsd/linux/musl/b64/x86_64.rs#L1
for example.

We need to consistently use c_char I guess

@sdroege
Copy link
Member

sdroege commented Jul 20, 2018

Hmm but we do: https://github.com/gtk-rs/glib/blob/master/src/translate.rs#L474

Can you check in your Cargo.lock is there are multiple versions of the libc crate linked in?

@meldron
Copy link
Author

meldron commented Jul 20, 2018

In the lock file of gstreamer-rs all libc versions are 0.2.42 and in gst-rust's lock file all versions are 0.2.41.

@sdroege
Copy link
Member

sdroege commented Jul 20, 2018

Those definitions also didn't change for years. Ok, someone will have to reproduce and follow the types. Somewhere there must be a u8 or i8 instead of c_char

error[E0308]: mismatched types
   --> gstreamer/src/tags.rs:197:39   
    |
197 |                 ffi::gst_tag_get_type(tag_name.as_ptr() as *const i8)
    |                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected u8, found i8
    |
    = note: expected type `*const u8` 
               found type `*const i8` 

This is a bug in gstreamer-rs btw, there might be more like this there. I'll check next week unless you want to send me a PR. @meldron

@meldron
Copy link
Author

meldron commented Jul 20, 2018

@sdroege thanks for your input, I opened an issue at sdroege/gstreamer-rs/, and i will try to look into it, but i am not sure where to look.

@sdroege
Copy link
Member

sdroege commented Jul 20, 2018

For gstreamer it's exactly in line 197 there. See my comment in the other ticket :)

For GLib/GIO I don't know either, you'll have to look at each of the errors individually, look at the types of function arguments/return values, local variables, etc and see where exactly the i8 or u8 comes from that should actually be a c_char. Or cast accordingly if needed.

@meldron
Copy link
Author

meldron commented Jul 20, 2018

I will look for more and submit a PR if I am successful.

@sdroege
Copy link
Member

sdroege commented Jul 23, 2018

The GStreamer part is fixed now, I'm looking at the GTK part now and the GIO part is here: #139

@sdroege
Copy link
Member

sdroege commented Jul 23, 2018

Oh the other part was also in GIO, added to the existing PR

vhdirk pushed a commit to vhdirk/gio-rs that referenced this issue Jan 16, 2019
GuillaumeGomez pushed a commit to gtk-rs/gtk3-rs that referenced this issue Oct 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants