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

NetBSD support #83

Closed
woelper opened this issue Sep 16, 2023 · 10 comments · Fixed by #84
Closed

NetBSD support #83

woelper opened this issue Sep 16, 2023 · 10 comments · Fixed by #84
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@woelper
Copy link

woelper commented Sep 16, 2023

I know that this is probably an exotic target, but when I build this library for NetBSD, I get the following error:

      Checking trash v3.0.6
  error[E0412]: cannot find type `statfs` in crate `libc`
     --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/trash-3.0.6/src/freedesktop.rs:703:34
      |
  703 |       let mut fs_infos: *mut libc::statfs = std::ptr::null_mut();
      |                                    ^^^^^^ help: a struct with a similar name exists: `statvfs`
      |
     ::: /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/libc-0.2.148/src/unix/bsd/netbsdlike/netbsd/mod.rs:757:1
      |
  757 | / s_no_extra_traits! {
  758 | |
  759 | |     pub struct utmpx {
  760 | |         pub ut_name: [::c_char; _UTX_USERSIZE],
  ...   |
  878 | |     }
  879 | | }
      | |_- similarly named struct `statvfs` defined here
  
  error[E0425]: cannot find function `getmntinfo` in crate `libc`
     --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/trash-3.0.6/src/freedesktop.rs:704:32
      |
  704 |     let count = unsafe { libc::getmntinfo(&mut fs_infos, libc::MNT_WAIT) };
      |                                ^^^^^^^^^^ not found in `libc`
  
  error[E0425]: cannot find value `MNT_WAIT` in crate `libc`
     --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/trash-3.0.6/src/freedesktop.rs:704:64
      |
  704 |     let count = unsafe { libc::getmntinfo(&mut fs_infos, libc::MNT_WAIT) };
      |                                                                ^^^^^^^^ not found in `libc`
  
  error[E0412]: cannot find type `statfs` in crate `libc`
     --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/trash-3.0.6/src/freedesktop.rs:708:27
      |
  708 |       let fs_infos: &[libc::statfs] = unsafe { std::slice::from_raw_parts(fs_infos as _, count as _) };
      |                             ^^^^^^ help: a struct with a similar name exists: `statvfs`
      |
     ::: /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/libc-0.2.148/src/unix/bsd/netbsdlike/netbsd/mod.rs:757:1
      |
  757 | / s_no_extra_traits! {
  758 | |
  759 | |     pub struct utmpx {
  760 | |         pub ut_name: [::c_char; _UTX_USERSIZE],
  ...   |
  878 | |     }
  879 | | }
      | |_- similarly named struct `statvfs` defined here

I don't have access to a native NetBSD system, but Github Actions support this target - I have one set up like this:
https://github.com/woelper/oculante/blob/e6e54253ff7de22601678eb6aaebe3f84a02c7ca/.github/workflows/netbsd_minimal.yml

@Byron Byron added enhancement New feature or request help wanted Extra attention is needed labels Sep 17, 2023
@Byron
Copy link
Owner

Byron commented Sep 17, 2023

Thanks for letting us know, and for suggesting how to setup CI. A contributor could probably start with setting up CI, reproduce this issue, and then make it pass by using the differently named symbols instead.

@0323pin
Copy link
Contributor

0323pin commented Sep 17, 2023

It was brought to my attention that statfs is the old version of statvfs, which NetBSD does support and which, seems to be in the libc crate.
So, I've tried the following patch

Unfortunately, I still get the other error 😞

~> cargo build --release
    Updating crates.io index
  Downloaded tinyvec_macros v0.1.1
  Downloaded scopeguard v1.2.0
  Downloaded form_urlencoded v1.2.0
  Downloaded iana-time-zone v0.1.57
  Downloaded log v0.4.20
  Downloaded percent-encoding v2.3.0
  Downloaded autocfg v1.1.0
  Downloaded unicode-bidi v0.3.13
  Downloaded once_cell v1.18.0
  Downloaded num-traits v0.2.16
  Downloaded url v2.4.1
  Downloaded chrono v0.4.31
  Downloaded tinyvec v1.6.0
  Downloaded unicode-normalization v0.1.22
  Downloaded idna v0.4.0
  Downloaded libc v0.2.148
  Downloaded 16 crates (1.7 MB) in 1.26s
   Compiling autocfg v1.1.0
   Compiling tinyvec_macros v0.1.1
   Compiling libc v0.2.148
   Compiling unicode-bidi v0.3.13
   Compiling tinyvec v1.6.0
   Compiling num-traits v0.2.16
   Compiling percent-encoding v2.3.0
   Compiling form_urlencoded v1.2.0
   Compiling unicode-normalization v0.1.22
   Compiling iana-time-zone v0.1.57
   Compiling idna v0.4.0
   Compiling chrono v0.4.31
   Compiling once_cell v1.18.0
   Compiling url v2.4.1
   Compiling scopeguard v1.2.0
   Compiling log v0.4.20
   Compiling trash v3.0.6 (/home/pin/Git/trash-rs)
error[E0425]: cannot find function `getmntinfo` in crate `libc`
   --> src/freedesktop.rs:706:32
    |
706 |     let count = unsafe { libc::getmntinfo(&mut fs_infos, libc::MNT_WAIT) };
    |                                ^^^^^^^^^^ not found in `libc`

error[E0425]: cannot find value `MNT_WAIT` in crate `libc`
   --> src/freedesktop.rs:706:64
    |
706 |     let count = unsafe { libc::getmntinfo(&mut fs_infos, libc::MNT_WAIT) };
    |                                                                ^^^^^^^^ not found in `libc`

For more information about this error, try `rustc --explain E0425`.
error: could not compile `trash` (lib) due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
Exception: cargo exited with 101

Thoughts?!

@wravoc
Copy link

wravoc commented Sep 17, 2023

Not meaning to sidetrack here, but add some voice for additional targets. It is the same situation on Dragonfly BSD that any cargo that requires trash will not work failing on get_mount_points.

@0323pin 0323pin mentioned this issue Sep 18, 2023
3 tasks
0323pin referenced this issue in woelper/oculante Sep 18, 2023
@0323pin
Copy link
Contributor

0323pin commented Sep 18, 2023

I've now successfully built trash-rs on NetBSD, #84 (comment)

@0323pin
Copy link
Contributor

0323pin commented Sep 25, 2023

@wravoc could we get the exact error? You wrote, get_mount_points and my PR is waiting on it.

Now, I don't see such syscall on DragonFly BSD man pages but, I do see getmntinfo just like in NetBSD.

Perhaps you could submit a similar pull request with rust-lang/libc adding the required function for it to build on DragonFly, After all, it too supports statvfs

@wravoc
Copy link

wravoc commented Sep 28, 2023

@0323pin
So today, I have a more robust build of Dragonfly BSD or maybe your fix was merged and also fixed DF, or the compilation order has changed because I cannot replicate that issue any longer and I cannot just install 'trash 3.0.6' to test. I originally encountered that error as a dependency of "Nu [Shell] but now it is failing on something different.

Ok, I went to crates.io and looked up dependents of and installed the first binary that required 'trash' and this is the error.

   Compiling trash v3.0.1
error[E0425]: cannot find function `get_mount_points` in this scope
  --> /home/elias/.cargo/registry/src/github.com-1ecc6299db9ec823/trash-3.0.1/src/freedesktop.rs:31:28
   |
31 |         let mount_points = get_mount_points()?;
   |                            ^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `get_mount_points` in this scope
  --> /home/elias/.cargo/registry/src/github.com-1ecc6299db9ec823/trash-3.0.1/src/freedesktop.rs:80:24
   |
80 |     let mount_points = get_mount_points()?;
   |                        ^^^^^^^^^^^^^^^^ not found in this scope

For more information about this error, try `rustc --explain E0425`.
error: could not compile `trash` due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
error: failed to compile `dua-cli v2.20.1`, intermediate artifacts can be found at `/tmp/cargo-install3qZFpP`:

@0323pin
Copy link
Contributor

0323pin commented Sep 28, 2023

@wravoc

So today, I have a more robust build of Dragonfly BSD or maybe your fix was merged and also fixed DF, or the compilation order has changed because I cannot replicate that issue any longer

Nothing has changed, none of my PRs have been merged, this one is still open and, I made a mistake on my libc PR and closed it, Resubmitted yesterday, now without rough edges.

I don't know DF but, dig through the headers (see my libc PR) and see what you are missing in libc.

If you just want to build nu you can do it with cargo build --release --no-default-features --features plugin,which-support,sqlite. But, I guess you already know that.

@0323pin
Copy link
Contributor

0323pin commented Sep 29, 2023

The libc bits have been merged

@0323pin
Copy link
Contributor

0323pin commented Oct 1, 2023

@wravoc Please see: #84 (comment)

@Byron Byron closed this as completed in #84 Oct 8, 2023
@woelper
Copy link
Author

woelper commented Oct 8, 2023

I just wanted to stop by and say a big thanks for fixing this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants