-
-
Notifications
You must be signed in to change notification settings - Fork 29
Description
We currently have a number of functions like this in our public api
#[export_name = prefix!(inflate)]
pub unsafe extern "C-unwind" fn inflate(/* ... */) -> i32 {
/* ... */
}The prefix! macro can be used to namespace the symbols that we export. Recently, a new idea came up, we could export the symbols only conditionally:
#[cfg_attr(feature = "export-symbols", export_name = prefix!(inflate))]
pub unsafe extern "C-unwind" fn inflate(/* ... */) -> i32 {
/* ... */
}That solves a common problem with using zlib-rs in existing projects: the names we export clash with another (usually indirect) dependency that also defines these symbols (e.g. openssl relies on libz-sys which defines these symbols). It would also be possible to have multiple versions of zlib-rs in the same dependency tree (that has no practical value, but the flexibility could be useful).
Proposal
We add the export-symbols feature flag
export-symbols = []And use cfg_attr to only export the symbol names when this feature flag is active.
The export-symbols feature flag is off by default: when used as a rust crate, the symbols will not be exported!
Because that changes existing behavior, I think this needs to be a major version bump.