-
Notifications
You must be signed in to change notification settings - Fork 236
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
Add the ability to use pkg_config on windows build #486
base: main
Are you sure you want to change the base?
Add the ability to use pkg_config on windows build #486
Conversation
Hi @alexcrichton and @sagebind can you review this change please ? Many Thks 😀. |
Sorry this is one I don't personally have the time to invest in at this time. Changing build behavior of longstanding platforms often comes with breakage perhaps months down the line that I'm not in a position to manage at this time personally. |
I understand. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made a similar change to rust-openssl
recently, and this change looks reasonable to me with two suggestions:
-
I'd only attempt using
pkg-config
with non-MSVC targets. -
Add a CI target which cross-compiles from Linux on a mingw toolchain, and running the tests in Wine.
Unfortunately Ubuntu doesn't have a pre-packaged mingw
libcurl
, so you'd need to buildcurl
from source outside of this project, disable the auto-vendoring inbuild.rs
(to ensure you're definitely using your "system libcurl"), and setup the pkg-config paths correctly for it.
With those changes, I think this PR should be good:
-
when targeting Windows,
curl-rust
will continue to try usingvcpkg
first (so should have no effect if you usevcpkg
); so this will only activate ifvcpkg-rs
can't find a matching package for the target. -
pkg-config-rs
by default won't allow cross-compiles (and potentially mixing host and target.pc
files) unless you set up certainpkg-config
environment variables for cross-compilation, or you setPKG_CONFIG_ALLOW_CROSS=1
-- so it's effectively opt-in there. -
mingw has separate environments and prefixes for each build toolchain (eg:
mingw64
,clangw64
, etc.) in an attempt to avoid cross-contamination.
The risk is if static-curl
is disabled and try_pkgconfig
somehow returned an invalid configuration (because of a misconfigured build environment), now it won't fall back to building a vendored curl
from the git submodule. Setting the static-curl
feature would work around this.
@@ -39,6 +39,8 @@ fn main() { | |||
if windows { | |||
if try_vcpkg() { | |||
return; | |||
} else if try_pkg_config() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd only run try_pkg_config
when targeting non-MSVC targets.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, on second thought, this is fine; will explain in a comment on this PR.
It looks like |
Closes #484