Skip to content
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

curl-sys' vendoring depends on libz-sys vendoring #515

Open
micolous opened this issue Jul 28, 2023 · 0 comments
Open

curl-sys' vendoring depends on libz-sys vendoring #515

micolous opened this issue Jul 28, 2023 · 0 comments

Comments

@micolous
Copy link

micolous commented Jul 28, 2023

When libz-sys fails to find zlib, it falls back to building it from source.

However, when curl-rust vendors libcurl (when it falls back), it transitively depends on either zlib being present in system include paths or libz-sys vendoring it into the same paths:

let dst = PathBuf::from(env::var_os("OUT_DIR").unwrap());
let include = dst.join("include");
let build = dst.join("build");

libz-sys recently attempted to use pkg-config on Windows, which broke curl-sys using an MSVC toolchain (from inside an MSYS2 environment, presumably without vcpkg), because it would no longer need to build zlib from source: rust-lang/libz-sys#143

However, because curl-sys does not support pkg-config (#486), on Windows:

When building from source, curl-sys generates a pkg-config file, but doesn't add any linkage or include path information for zlib:

.replace("@includedir@", include.to_str().unwrap())
.replace("@CPPFLAG_CURL_STATICLIB@", "-DCURL_STATICLIB")
.replace("@LIBCURL_LIBS@", "")

...and enables zlib support:

.define("HAVE_ZLIB_H", None)

...it might get something from vcpkg if built on an MSVC host (because build.rs cfg directives are based on the host, not the target):

curl-rust/curl-sys/build.rs

Lines 296 to 299 in ff6ad21

#[cfg(target_env = "msvc")]
vcpkg::Config::new().find_package("openssl").ok();
#[cfg(target_env = "msvc")]
vcpkg::Config::new().find_package("zlib").ok();

...but otherwise this means zlib.h needs to be in $OUT_DIR/include (which it gets from libz-sys' vendoring) or in the system include paths (which it gets on most non-Windows platforms).

When vendoring libcurl, curl-sys should find zlib properly (ideally, the same way as libz-sys does).

It would be better if you needed to explicitly enable vendoring in this library, because while "silent fallback" can be helpful, it leads to surprising behaviour like this, and makes it more difficult to audit your dependencies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant