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

uucore build fails on OpenBSD #5448

Closed
lcheylus opened this issue Oct 24, 2023 · 5 comments · Fixed by #5599
Closed

uucore build fails on OpenBSD #5448

lcheylus opened this issue Oct 24, 2023 · 5 comments · Fixed by #5599

Comments

@lcheylus
Copy link
Contributor

On OpenBSD-current (future version 7.5) on amd64, with Rust 1.73.0,

$ sysctl kern.version
kern.version=OpenBSD 7.4-current (GENERIC) #1356: Sun Oct 22 13:03:10 MDT 2023
    [email protected]:/usr/src/sys/arch/amd64/compile/GENERIC
$ rustc -V
rustc 1.73.0 (cc66ad468 2023-10-03) (built from a source tarball)

$ git rev-parse HEAD
769eb29cd3503d7734776572f7875a864c847c92

uucore build fails:

$ cargo build --release --features unix
   Compiling uucore v0.0.22 (/home/fox/dev/coreutils.git/src/uucore)
error[E0432]: unresolved import `libc::endutxent`
  --> src/uucore/src/lib/features/utmpx.rs:43:9
   |
43 | pub use libc::endutxent;
   |         ^^^^^^---------
   |         |     |
   |         |     help: a similar name exists in the module: `endpwent`
   |         no `endutxent` in the root

error[E0432]: unresolved import `libc::getutxent`
  --> src/uucore/src/lib/features/utmpx.rs:44:9
   |
44 | pub use libc::getutxent;
   |         ^^^^^^---------
   |         |     |
   |         |     help: a similar name exists in the module: `getpwent`
   |         no `getutxent` in the root

error[E0432]: unresolved import `libc::setutxent`
  --> src/uucore/src/lib/features/utmpx.rs:45:9
   |
45 | pub use libc::setutxent;
   |         ^^^^^^---------
   |         |     |
   |         |     help: a similar name exists in the module: `setpwent`
   |         no `setutxent` in the root

error[E0432]: unresolved import `libc::utmpx`
  --> src/uucore/src/lib/features/utmpx.rs:46:5
   |
46 | use libc::utmpx;
   |     ^^^^^^^^^^^ no `utmpx` in the root
   |
help: a similar name exists in the module
   |
46 | use libc::utmp;
   |           ~~~~
help: consider importing this module through its public re-export instead
   |
46 | use crate::utmpx;
   |     ~~~~~~~~~~~~

error[E0432]: unresolved import `self::ut`
  --> src/uucore/src/lib/features/utmpx.rs:42:15
   |
42 | pub use self::ut::*;
   |               ^^ could not find `ut` in `self`

error[E0573]: expected type, found module `utmpx`
   --> src/uucore/src/lib/features/utmpx.rs:160:12
    |
160 |     inner: utmpx,
    |            ^^^^^ not a type

error[E0573]: expected type, found module `utmpx
   --> src/uucore/src/lib/features/utmpx.rs:214:32
    |
159 | pub struct Utmpx {
    | ---------------- similarly named struct `Utmpx` defined here
...
214 |     pub fn into_inner(self) -> utmpx {
    |                                ^^^^^ help: a struct with a similar name exists (notice the capitalization): `Utmpx`

error[E0425]: cannot find value `USER_PROCESS` in this scope
   --> src/uucore/src/lib/features/utmpx.rs:218:58
    |
218 |         !self.user().is_empty() && self.record_type() == USER_PROCESS
    |                                                          ^^^^^^^^^^^^ not found in this scope

error[E0308]: mismatched types
   --> src/uucore/src/lib/features/fs.rs:122:16
    |
111 |     pub fn number_of_links(&self) -> u64 {
    |                                      --- expected `u64` because of return type
...
122 |         return self.0.st_nlink;
    |                ^^^^^^^^^^^^^^^ expected `u64`, found `u32`
    |
help: you can convert a `u32` to a `u64`
    |
122 |         return self.0.st_nlink.into();
    |                               +++++++

error[E0308]: mismatched types
   --> src/uucore/src/lib/features/fsext.rs:497:25
    |
497 |                 bavail: statvfs.f_bavail,
    |                         ^^^^^^^^^^^^^^^^ expected `u64`, found `i64`

error[E0308]: mismatched types
   --> src/uucore/src/lib/features/fsext.rs:498:59
    |
498 |                 bavail_top_bit_set: ((statvfs.f_bavail) & (1u64.rotate_right(1))) != 0,
    |                                                           ^^^^^^^^^^^^^^^^^^^^^^ expected `i64`, found `u64`

error[E0277]: no implementation for `i64 & u64`
   --> src/uucore/src/lib/features/fsext.rs:498:57
    |
498 |                 bavail_top_bit_set: ((statvfs.f_bavail) & (1u64.rotate_right(1))) != 0,
    |                                                         ^ no implementation for `i64 & u64`
    |
    = help: the trait `BitAnd<u64>` is not implemented for `i64`
    = help: the following other types implement trait `BitAnd<Rhs>`:
              <i64 as BitAnd>
              <i64 as BitAnd<&i64>>
              <&'a i64 as BitAnd<i64>>
              <&i64 as BitAnd<&i64>>

error[E0308]: mismatched types
   --> src/uucore/src/lib/features/fsext.rs:615:16
    |
606 |     fn block_size(&self) -> i64 {
    |                             --- expected `i64` because of return type
...
615 |         return self.f_bsize;
    |                ^^^^^^^^^^^^ expected `i64`, found `u32`
    |
help: you can convert a `u32` to an `i64`
    |
615 |         return self.f_bsize.into();
    |                            +++++++

error[E0308]: mismatched types
   --> src/uucore/src/lib/features/fsext.rs:644:16
    |
642 |     fn avail_blocks(&self) -> u64 {
    |                               --- expected `u64` because of return type
643 |         #[cfg(all(not(target_os = "freebsd"), target_pointer_width = "64"))]
644 |         return self.f_bavail;
    |                ^^^^^^^^^^^^^ expected `u64`, found `i64`
    |
help: you can convert an `i64` to a `u64` and panic if the converted value doesn't fit
    |
644 |         return self.f_bavail.try_into().unwrap();
    |                             ++++++++++++++++++++

error[E0425]: cannot find function `utmpxname` in this scope
   --> src/uucore/src/lib/features/utmpx.rs:292:13
    |
292 |             utmpxname(path.as_ptr());
    |             ^^^^^^^^^ help: a function with a similar name exists: `util_name`
    |
   ::: src/uucore/src/lib/lib.rs:146:1
    |
146 | pub fn util_name() -> &'static str {
    | ---------------------------------- similarly named function `util_name` defined here

Some errors have detailed explanations: E0277, E0308, E0425, E0432, E0573.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `uucore` (lib) due to 15 previous errors

After a quick analysis, 2 types of errors here:

  • support of utmpx on OpenBSD in libc crate
  • errors with types in src/uucore/src/lib/features/fs.rs and src/uucore/src/lib/features/fsext.rs => similar to errors detected to support NetBSD (issue#5288).
@sylvestre
Copy link
Contributor

would you like to prepare a patch?
(i can't test)

@tertsdiepraam
Copy link
Member

Thanks for the report! To guarantee support, we need a CI job in the long term. Of course, a patch for this particular issue is a great start, but if you want you could also help us by creating an OpenBSD CI job!

@lcheylus
Copy link
Contributor Author

@sylvestre I could try to fix the issues with u64 types in fs.rs/fsext.rs. But the issues with utmpx support for OpenBSD in libc crate seems more complex to fix.

I only have a limited experience with Rust.

@tertsdiepraam Yes, adding a OpenBSD CI job would be a good solution to guarantee support in the long term.
But it's a difficult task :

  • vmactions/openbsd-vm supports only version 7.1/7/2 ; current OpenBSD version released last week = 7.4 !
  • rustup tool used in FreeBSD CI job is not supported on OpenBSD.

@n1000
Copy link
Contributor

n1000 commented Oct 25, 2023

I had some initial compile fixes for OpenBSD here: https://github.com/n1000/coreutils/tree/openbsd_compile_fixes

But I was not compiling with the --features unix option so did not run into the utmpx failure...

I ended up getting side tracked with some test failures so did not get around to raising the pull request.

edit: @lcheylus If you have the bandwidth and would like to take this fix forward, please feel free (just drop a note here). Otherwise I can raise the pull request later on (probably would get back to it on the weekend). Either way is cool with me!

@lcheylus
Copy link
Contributor Author

lcheylus commented Nov 29, 2023

Thanks @n1000 to fix compilation on OpenBSD. I merged your modifications in a personal branch, it works if I don't compile with unix feature :)

I propose to split this issue in 3 different ones:

  • WIP to fix build on OpenBSD in this issue => I will submit a PR to close it.
  • No support for utmpx on OpenBSD (WIP in my personal fork to fix it)
  • add an OpenBSD CI job as proposed by @tertsdiepraam : use vmactions/openbsd-vm GH action with OpenBSD version 7.4 (current version).

lcheylus added a commit to lcheylus/rust-coreutils that referenced this issue Nov 29, 2023
  - uucore/src/lib/features/fs.rs: add target_os = OpenBSD when needed
  - uucore/src/lib/features/fsext.rs: implement FsUsage::new for OpenBSD

  - fixes uutils#5448

  - initial code by n1000 https://github.com/n1000/coreutils/tree/openbsd_compile_fixes

Signed-off-by: Laurent Cheylus <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants