erickt / rust-zmq

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

Feature-probing at build time is flawed #275

Closed rotty closed 5 years ago

rotty commented 5 years ago

After reconsidering how the zmq_has API is intended to be used, I think using it at build time to expose parts of the API, as it is currently done, is a flawed approach:

Thus, all feature probing at build time should be removed, the whole API should be always exposed, and the documentation of the affected parts should be updated to indicate that they may fail with when the corresponding feature is not present in the libzmq present.

This will get rid of all the cross-compilation issues, and allow Rust code to handle missing features at runtime, like C code could would.

The feature-probing was introduced originally in commit d8cb8ee0 ("Binding update for ZMQ v4.1") in 2016, and was probably intended to cope with potentially missing C ABI, allowing for rust-zmq to work with a range of different libzmq versions, including ones that expose a subset of the C ABI that was supported by rust-zmq. Tying it to the zmq_has runtime probe was a mistake, I realize now, from the very outset.

Thus, going forward, after resolving this issue, rust-zmq will expose only functionality supported by the C ABI of the minimum libzmq version it requires, and will never conditionally disable parts of its API for older C ABI versions.

This affects at least issue #179 and the discussion in PR #247.