Skip to content

Conversation

@dg0yt
Copy link
Contributor

@dg0yt dg0yt commented Nov 29, 2025

Adapt to upstream changes.

I expect that the port needs to keep the build system patches in order to satisfy static linkage and multi-config requirements across CMake, pkg-config and curl-config.

Exported configuration is provided in four ways, and this is why the port keeps significant patching vs. pristine CURL:

  • curl-config scripts: non-Windows only. Single config.
    All link libs and lib dirs must be listed explicitly.
    Our patch reduces duplicate link libs.
  • pkg-config: Single config.
    It is best practice to refer to depedencies via Requires instead of Libs if possible. But upstream does both, and it also forwards private to the regular field for static builds.
    Our patch removes redundancy (causing extra work for dealing with curl-config). This trimming significantly facilitates downstream analysis of linking issues.
  • CMake package with target CURL::libcurl. Multi-config in vcpkg only.
    Our patching ensures that link libraries are found without requiring pkg-config and that multi-config use is possible. (It would be fairly easy to supply pkg-config, but this would not support multi-config.
    As before, this is achieved by using the LINK_LIBRARIES results from pkg_check_modules.
  • CMake package with variable CURL_LIBRARIES. Multi-config in vcpkg only.
    This is the legacy interface provided by the Find module. Such variables are often consumed in the expectation that they don't contain imported targets, i.e. not requiring find_dependency in downstream exports. The port used to try hard to satisfy this condition. With this PR, this will only be done in trivial cases (shared library linkage, or just OpenSSL and ZLIB dependencies). For other dependencies, CURL_LIBRARIES will just point to CURL::libcurl as implemented upstream.
    (i.e. patching is reduced a little bit now.)

)
# The on-the-fly tarballs do not carry the details of release tarballs.
vcpkg_replace_string("${SOURCE_PATH}/include/curl/curlver.h" [[-DEV"]] [["]])
vcpkg_replace_string("${SOURCE_PATH}/include/curl/curlver.h" [[LIBCURL_TIMESTAMP "[unreleased]"]] [[LIBCURL_TIMESTAMP "[vcpkg]"]])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this maybe include the port version like vcpkg-2?

Copy link
Contributor Author

@dg0yt dg0yt Dec 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • The port version isn't readily available as a CMake variable.
    (I don't want to read the manifest for an optional property.)
  • If we were using official tarballs, the value would also be const for one version.
  • If there was a strong desire for details, we might use (a fragment of) the directory name of SOURCE_PATH (e.g. c-8_18_0-1-f780f9182e.clean -> f780f9182e). It is unique for a combination of sources and patches.

@dg0yt
Copy link
Contributor Author

dg0yt commented Dec 10, 2025

vcpkg-ci-tgbot-cpp:x64-linux

FAILED: [code=1] main 
: && /usr/bin/c++ -fPIC -g -Wl,--dependency-file=CMakeFiles/main.dir/link.d CMakeFiles/main.dir/main.cpp.o -o main  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libTgBot.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libssh2.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libcrypto.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libz.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libcares.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libmbedtls.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libmbedx509.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libmbedcrypto.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libeverest.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libp256m.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libwolfssl.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libbrotlidec.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libbrotlicommon.a  -lm  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libzstd.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libz.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libssl.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libcrypto.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libcurl-d.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libidn2.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libunistring.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libldap.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/liblber.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libgnutls.a  -latomic  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libhogweed.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libgmp.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libnettle.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libtasn1.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libnghttp2.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libpsl.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libgsasl.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libgssapi_krb5.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libkrb5.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libk5crypto.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libcom_err.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libkrb5support.a  /usr/lib/x86_64-linux-gnu/libresolv.so  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/librtmp.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libz.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libssl.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libcrypto.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libcurl-d.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libidn2.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libunistring.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libldap.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/liblber.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libgnutls.a  -latomic  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libhogweed.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libgmp.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libnettle.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libtasn1.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libnghttp2.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libpsl.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libgsasl.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libgssapi_krb5.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libkrb5.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libk5crypto.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libcom_err.a  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libkrb5support.a  /usr/lib/x86_64-linux-gnu/libresolv.so  /mnt/vcpkg-ci/installed/x64-linux/debug/lib/librtmp.a  -ldl && :
/usr/bin/ld: /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libcurl-d.a(httpsrr.c.o): in function `httpsrr_opt':
/mnt/vcpkg-ci/b/curl/src/c-8_18_0-1-b73d951667.clean/lib/httpsrr.c:165:(.text+0xa6f): undefined reference to `ares_dns_rr_get_opt'

This is the infamous CMake-breaks-link-library-order-for-traditional-linker. libcares.a listed before libcurl-d.a.

@dg0yt
Copy link
Contributor Author

dg0yt commented Dec 10, 2025

find_package(Threads)
find_package(Boost COMPONENTS system REQUIRED)
find_package(CURL REQUIRED)
find_package(TgBot CONFIG REQUIRED)
add_executable(main main.cpp)
target_compile_definitions(main PRIVATE HAVE_CURL)
target_link_libraries(main PRIVATE TgBot::TgBot)

Only linking TgBot::TgBot. Why doesn't TgBot bring its dependencies?

@dg0yt
Copy link
Contributor Author

dg0yt commented Dec 10, 2025

Why doesn't TgBot bring its dependencies?

A: Upstream links using the cmake variables (expecting filepaths), not the cmake targets.

@dg0yt
Copy link
Contributor Author

dg0yt commented Dec 10, 2025

This is the infamous CMake-breaks-link-library-order-for-traditional-linker. libcares.a listed before libcurl-d.a.

This the result of CURL_LIBRARIES listing curl lib filepaths, than c-ares imported target.
In the past we used unroll imported targets as much as possible, so that downstreams relying on CURL_LIBRARIES would not need find_dependency(CURL).

Now that the CURL config package has been around for so long, I tend to simply follow upstream and let CURL_LIBRARIES just be CURL::libcurl if we cannot unroll imported targets easily.

message(WARNING "CURL_LIBRARIES list at least one target. This will not work for use cases where targets are not resolved.")
endif()
# leave CURL_LIBRARIES as set by upstream (imported target)
message(WARNING "Cannot easily unroll CURL_LIBRARIES (\"${CURL_LIBRARIES}\") to filepaths. Exported CMake config must use \"find_dependency(CURL)\".")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this warning could be moved into a watch() action for read access. Then it is only emitted when the variable is actually read, not when a project uses the target directly.

@dg0yt dg0yt changed the title [curl] WIP [curl] WIP for 8.18.0 Dec 11, 2025
@dg0yt
Copy link
Contributor Author

dg0yt commented Dec 29, 2025

Using CURL_LIBRARIES. Calling find_dependency(CURL)?

  • aliyun-oss-cpp-sdk:x64-linux failed with BUILD_FAILED.
  • aws-sdk-cpp:x64-linux failed with BUILD_FAILED.
  • azure-c-shared-utility:x64-linux failed with BUILD_FAILED.
  • kubernetes:x64-linux failed with BUILD_FAILED. [kubernetes] Test and fix cmake config #49149
  • launch-darkly-server:x64-linux failed with BUILD_FAILED.
  • libmediainfo:x64-linux failed with BUILD_FAILED. [libmediainfo] Update, revise #49114
  • netcdf-c:x64-linux failed with BUILD_FAILED.
  • openscap:x64-linux failed with BUILD_FAILED. No CMake config.
  • ppconsul:x64-linux failed with BUILD_FAILED. [ppconsul] Update, revise #49161
  • tgbot-cpp:x64-linux failed with BUILD_FAILED.
  • vcpkg-ci-curl:x64-linux failed with BUILD_FAILED.
  • wxwidgets:x64-linux failed with BUILD_FAILED.

Cascaded from a dependency which uses CURL_LIBRARIES. Check again after dealing with first list.

  • cmake-user:x64-linux cascaded, but it is required to pass.
  • vcpkg-ci-gdal:x64-linux cascaded, but it is required to pass.
  • vcpkg-ci-itk:x64-linux cascaded, but it is required to pass.
  • vcpkg-ci-mathgl:x64-linux cascaded, but it is required to pass.
  • vcpkg-ci-opencv:x64-linux cascaded, but it is required to pass.
  • vcpkg-ci-paraview:x64-linux cascaded, but it is required to pass.
  • vcpkg-ci-wxwidgets:x64-linux cascaded, but it is required to pass.

@dg0yt dg0yt changed the title [curl] WIP for 8.18.0 [curl] Update to 8.18.0 Jan 7, 2026
@dg0yt dg0yt marked this pull request as ready for review January 8, 2026 16:40
@dg0yt dg0yt closed this Jan 8, 2026
@dg0yt dg0yt reopened this Jan 8, 2026
@vicroms vicroms merged commit 70b941a into microsoft:master Jan 8, 2026
18 checks passed
@dg0yt dg0yt deleted the curl-8.18 branch January 9, 2026 04:37
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

Successfully merging this pull request may close these issues.

3 participants