Add the ability to use pkg_config on windows build#486
Add the ability to use pkg_config on windows build#486lepapareil wants to merge 1 commit intoalexcrichton:mainfrom
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. |
micolous
left a comment
There was a problem hiding this comment.
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-configwith 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 buildcurlfrom 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-rustwill continue to try usingvcpkgfirst (so should have no effect if you usevcpkg); so this will only activate ifvcpkg-rscan't find a matching package for the target. -
pkg-config-rsby default won't allow cross-compiles (and potentially mixing host and target.pcfiles) unless you set up certainpkg-configenvironment 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.
| if windows { | ||
| if try_vcpkg() { | ||
| return; | ||
| } else if try_pkg_config() { |
There was a problem hiding this comment.
I'd only run try_pkg_config when targeting non-MSVC targets.
There was a problem hiding this comment.
Actually, on second thought, this is fine; will explain in a comment on this PR.
|
It looks like |
Closes #484