erickt / rust-zmq

Rust zeromq bindings.
Apache License 2.0
900 stars 194 forks source link

Fail to build on openbsd #170

Closed kpcyrd closed 7 years ago

kpcyrd commented 7 years ago
   Compiling zmq-sys v0.8.1
   Compiling libc v0.2.21
/home/user/.cargo/registry/src/github.com-88ac128001ac3a9a/zmq-sys-0.8.1/src/errno.rs:23:35: 23:48 error: unresolved name `errno::EPROTO` [E0425]
/home/user/.cargo/registry/src/github.com-88ac128001ac3a9a/zmq-sys-0.8.1/src/errno.rs:23 pub const EPROTO:           i32 = errno::EPROTO;
                                                                                                                           ^~~~~~~~~~~~~
/home/user/.cargo/registry/src/github.com-88ac128001ac3a9a/zmq-sys-0.8.1/src/errno.rs:23:35: 23:48 help: run `rustc --explain E0425` to see a detailed explanation
error: aborting due to previous error
error: Could not compile `zmq-sys`.

To learn more, run the command again with --verbose.

Steps to reproduce: 1) install openbsd 6.0 2) pkg_add -v cargo zeromq 3) cargo new --bin foo 4) Add zmq = "0.8" to Cargo.toml 5) cargo build

See these links about openbsd not having EPROTO: https://github.com/networkupstools/nut/issues/44 https://github.com/performancecopilot/pcp/issues/71 https://bugs.freedesktop.org/show_bug.cgi?id=84665

kpcyrd commented 7 years ago

I've applied the following patch:

diff --git a/zmq-sys/src/errno.rs b/zmq-sys/src/errno.rs
index fc5993f..1faa3fd 100644
--- a/zmq-sys/src/errno.rs
+++ b/zmq-sys/src/errno.rs
@@ -20,7 +20,10 @@ pub const ENOENT:           i32 = errno::ENOENT;
 pub const ENOMEM:           i32 = errno::ENOMEM;
 pub const ENOTCONN:         i32 = errno::ENOTCONN;
 pub const ENOTSOCK:         i32 = errno::ENOTSOCK;
+#[cfg(not(target_os = "openbsd"))]
 pub const EPROTO:           i32 = errno::EPROTO;
+#[cfg(target_os = "openbsd")]
+pub const EPROTO:           i32 = errno::EIO;
 pub const EPROTONOSUPPORT:  i32 = errno::EPROTONOSUPPORT;

 #[cfg(not(target_os = "windows"))]

and the build now looks like this:

   Compiling zmq v0.9.0 (file:///home/user/rust-zmq)
src/lib.rs:32:20: 32:23 error: unexpected token: `unsafe`
src/lib.rs:32         let rc = $($tt)*;
                                 ^~~
src/lib.rs:32:20: 32:23 error: unexpected token: `unsafe`
src/lib.rs:32         let rc = $($tt)*;
                                 ^~~
src/lib.rs:32:20: 32:23 error: unexpected token: `unsafe`
src/lib.rs:32         let rc = $($tt)*;
                                 ^~~
src/lib.rs:32:20: 32:23 error: unexpected token: `unsafe`
src/lib.rs:32         let rc = $($tt)*;
                                 ^~~
src/lib.rs:32:20: 32:23 error: unexpected token: `unsafe`
src/lib.rs:32         let rc = $($tt)*;
                                 ^~~
src/lib.rs:32:20: 32:23 error: unexpected token: `unsafe`
src/lib.rs:32         let rc = $($tt)*;
                                 ^~~
src/lib.rs:32:20: 32:23 error: unexpected token: `unsafe`
src/lib.rs:32         let rc = $($tt)*;
                                 ^~~
src/lib.rs:32:20: 32:23 error: unexpected token: `unsafe`
src/lib.rs:32         let rc = $($tt)*;
                                 ^~~
src/lib.rs:32:20: 32:23 error: unexpected token: `unsafe`
src/lib.rs:32         let rc = $($tt)*;
                                 ^~~
src/lib.rs:32:20: 32:23 error: unexpected token: `unsafe`
src/lib.rs:32         let rc = $($tt)*;
                                 ^~~
src/lib.rs:32:20: 32:23 error: unexpected token: `unsafe`
src/lib.rs:32         let rc = $($tt)*;
                                 ^~~
src/lib.rs:32:20: 32:23 error: unexpected token: `unsafe`
src/lib.rs:32         let rc = $($tt)*;
                                 ^~~
src/lib.rs:32:20: 32:23 error: unexpected token: `unsafe`
src/lib.rs:32         let rc = $($tt)*;
                                 ^~~
src/lib.rs:32:20: 32:23 error: unexpected token: `unsafe`
src/lib.rs:32         let rc = $($tt)*;
                                 ^~~
src/lib.rs:32:20: 32:23 error: unexpected token: `unsafe`
src/lib.rs:32         let rc = $($tt)*;
                                 ^~~
src/lib.rs:32:20: 32:23 error: unexpected token: `unsafe`
src/lib.rs:32         let rc = $($tt)*;
                                 ^~~
src/lib.rs:32:20: 32:23 error: unexpected token: `unsafe`
src/lib.rs:32         let rc = $($tt)*;
                                 ^~~
src/lib.rs:32:20: 32:23 error: unexpected token: `unsafe`
src/lib.rs:32         let rc = $($tt)*;
                                 ^~~
src/lib.rs:32:20: 32:23 error: unexpected token: `unsafe`
src/lib.rs:32         let rc = $($tt)*;
                                 ^~~
error: aborting due to 19 previous errors
error: Could not compile `zmq`.

To learn more, run the command again with --verbose.
kpcyrd commented 7 years ago

I was able to resolve this issue by bumping my openbsd install to a 6.1 snapshot and installing rustc 1.15.1