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

Unable to build on NetBSD #56

Closed
0323pin opened this issue Sep 8, 2022 · 4 comments
Closed

Unable to build on NetBSD #56

0323pin opened this issue Sep 8, 2022 · 4 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@0323pin
Copy link
Contributor

0323pin commented Sep 8, 2022

Hi,

I'm the package maintainer of nushell on NetBSD. To build nushell successfully on NetBSD, I need to disable the trash-support feature, else the build will fail.

Today, I've decided to have a look and build trash-rs standalone.
Here's what I get,

Compiling trash v2.1.5 (/usr/pkgsrc/wip/trash/work/trash-rs-2.1.5)
error[E0412]: cannot find type `statfs` in crate `libc`
   --> src/freedesktop.rs:727:34
    |
727 |       let mut fs_infos: *mut libc::statfs = std::ptr::null_mut();
    |                                    ^^^^^^ help: a struct with a similar name exists: `statvfs`
    |
   ::: /usr/pkgsrc/wip/trash/work/vendor/libc-0.2.132/src/unix/bsd/netbsdlike/netbsd/mod.rs:714:1
    |
714 | / s_no_extra_traits! {
715 | |
716 | |     pub struct utmpx {
717 | |         pub ut_name: [::c_char; _UTX_USERSIZE],
...   |
835 | |     }
836 | | }
    | |_- similarly named struct `statvfs` defined here

error[E0425]: cannot find function `getmntinfo` in crate `libc`
   --> src/freedesktop.rs:728:32
    |
728 |     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:728:64
    |
728 |     let count = unsafe { libc::getmntinfo(&mut fs_infos, libc::MNT_WAIT) };
    |                                                                ^^^^^^^^ not found in `libc`

error[E0412]: cannot find type `statfs` in crate `libc`
   --> src/freedesktop.rs:732:27
    |
732 |       let fs_infos: &[libc::statfs] =
    |                             ^^^^^^ help: a struct with a similar name exists: `statvfs`
    |
   ::: /usr/pkgsrc/wip/trash/work/vendor/libc-0.2.132/src/unix/bsd/netbsdlike/netbsd/mod.rs:714:1
    |
714 | / s_no_extra_traits! {
715 | |
716 | |     pub struct utmpx {
717 | |         pub ut_name: [::c_char; _UTX_USERSIZE],
...   |
835 | |     }
836 | | }
    | |_- similarly named struct `statvfs` defined here

Some errors have detailed explanations: E0412, E0425.
For more information about an error, try `rustc --explain E0412`.
error: could not compile `trash` due to 4 previous errors
warning: build failed, waiting for other jobs to finish...
*** Error code 101

Stop.

Any clue on how to fix the build? Or, is this an issue with libc support?
Thanks!

EDIT:
OS: NetBSD-9.99.99
Rust: 1.63

@Byron Byron added bug Something isn't working help wanted Extra attention is needed labels Sep 9, 2022
@Byron
Copy link
Owner

Byron commented Sep 9, 2022

Thanks for digging in and letting us know.

I for one don't know where this should be fixed - my assumption would be that libc isn't portable at all and that specific function doesn't exist on NetBSD. I'd think this can only be fixed by using NetBSD (or FreeBSD?) specific functions.
I also wonder if the implementation for MacOS has anything to do with it, given it's BSD heritage.

@0323pin
Copy link
Contributor Author

0323pin commented Sep 9, 2022

Thanks for taking the time.

my assumption would be that libc isn't portable at all

Actually, this reminds me that I've looked at this before, The rust libc implementation for NetBSD is not as nearly as complete as FreeBSDs one.
Then, I recognized your name 😄
I'm also maintaining the dua-cli package on NetBSD where I have the following on the package build instructions,

.if ${OPSYS} != "Linux"
CARGO_NO_DEFAULT_FEATURES=	YES
CARGO_FEATURES+=		tui-unix
.endif

I also wonder if the implementation for MacOS has anything to do with it, given it's BSD heritage.

Are you also having trouble on MacOS? The reason could be the same but, MacOS and FreeBSD have redly available CIs and the implemented libc functionality is far more advanced than for NetBSD or, OpenBSD for that matter.

As this should be fixed at the libcs end, there's no need to keep this issue open. Please feel free to close it or move it to Discussions.

@Byron
Copy link
Owner

Byron commented Sep 10, 2022

Then, I recognized your name 😄
I'm also maintaining the dua-cli package on NetBSD where I have the following on the package build instructions,

Ha, look how small the world is :D. Even though I wouldn't be surprised to learn that you maintain hundreds of packages making this coincidence so much more likely.

Are you also having trouble on MacOS? The reason could be the same but, MacOS and FreeBSD have redly available CIs and the implemented libc functionality is far more advanced than for NetBSD or, OpenBSD for that matter.

Actually I thought that since MacOS is working for trash and it's a BSD-ish (I don't know what I am talking about here), the functions called there could be transferable to the NetBSD version.

As this should be fixed at the libcs end, there's no need to keep this issue open. Please feel free to close it or move it to Discussions.

Alright, let's take this on another time. Leaving it as issues as commenting here feels more natural.

@Byron Byron closed this as completed Sep 10, 2022
@Byron Byron reopened this Sep 10, 2022
@Byron Byron closed this as not planned Won't fix, can't repro, duplicate, stale Sep 10, 2022
@0323pin
Copy link
Contributor Author

0323pin commented Sep 10, 2022

look how small the world is :D. Even though I wouldn't be surprised to learn that you maintain hundreds of packages making this coincidence so much more likely.

Correct, I've only signed-up as maintainer on 75 packages but, in practice I do maintain a much larger number 🤣

Maybe at somepoint I should dig into libc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants