-
Notifications
You must be signed in to change notification settings - Fork 77
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
Dynamically link zlib-ng #158
Comments
Even though I don't know enough yet to help with figuring out implementation details, I can say that any implementation of this feature would need to be backwards compatible, i.e. non-breaking. With this said, such a feature will also help to one day make it possible to let people opt-in to using system libraries, static or dynamic, via |
Maybe it could use a CARGO environment for this instead of a feature? I've seen other *-sys crates (e.g. openssl) doing this, with a vendored feature to override environment settings. |
might be just do |
For zlib-rs we want to test against locally-built versions of zlib a lot, so I hacked up a script that takes the https://github.com/memorysafety/zlib-rs/blob/main/dynamic-libz-sys/src/generated.rs e.g. extern "C" {
fn deflateReset(strm: z_streamp) -> c_int;
} becomes pub unsafe fn deflateReset(strm: z_streamp) -> c_int {
type Func = unsafe extern "C" fn(strm: z_streamp) -> c_int;
let f: libloading::Symbol<Func> = dynamic_library()
.get(if_zng!({ concat!("zng_", "deflateReset") }, "deflateReset").as_bytes())
.unwrap();
f(strm)
} The reason this approach is useful for us is that we can load two versions of zlib into the same binary without name conflicts. There is a performance penalty I guess but we only need this for debugging anyway so that's not an issue. Maybe this is useful for someone while this crate does not implement picking a custom dylib to link. |
Linux distros prefer shared libraries over vendor it whenever possible, and zlib-ng is (at least) available on Arch Linux. I am wondering if we can support dynamic linking in libz-ng-sys?
I would like to help and create a PR, but we may need to discuss how to expose this feature first, if it is acceptable.
The text was updated successfully, but these errors were encountered: