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

Add support for OpenBSD #685

Closed
1 task
wezm opened this issue Jul 17, 2017 · 6 comments
Closed
1 task

Add support for OpenBSD #685

wezm opened this issue Jul 17, 2017 · 6 comments

Comments

@wezm
Copy link
Contributor

wezm commented Jul 17, 2017

OpenBSD appears to be not currently supported. Attempting to compile nix v0.8.1 on OpenBSD 6.1 amd64 with rust 1.16.0 produces the errors below. I would like to use nix in a project that I'll be deploying on OpenBSD so will take an initial pass at adding support. I'll update the task list here as I get more details on what needs to be implemented:

  • Determine what is needed to get nix building on OpenBSD
   Compiling nix v0.8.1
error[E0425]: cannot find value `EV_DISPATCH` in module `libc`
   --> /home/vagrant/.cargo/registry/src/github.com-1ecc6299db9ec823/nix-0.8.1/src/macros.rs:144:31
    |
144 |                 const $flag = libc::$flag,
    |                               ^ not found in `libc`
    | 
   ::: /home/vagrant/.cargo/registry/src/github.com-1ecc6299db9ec823/nix-0.8.1/src/sys/event.rs
    |
80  | libc_bitflags!{
    | - in this macro invocation
    |
    = help: possible candidate is found in another module, you can import it into scope:
              `use sys::event::EV_DISPATCH;`

error[E0412]: cannot find type sigevent in module libc
--> /home/vagrant/.cargo/registry/src/github.com-1ecc6299db9ec823/nix-0.8.1/src/sys/signal.rs:447:15
|
447 | sigevent: libc::sigevent
| ^^^^^^^^^^^^^^ not found in libc

error[E0412]: cannot find type sigevent in module libc
--> /home/vagrant/.cargo/registry/src/github.com-1ecc6299db9ec823/nix-0.8.1/src/sys/signal.rs:464:46
|
464 | let mut sev = unsafe { mem::zeroed::libc::sigevent()};
| ^^^^^^^^^^^^^^ not found in libc

error[E0425]: cannot find value SIGEV_NONE in module libc
--> /home/vagrant/.cargo/registry/src/github.com-1ecc6299db9ec823/nix-0.8.1/src/sys/signal.rs:466:39
|
466 | SigevNotify::SigevNone => libc::SIGEV_NONE,
| ^^^^^^^^^^^^^^^^ not found in libc

error[E0425]: cannot find value SIGEV_SIGNAL in module libc
--> /home/vagrant/.cargo/registry/src/github.com-1ecc6299db9ec823/nix-0.8.1/src/sys/signal.rs:467:45
|
467 | SigevNotify::SigevSignal{..} => libc::SIGEV_SIGNAL,
| ^^^^^^^^^^^^^^^^^^ not found in libc

error[E0412]: cannot find type sigevent in module libc
--> /home/vagrant/.cargo/registry/src/github.com-1ecc6299db9ec823/nix-0.8.1/src/sys/signal.rs:506:27
|
506 | fn set_tid(_sev: &mut libc::sigevent, _sigev_notify: &SigevNotify) {
| ^^^^^^^^^^^^^^ not found in libc

error[E0412]: cannot find type sigevent in module libc
--> /home/vagrant/.cargo/registry/src/github.com-1ecc6299db9ec823/nix-0.8.1/src/sys/signal.rs:509:31
|
509 | pub fn sigevent(&self) -> libc::sigevent {
| ^^^^^^^^^^^^^^ not found in libc

error[E0412]: cannot find type sigevent in module libc
--> /home/vagrant/.cargo/registry/src/github.com-1ecc6299db9ec823/nix-0.8.1/src/sys/signal.rs:536:19
|
536 | impl<'a> From<&'a libc::sigevent> for SigEvent {
| ^^^^^^^^^^^^^^ not found in libc

error[E0412]: cannot find type sigevent in module libc
--> /home/vagrant/.cargo/registry/src/github.com-1ecc6299db9ec823/nix-0.8.1/src/sys/signal.rs:537:24
|
537 | fn from(sigevent: &libc::sigevent) -> Self {
| ^^^^^^^^^^^^^^ not found in libc

error[E0308]: mismatched types
--> /home/vagrant/.cargo/registry/src/github.com-1ecc6299db9ec823/nix-0.8.1/src/macros.rs:144:31
|
144 | const $flag = libc::$flag,
| ^ expected u32, found u16
|
::: /home/vagrant/.cargo/registry/src/github.com-1ecc6299db9ec823/nix-0.8.1/src/sys/event.rs
|
80 | libc_bitflags!{
| - in this macro invocation
|
= help: here are some functions which might fulfill your needs:
- .count_ones()
- .count_zeros()
- .leading_zeros()
- .trailing_zeros()

error[E0308]: mismatched types
--> /home/vagrant/.cargo/registry/src/github.com-1ecc6299db9ec823/nix-0.8.1/src/macros.rs:144:31
|
144 | const $flag = libc::$flag,
| ^ expected u32, found u16
|
::: /home/vagrant/.cargo/registry/src/github.com-1ecc6299db9ec823/nix-0.8.1/src/sys/event.rs
|
80 | libc_bitflags!{
| - in this macro invocation
|
= help: here are some functions which might fulfill your needs:
- .count_ones()
- .count_zeros()
- .leading_zeros()
- .trailing_zeros()

error[E0308]: mismatched types
--> /home/vagrant/.cargo/registry/src/github.com-1ecc6299db9ec823/nix-0.8.1/src/macros.rs:144:31
|
144 | const $flag = libc::$flag,
| ^ expected u32, found u16
|
::: /home/vagrant/.cargo/registry/src/github.com-1ecc6299db9ec823/nix-0.8.1/src/sys/event.rs
|
80 | libc_bitflags!{
| - in this macro invocation
|
= help: here are some functions which might fulfill your needs:
- .count_ones()
- .count_zeros()
- .leading_zeros()
- .trailing_zeros()

error[E0308]: mismatched types
--> /home/vagrant/.cargo/registry/src/github.com-1ecc6299db9ec823/nix-0.8.1/src/macros.rs:144:31
|
144 | const $flag = libc::$flag,
| ^ expected u32, found u16
|
::: /home/vagrant/.cargo/registry/src/github.com-1ecc6299db9ec823/nix-0.8.1/src/sys/event.rs
|
80 | libc_bitflags!{
| - in this macro invocation
|
= help: here are some functions which might fulfill your needs:
- .count_ones()
- .count_zeros()
- .leading_zeros()
- .trailing_zeros()

error[E0308]: mismatched types
--> /home/vagrant/.cargo/registry/src/github.com-1ecc6299db9ec823/nix-0.8.1/src/macros.rs:144:31
|
144 | const $flag = libc::$flag,
| ^ expected u32, found u16
|
::: /home/vagrant/.cargo/registry/src/github.com-1ecc6299db9ec823/nix-0.8.1/src/sys/event.rs
|
80 | libc_bitflags!{
| - in this macro invocation
|
= help: here are some functions which might fulfill your needs:
- .count_ones()
- .count_zeros()
- .leading_zeros()
- .trailing_zeros()

error[E0308]: mismatched types
--> /home/vagrant/.cargo/registry/src/github.com-1ecc6299db9ec823/nix-0.8.1/src/macros.rs:144:31
|
144 | const $flag = libc::$flag,
| ^ expected u32, found u16
|
::: /home/vagrant/.cargo/registry/src/github.com-1ecc6299db9ec823/nix-0.8.1/src/sys/event.rs
|
80 | libc_bitflags!{
| - in this macro invocation
|
= help: here are some functions which might fulfill your needs:
- .count_ones()
- .count_zeros()
- .leading_zeros()
- .trailing_zeros()

error[E0308]: mismatched types
--> /home/vagrant/.cargo/registry/src/github.com-1ecc6299db9ec823/nix-0.8.1/src/macros.rs:144:31
|
144 | const $flag = libc::$flag,
| ^ expected u32, found u16
|
::: /home/vagrant/.cargo/registry/src/github.com-1ecc6299db9ec823/nix-0.8.1/src/sys/event.rs
|
80 | libc_bitflags!{
| - in this macro invocation
|
= help: here are some functions which might fulfill your needs:
- .count_ones()
- .count_zeros()
- .leading_zeros()
- .trailing_zeros()

error[E0308]: mismatched types
--> /home/vagrant/.cargo/registry/src/github.com-1ecc6299db9ec823/nix-0.8.1/src/macros.rs:144:31
|
144 | const $flag = libc::$flag,
| ^ expected u32, found u16
|
::: /home/vagrant/.cargo/registry/src/github.com-1ecc6299db9ec823/nix-0.8.1/src/sys/event.rs
|
80 | libc_bitflags!{
| - in this macro invocation
|
= help: here are some functions which might fulfill your needs:
- .count_ones()
- .count_zeros()
- .leading_zeros()
- .trailing_zeros()

error[E0308]: mismatched types
--> /home/vagrant/.cargo/registry/src/github.com-1ecc6299db9ec823/nix-0.8.1/src/macros.rs:144:31
|
144 | const $flag = libc::$flag,
| ^ expected u32, found u16
|
::: /home/vagrant/.cargo/registry/src/github.com-1ecc6299db9ec823/nix-0.8.1/src/sys/event.rs
|
80 | libc_bitflags!{
| - in this macro invocation
|
= help: here are some functions which might fulfill your needs:
- .count_ones()
- .count_zeros()
- .leading_zeros()
- .trailing_zeros()

error[E0308]: mismatched types
--> /home/vagrant/.cargo/registry/src/github.com-1ecc6299db9ec823/nix-0.8.1/src/macros.rs:144:31
|
144 | const $flag = libc::$flag,
| ^ expected u32, found u16
|
::: /home/vagrant/.cargo/registry/src/github.com-1ecc6299db9ec823/nix-0.8.1/src/sys/event.rs
|
80 | libc_bitflags!{
| - in this macro invocation
|
= help: here are some functions which might fulfill your needs:
- .count_ones()
- .count_zeros()
- .leading_zeros()
- .trailing_zeros()

error: aborting due to 10 previous errors

error: Could not compile nix.

@Susurrus
Copy link
Contributor

The first priority here is to get OpenBSD supported as a Tier 3 platform, where we automatically test it. We use cross for our testing, and right now it doesn't support OpenBSD. It looks like it'll take a bit of work to make that happen.

We'd also welcome patches to nix (likely in the form of #cfging out certain parts of it on OpenBSD) and libc (where missing constants and functions are added) to improve this support and get compilation working. But without also adding CI support for OpenBSD, this will be a losing battle over the long term. Might be worth pinging japaric on #rust on IRC to see if he'd be willing to help you get OpenBSD into cross (and adding it to trust would be good to do as well for the entire ecosystem).

@Susurrus
Copy link
Contributor

(Also, if you could condense that list into action items, that'd be great. Seems like there are some improper datatypes and missing constants/functions in libc, so it should be pretty easy).

@wezm
Copy link
Contributor Author

wezm commented Jul 17, 2017

Hmm cross support seems blocked on, "having official releases of the rust-std component for OpenBSD". cross-rs/cross#97 I'll proceed with attempting to get nix building for my own purposes and go from there.

@Susurrus
Copy link
Contributor

Looking at the code for rustup, I would think this would be supported. Have you tried using rustup to install Rust on an OpenBSD machine? If it works doing that, then cross-rs/cross#97 is fixed and support can be added. That's an awfully old issue, so I wonder if things have changed.

@wezm
Copy link
Contributor Author

wezm commented Jul 18, 2017

Yep I tried it to try to get a version newer than 1.16.0:

$ ftp -o - https://sh.rustup.rs | sh
Trying 54.215.0.2...
Requesting https://sh.rustup.rs
9325 bytes received in 0.02 seconds (541.44 KB/s)
rustup: unrecognized OS type: OpenBSD

It's missing from https://github.com/rust-lang-nursery/rustup.rs/blob/master/rustup-init.sh#L189-L223

Hacking the script to include OpenBSD results in:

$ sh rustup.sh                                                                                                                                                
info: downloading installer
curl: (22) The requested URL returned error: 404 
rustup: command failed: curl -sSfL https://static.rust-lang.org/rustup/dist/x86_64-unknown-openbsd/rustup-init -o /tmp/tmp.rwjaPyJ1gg/rustup-init

@Susurrus
Copy link
Contributor

Alright, well looks like rustup is going to need someone who loves OpenBSD to get to work on it! Is that you?! :-)

Anyways, yes, let's confine ourselves to fixing OpenBSD compilation currently and we'll defer on CI for now.

bors bot added a commit that referenced this issue Aug 9, 2017
688: Support for OpenBSD r=Susurrus

Fixes #685 

These changes get nix building on OpenBSD 6.1. There is one failing test that I want a little guidance on:

```
error[E0308]: mismatched types
   --> src/sys/event.rs:333:30
    |
333 |     assert!(expected.data == actual.data());
    |                              ^^^^^^^^^^^^^ expected i64, found isize
```

`KEvent::data` is:

```
    pub fn data(&self) -> intptr_t {
        self.kevent.data as intptr_t
    }
```

I assume the test should be updated to cast to the expected type but wanted to confirm that before making the change.
@bors bors bot closed this as completed in #688 Aug 9, 2017
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