erickt / rust-zmq

Rust zeromq bindings.
Apache License 2.0
887 stars 189 forks source link

zeromq-src #257

Closed AxelNennker closed 5 years ago

AxelNennker commented 5 years ago

I suggest to follow the example of rust-openssl to build the library from source if needed or when the developer requests it.

rust-openssl has a crate feature 'vendored' which gets the openss source code by using the openssl-src crate. https://github.com/sfackler/rust-openssl/blob/master/openssl-sys/Cargo.toml#L15 Then ./configure --prefix=OUTDIR/... && make && make install is run. Afterwards the openssl libraries are available in OUTDIR/... The right compiler is found using the CC crate.

This would enable zeromq to be used when e.g. cross-compiling to e.g. Android without struggle of the developer.

Currently cargo build --target= requires the developer to build libzmq for that target beforehand. By supporting building from from we could avoid this.

jean-airoldie commented 5 years ago

Something like this?

AxelNennker commented 5 years ago

Yes, but here for this crate

jean-airoldie commented 5 years ago

The crate I linked is compatible with this lib, so it would be trivial to add support.

rotty commented 5 years ago

@jean-airoldie I think there could (should?) probably be a shared libzmq-src (or rather zeromq-src, as @AxelNennker suggested) crate shared between the libzmq crate and the zmq crate.

I've tried to explain this review how this might work out.

jean-airoldie commented 5 years ago

I do agree with this approach. It might be interesting to create a new repo entirely. It should probably be named zeromq-sys or libzmq-sys to follow the rust cffi conventions.

The approach I went with was to use a libzmq git submodule and allow the user to decide whether to link statically or dynamically (or build with DRAFT API etc.). I also generate bindings with every build (which add a clang-6 dependency). From what I understand that's pretty much what you where looking to do.

In all cases I would be interested in helping maintain such a crate since I have a couple applications that would depend on it.

AxelNennker commented 5 years ago

@jean-airoldie Thanks, Jean. How about you create a PR to rust-zmq that adds compile-from-src support and see what rust-zmq maintainers say to that?

My motivation is that I would like to see cargo build --target=aarch64-linux-android working. There are more step needed to that goal but compiling zmq from source is an important one in that direction.

jean-airoldie commented 5 years ago

I just not convinced that such a crate should live here as this repo is not as active as I would like. If I have to wait several months for my PRs to be reviewed and merged its no good. That's why I'm interested to see what @rotty thinks.

AxelNennker commented 5 years ago

Why would the src-crate have to live here? Couldn't you publish your zeromq-src crate at crates.io like openssl does and use that crate here and where ever it is needed/useful? https://crates.io/crates/openssl-src

Where the repo for this zeromq-src lives is not so interesting. I assume that you and @rotty and others will contribute if necessary. It seems easy to set up and probably does not need much maintenance except for the occasional src-update

jean-airoldie commented 5 years ago

Right this makes a lot of sense. I did not think about making the src and sys crate separate.

I am personally using the library from the master branch since I submit occasional PRs, so that would require little bit of maintenance in the form of occasion version bumps.

jean-airoldie commented 5 years ago

Alright, so I made this crate which provides the basic tooling as well as the libzmq source code. I'll make a PR to integrate it in zmq-sys.

rotty commented 5 years ago

This will be resolved when #267 lands, which is almost ready.

rotty commented 5 years ago

PR #267 has been merged, so this should be resolved now.