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

Build fails on OpenBSD #19

Closed
la-ninpre opened this issue Mar 11, 2022 · 12 comments
Closed

Build fails on OpenBSD #19

la-ninpre opened this issue Mar 11, 2022 · 12 comments

Comments

@la-ninpre
Copy link

OpenBSD is listed as a supported platforms, but it fails to build on it.

Here is error log. It seems that libc crate doesn't have these structs and functions on openbsd.

   Compiling thread-priority v0.8.0
error[E0412]: cannot find type `sched_param` in crate `libc`
  --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/thread-priority-0.8.0/src/unix.rs:63:34
   |
63 |     fn into_posix(self) -> libc::sched_param {
   |                                  ^^^^^^^^^^^ not found in `libc`

error[E0412]: cannot find type `sched_param` in crate `libc`
  --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/thread-priority-0.8.0/src/unix.rs:64:54
   |
64 |         let mut param = unsafe { MaybeUninit::<libc::sched_param>::zeroed().assume_init() };
   |                                                      ^^^^^^^^^^^ not found in `libc`

error[E0412]: cannot find type `sched_param` in crate `libc`
  --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/thread-priority-0.8.0/src/unix.rs:69:38
   |
69 |     fn from_posix(sched_param: libc::sched_param) -> Self {
   |                                      ^^^^^^^^^^^ not found in `libc`

error[E0425]: cannot find function `__errno_location` in crate `libc`
   --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/thread-priority-0.8.0/src/unix.rs:204:38
    |
204 |                 Err(Error::OS(*libc::__errno_location()))
    |                                      ^^^^^^^^^^^^^^^^ not found in `libc`

error[E0425]: cannot find function `__errno_location` in crate `libc`
   --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/thread-priority-0.8.0/src/unix.rs:222:38
    |
222 |                 Err(Error::OS(*libc::__errno_location()))
    |                                      ^^^^^^^^^^^^^^^^ not found in `libc`

error[E0425]: cannot find function `pthread_setschedparam` in crate `libc`
   --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/thread-priority-0.8.0/src/unix.rs:387:23
    |
387 |                 libc::pthread_setschedparam(
    |                       ^^^^^^^^^^^^^^^^^^^^^ not found in `libc`

error[E0412]: cannot find type `sched_param` in crate `libc`
   --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/thread-priority-0.8.0/src/unix.rs:390:45
    |
390 |                     &params as *const libc::sched_param,
    |                                             ^^^^^^^^^^^ not found in `libc`

error[E0425]: cannot find function `pthread_getschedparam` in crate `libc`
   --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/thread-priority-0.8.0/src/unix.rs:452:25
    |
452 |         let ret = libc::pthread_getschedparam(
    |                         ^^^^^^^^^^^^^^^^^^^^^ not found in `libc`

error[E0412]: cannot find type `sched_param` in crate `libc`
   --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/thread-priority-0.8.0/src/unix.rs:455:39
    |
455 |             &mut params as *mut libc::sched_param,
    |                                       ^^^^^^^^^^^ not found in `libc`

Some errors have detailed explanations: E0412, E0425.
For more information about an error, try `rustc --explain E0412`.
error: could not compile `thread-priority` due to 9 previous errors
@iddm
Copy link
Owner

iddm commented Mar 11, 2022

Thanks much for reporting this. Before writing down the list I carefully checked if the same mechanisms are available in BSD and they should be. I think this is a bug of libc that it doesn't expose these functions in the crate for openbsd, I'll have a look there.

OpenBSD itself should have the support.

Unfortunately, GitHub CI doesn't have *BSD building machines which I'd really like to use for this crate.

Strange enough, the libc crate has the sched_param defined for FreeBSD and NetBSD, but not for OpenBSD!

@iddm
Copy link
Owner

iddm commented Mar 26, 2022

After the pull request in libc gets merged, I'll need to work around the absence of libc::__errno_location() in the thread-priority code.

@iddm
Copy link
Owner

iddm commented Apr 7, 2022

Can you please try either with the master branch or published version 0.8.1?

@la-ninpre
Copy link
Author

tested both, it builds now, yeah.

but when i ran cargo test --test unix there were 16 failed tests, is this okay?

@iddm
Copy link
Owner

iddm commented Apr 7, 2022

This is odd, can you please tell what tests fail for you?

@la-ninpre
Copy link
Author

here's the output of test command:

    Finished test [unoptimized + debuginfo] target(s) in 0.03s
     Running tests/unix.rs (target/debug/deps/unix-7edcd13525f73f7c)

running 20 tests
test check_min_and_max_priority_values::case_4 ... FAILED
test check_min_and_max_priority_values::case_1 ... FAILED
test check_min_and_max_priority_values::case_2 ... FAILED
test check_min_and_max_priority_values::case_3 ... FAILED
test check_min_and_max_priority_values::case_5 ... ok
test check_min_and_max_priority_values::case_6 ... ok
test get_and_set_priority_with_normal_policies::policy_1::correct_priority_2::incorrect_priority_1 ... FAILED
test get_and_set_priority_with_normal_policies::policy_2::correct_priority_2::incorrect_priority_1 ... FAILED
test get_and_set_priority_with_normal_policies::policy_3::correct_priority_1::incorrect_priority_1 ... FAILED
test get_and_set_priority_with_normal_policies::policy_1::correct_priority_1::incorrect_priority_1 ... FAILED
test get_and_set_priority_with_normal_policies::policy_4::correct_priority_1::incorrect_priority_1 ... FAILED
test get_and_set_priority_with_normal_policies::policy_4::correct_priority_2::incorrect_priority_1 ... FAILED
test get_and_set_priority_with_realtime_policy_requires_capabilities::case_2_roundrobin ... ok
test get_and_set_priority_with_normal_policies::policy_2::correct_priority_1::incorrect_priority_1 ... FAILED
test get_and_set_priority_with_realtime_policy_requires_capabilities::case_1_fifo ... ok
test get_and_set_priority_with_normal_policies::policy_3::correct_priority_2::incorrect_priority_1 ... FAILED
test set_priority_with_normal_policy_but_with_invalid_value::case_1 ... FAILED
test set_priority_with_normal_policy_but_with_invalid_value::case_2 ... FAILED
test set_priority_with_normal_policy_but_with_invalid_value::case_3 ... FAILED
test set_priority_with_normal_policy_but_with_invalid_value::case_4 ... FAILED

failures:

---- check_min_and_max_priority_values::case_4 stdout ----
-------------- TEST START --------------
thread 'check_min_and_max_priority_values::case_4' panicked at 'called `Result::unwrap()` on an `Err` value: OS(22)', tests/unix.rs:53:66

---- check_min_and_max_priority_values::case_1 stdout ----
-------------- TEST START --------------
thread 'check_min_and_max_priority_values::case_1' panicked at 'called `Result::unwrap()` on an `Err` value: OS(22)', tests/unix.rs:53:66

---- check_min_and_max_priority_values::case_2 stdout ----
-------------- TEST START --------------
thread 'check_min_and_max_priority_values::case_2' panicked at 'called `Result::unwrap()` on an `Err` value: OS(22)', tests/unix.rs:53:66
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- check_min_and_max_priority_values::case_3 stdout ----
-------------- TEST START --------------
thread 'check_min_and_max_priority_values::case_3' panicked at 'assertion failed: posix_range.contains(&max_value)', tests/unix.rs:55:5

---- get_and_set_priority_with_normal_policies::policy_1::correct_priority_2::incorrect_priority_1 stdout ----
-------------- TEST START --------------
thread 'get_and_set_priority_with_normal_policies::policy_1::correct_priority_2::incorrect_priority_1' panicked at 'assertion failed: set_thread_priority_and_policy(thread_native_id(), correct_priority,\n                               policy).is_ok()', tests/unix.rs:26:5

---- get_and_set_priority_with_normal_policies::policy_2::correct_priority_2::incorrect_priority_1 stdout ----
-------------- TEST START --------------
thread 'get_and_set_priority_with_normal_policies::policy_2::correct_priority_2::incorrect_priority_1' panicked at 'assertion failed: set_thread_priority_and_policy(thread_native_id(), correct_priority,\n                               policy).is_ok()', tests/unix.rs:26:5

---- get_and_set_priority_with_normal_policies::policy_3::correct_priority_1::incorrect_priority_1 stdout ----
-------------- TEST START --------------
thread 'get_and_set_priority_with_normal_policies::policy_3::correct_priority_1::incorrect_priority_1' panicked at 'assertion failed: set_thread_priority_and_policy(thread_native_id(), correct_priority,\n                               policy).is_ok()', tests/unix.rs:26:5

---- get_and_set_priority_with_normal_policies::policy_1::correct_priority_1::incorrect_priority_1 stdout ----
-------------- TEST START --------------
thread 'get_and_set_priority_with_normal_policies::policy_1::correct_priority_1::incorrect_priority_1' panicked at 'assertion failed: set_thread_priority_and_policy(thread_native_id(), correct_priority,\n                               policy).is_ok()', tests/unix.rs:26:5

---- get_and_set_priority_with_normal_policies::policy_4::correct_priority_1::incorrect_priority_1 stdout ----
-------------- TEST START --------------
thread 'get_and_set_priority_with_normal_policies::policy_4::correct_priority_1::incorrect_priority_1' panicked at 'assertion failed: set_thread_priority_and_policy(thread_native_id(), incorrect_priority,\n                               policy).is_err()', tests/unix.rs:22:5

---- get_and_set_priority_with_normal_policies::policy_4::correct_priority_2::incorrect_priority_1 stdout ----
-------------- TEST START --------------
thread 'get_and_set_priority_with_normal_policies::policy_4::correct_priority_2::incorrect_priority_1' panicked at 'assertion failed: set_thread_priority_and_policy(thread_native_id(), incorrect_priority,\n                               policy).is_err()', tests/unix.rs:22:5

---- get_and_set_priority_with_normal_policies::policy_2::correct_priority_1::incorrect_priority_1 stdout ----
-------------- TEST START --------------
thread 'get_and_set_priority_with_normal_policies::policy_2::correct_priority_1::incorrect_priority_1' panicked at 'assertion failed: set_thread_priority_and_policy(thread_native_id(), correct_priority,\n                               policy).is_ok()', tests/unix.rs:26:5

---- get_and_set_priority_with_normal_policies::policy_3::correct_priority_2::incorrect_priority_1 stdout ----
-------------- TEST START --------------
thread 'get_and_set_priority_with_normal_policies::policy_3::correct_priority_2::incorrect_priority_1' panicked at 'assertion failed: set_thread_priority_and_policy(thread_native_id(), correct_priority,\n                               policy).is_ok()', tests/unix.rs:26:5

---- set_priority_with_normal_policy_but_with_invalid_value::case_1 stdout ----
-------------- TEST START --------------
thread 'set_priority_with_normal_policy_but_with_invalid_value::case_1' panicked at 'assertion failed: `(left == right)`
  left: `Err(OS(22))`,
 right: `Err(PriorityNotInRange(0..=0))`', tests/unix.rs:88:5

---- set_priority_with_normal_policy_but_with_invalid_value::case_2 stdout ----
-------------- TEST START --------------
thread 'set_priority_with_normal_policy_but_with_invalid_value::case_2' panicked at 'assertion failed: `(left == right)`
  left: `Err(OS(22))`,
 right: `Err(PriorityNotInRange(0..=0))`', tests/unix.rs:88:5

---- set_priority_with_normal_policy_but_with_invalid_value::case_3 stdout ----
-------------- TEST START --------------
thread 'set_priority_with_normal_policy_but_with_invalid_value::case_3' panicked at 'assertion failed: `(left == right)`
  left: `Ok(())`,
 right: `Err(PriorityNotInRange(0..=0))`', tests/unix.rs:88:5

---- set_priority_with_normal_policy_but_with_invalid_value::case_4 stdout ----
-------------- TEST START --------------
thread 'set_priority_with_normal_policy_but_with_invalid_value::case_4' panicked at 'assertion failed: `(left == right)`
  left: `Err(OS(22))`,
 right: `Err(PriorityNotInRange(0..=0))`', tests/unix.rs:88:5


failures:
    check_min_and_max_priority_values::case_1
    check_min_and_max_priority_values::case_2
    check_min_and_max_priority_values::case_3
    check_min_and_max_priority_values::case_4
    get_and_set_priority_with_normal_policies::policy_1::correct_priority_1::incorrect_priority_1
    get_and_set_priority_with_normal_policies::policy_1::correct_priority_2::incorrect_priority_1
    get_and_set_priority_with_normal_policies::policy_2::correct_priority_1::incorrect_priority_1
    get_and_set_priority_with_normal_policies::policy_2::correct_priority_2::incorrect_priority_1
    get_and_set_priority_with_normal_policies::policy_3::correct_priority_1::incorrect_priority_1
    get_and_set_priority_with_normal_policies::policy_3::correct_priority_2::incorrect_priority_1
    get_and_set_priority_with_normal_policies::policy_4::correct_priority_1::incorrect_priority_1
    get_and_set_priority_with_normal_policies::policy_4::correct_priority_2::incorrect_priority_1
    set_priority_with_normal_policy_but_with_invalid_value::case_1
    set_priority_with_normal_policy_but_with_invalid_value::case_2
    set_priority_with_normal_policy_but_with_invalid_value::case_3
    set_priority_with_normal_policy_but_with_invalid_value::case_4

test result: FAILED. 4 passed; 16 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.01s

error: test failed, to rerun pass '--test unix'

@iddm
Copy link
Owner

iddm commented Apr 8, 2022

I will take a look.

@iddm
Copy link
Owner

iddm commented Apr 9, 2022

Okay, I know what the problem is and know how to fix it. I'll post once I fix it.

@iddm
Copy link
Owner

iddm commented Apr 12, 2022

It looks like it builds now. Can you please check it once more?

@la-ninpre
Copy link
Author

la-ninpre commented Apr 12, 2022

now all test are passing. thanks!

i guess, the issue can be closed now?

@iddm
Copy link
Owner

iddm commented Apr 12, 2022

Glad to hear it works for you now! Well, you are the author of this issue and you decide when to close it. I'd say if it works for you and the issue you opened this ticket for has been addressed, I'd close it :-)

@la-ninpre
Copy link
Author

ah, okay, i'm closing it then. thank you for your support!

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

No branches or pull requests

2 participants