Ax9D / pw-viz

Pipewire graph editor written in Rust. WIP⚠️
GNU General Public License v3.0
230 stars 14 forks source link

Fails to build: cannot find function `eventfd` in crate `libc` #29

Closed yurivict closed 1 year ago

yurivict commented 1 year ago
error[E0425]: cannot find function `eventfd` in crate `libc`
   --> /usr/ports/net/pw-viz/work/pw-viz-0.1.0-22-g04ffced/cargo-crates/pipewire-0.4.1/src/channel.rs:220:34
    |
220 |     let eventfd = unsafe { libc::eventfd(0, libc::EFD_CLOEXEC) };
    |                                  ^^^^^^^ not found in `libc`

error[E0425]: cannot find function `pw_init` in crate `pw_sys`
   --> /usr/ports/net/pw-viz/work/pw-viz-0.1.0-22-g04ffced/cargo-crates/pipewire-0.4.1/src/lib.rs:156:49
    |
156 |     INITIALIZED.get_or_init(|| unsafe { pw_sys::pw_init(ptr::null_mut(), ptr::null_mut()) });
    |                                                 ^^^^^^^ not found in `pw_sys`

error[E0425]: cannot find function `pw_deinit` in crate `pw_sys`
   --> /usr/ports/net/pw-viz/work/pw-viz-0.1.0-22-g04ffced/cargo-crates/pipewire-0.4.1/src/lib.rs:165:13
    |
165 |     pw_sys::pw_deinit()
    |             ^^^^^^^^^ not found in `pw_sys`

The libc crate does contain this function for FreeBSD-13:

libc-0.2.107/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs: pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int;

rev.04ffced FreeBSD 13.1 STABLE

Ax9D commented 1 year ago

Maybe its a versioning issue. What version of rust are you using?

eventfd was added for FreeBSD 13 in libc-0.2.107: https://github.com/rust-lang/libc/commit/57492ef9939f8d99f577f64bf85f10834eea0607 rustc bumped libc to 0.2.108 here: https://github.com/thomcc/rust/commit/9a04ae4997493e9260352064163285cddc43de3c So it should be available since rust-1.57 I think.

yurivict commented 1 year ago

I use rust-1.66.0

yurivict commented 1 year ago

There are two issues in the error messages - another one is with pw_sys::pw_init.

I think the eventfd issue disappeared when I updated libc to the latest version, but the second issue did not disappear.

yurivict commented 1 year ago

Maybe you can make a release with all the latest dependencies.

Ax9D commented 1 year ago

Yes I'm prepping a release. For the time being it's available here testing.

yurivict commented 1 year ago

I tried the testing branch, and this error is still there:

error[E0425]: cannot find function `pw_init` in crate `pw_sys`
   --> /usr/ports/multimedia/pw-viz/work/pw-viz-0194a12/cargo-crates/pipewire-0.5.0/src/lib.rs:160:49
    |
160 |     INITIALIZED.get_or_init(|| unsafe { pw_sys::pw_init(ptr::null_mut(), ptr::null_mut()) });
    |                                                 ^^^^^^^ not found in `pw_sys`

error[E0425]: cannot find function `pw_deinit` in crate `pw_sys`
   --> /usr/ports/multimedia/pw-viz/work/pw-viz-0194a12/cargo-crates/pipewire-0.5.0/src/lib.rs:169:13
    |
169 |     pw_sys::pw_deinit()
    |             ^^^^^^^^^ not found in `pw_sys`

warning: `signal` (lib) generated 7 warnings
Ax9D commented 1 year ago

I think I found the problem,

On BSD pw_init and pw_deinit are renamed to pipewire_init and pipewire_deinit: https://github.com/freebsd/freebsd-ports/blob/main/multimedia/pipewire/files/patch-src_pipewire_pipewire_init As a result pipewire-rs doesn't find these functions at build time.

Ax9D commented 1 year ago

As for the solution, You can do something similar to helvum I suppose: https://github.com/freebsd/freebsd-ports/blob/main/multimedia/helvum/files/patch-pipewire_init

yurivict commented 1 year ago

Yes, I am already doing it. Thank you.