cmake: add native pkg-config detection for mbedTLS, MSH3, Quiche, Rustls, wolfSSL - #15193
Closed
vszakats wants to merge 21 commits into
Closed
cmake: add native pkg-config detection for mbedTLS, MSH3, Quiche, Rustls, wolfSSL#15193vszakats wants to merge 21 commits into
pkg-config detection for mbedTLS, MSH3, Quiche, Rustls, wolfSSL#15193vszakats wants to merge 21 commits into
Conversation
vszakats
force-pushed
the
cm-find-pkgconf-2
branch
3 times, most recently
from
October 8, 2024 11:02
65c7bf5 to
0151919
Compare
pkg-config detection for mbedTLS, MSH3, Quiche, Rustlspkg-config detection for mbedTLS, MSH3, Quiche, Rustls, wolfSSL
Contributor
|
Analysis of PR #15193 at 15287516: Test 2055 failed, which has NOT been flaky recently, so there could be a real issue in the PR. Generated by Testclutch |
vszakats
force-pushed
the
cm-find-pkgconf-2
branch
from
October 8, 2024 21:49
bae93ef to
56e9795
Compare
vszakats
added a commit
to vszakats/curl
that referenced
this pull request
Oct 8, 2024
vszakats
added a commit
that referenced
this pull request
Oct 9, 2024
- update mbedTLS repo URL. - switch local mbedTLS build to use CMake, and Ninja. CMake build is required to create and install mbedTLS `pkg-config` files. (as of v3.6.1) `-DCMAKE_POSITION_INDEPENDENT_CODE=ON` required to avoid this error when linking mbedtls to `libcurl.so`: ``` /usr/bin/ld: /home/runner/mbedtls/lib/libmbedcrypto.a(cipher.c.o): warning: relocation against `mbedtls_cipher_base_lookup_table' in read-only section `.text' /usr/bin/ld: /home/runner/mbedtls/lib/libmbedtls.a(ssl_tls.c.o): relocation R_X86_64_PC32 against symbol `mbedtls_x509_crt_profile_suiteb' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: final link failed: bad value ``` Ref: https://github.com/curl/curl/actions/runs/11245069259/job/31264386723#step:40:43 - make local mbedTLS build 10x smaller by omitting programs and tests. - GHA/linux: fix cmake warning by adding `-B .` option. - GHA/linux: add build-only cmake job for packaged mbedTLS (2.x). - fix compiler warning when building with mbedTLS 2.x: ``` /home/runner/work/curl/curl/lib/vtls/mbedtls.c:344:1: error: ‘mbed_cipher_suite_get_str’ defined but not used [-Werror=unused-function] 344 | mbed_cipher_suite_get_str(uint16_t id, char *buf, size_t buf_size, | ^~~~~~~~~~~~~~~~~~~~~~~~~ ``` Ref: https://github.com/curl/curl/actions/runs/11244999065/job/31264168295#step:40:50 Also in preparation for #15193 Closes #15208
vszakats
force-pushed
the
cm-find-pkgconf-2
branch
2 times, most recently
from
October 9, 2024 01:21
c25512c to
ca9b053
Compare
Member
Author
|
Field notes:
|
vszakats
force-pushed
the
cm-find-pkgconf-2
branch
from
October 9, 2024 18:09
08309f1 to
c431d80
Compare
use `CMAKE_LIBRARY_PATH_FLAG` https://cmake.org/cmake/help/v3.6/variable/CMAKE_LIBRARY_PATH_FLAG.html
mbedtls.pc only has references to its dependencies when building statically.
mbedtls.pc
```
prefix=/usr/local/Cellar/mbedtls/3.6.1
includedir=${prefix}/include
libdir=${prefix}/lib
Name: Mbed TLS
Description: Mbed TLS is a C library that implements cryptographic primitives, X.509 certificate manipulation and the SSL/TLS and DTLS protocols. Its small code footprint makes it suitable for embedded systems.
URL: https://www.trustedfirmware.org/projects/mbed-tls/
Version: 3.6.1
Requires.private: mbedcrypto mbedx509
Cflags: -I"${includedir}"
Libs: -L"${libdir}" -lmbedtls
```
mbedx509.pc
```
prefix=/usr/local/Cellar/mbedtls/3.6.1
includedir=${prefix}/include
libdir=${prefix}/lib
Name: Mbed TLS
Description: Mbed TLS is a C library that implements cryptographic primitives, X.509 certificate manipulation and the SSL/TLS and DTLS protocols. Its small code footprint makes it suitable for embedded systems.
URL: https://www.trustedfirmware.org/projects/mbed-tls/
Version: 3.6.1
Requires.private: mbedcrypto
Cflags: -I"${includedir}"
Libs: -L"${libdir}" -lmbedx509
```
mbedcrypto.pc
```
prefix=/usr/local/Cellar/mbedtls/3.6.1
includedir=${prefix}/include
libdir=${prefix}/lib
Name: Mbed TLS
Description: Mbed TLS is a C library that implements cryptographic primitives, X.509 certificate manipulation and the SSL/TLS and DTLS protocols. Its small code footprint makes it suitable for embedded systems.
URL: https://www.trustedfirmware.org/projects/mbed-tls/
Version: 3.6.1
Cflags: -I"${includedir}"
Libs: -L"${libdir}" -lmbedcrypto
```
vszakats
added a commit
that referenced
this pull request
Oct 12, 2024
- limit `SIZEOF_SA_FAMILY_T` detection to non-Windows. - make sure `sys/socket.h` exists before detecting `SIZEOF_SA_FAMILY_T`. - limit `mach_absolute_time()` detection to `APPLE`. Drop from Windows pre-cache. - skip `HAVE_LIBSOCKET` detection for Windows, drop pre-cached value. - drop redundant pre-cached `HAVE_LIBZ` for Windows. - `curl_required_libpaths()`: stop accepting multiple arguments. To prepare for `CMAKE_REQUIRED_LINK_DIRECTORIES` support. Follow-up to 7bab201 #15193 - GSS: fix recent rebase mistakes: - fix variable name. - do not add a header twice. Follow-up to 91d451b #15157 - GSS: quote a variable. Closes #15271
This was referenced Oct 12, 2024
2 tasks
vszakats
added a commit
to vszakats/curl
that referenced
this pull request
Oct 25, 2024
`pkg_check_modules()` seems to leave `<PACKAGE>_VERSION` defined with an empty value, if the package is not found. When the package is also not found in the fallback branch, `find_package_handle_standard_args()` logs and error message. In this message it includes the bogus empty value as: `(found version "")`: ``` Could NOT find Libssh2 (missing: LIBSSH2_INCLUDE_DIR LIBSSH2_LIBRARY) (found version "") ``` https://github.com/curl/curl/actions/runs/11509727553/job/32040378958?pr=15408#step:31:99 Clear the version number to avoid the confusion: ``` Could NOT find Libssh2 (missing: LIBSSH2_INCLUDE_DIR LIBSSH2_LIBRARY) ``` https://github.com/curl/curl/actions/runs/11510022503/job/32041149129?pr=15408#step:31:99 Seen with CMake v3.30.5 Follow-up to 7bab201 curl#15193
vszakats
added a commit
that referenced
this pull request
Oct 25, 2024
`pkg_check_modules()` seems to leave `<PACKAGE>_VERSION` defined with an empty value, if the package is not found. When the package is also not found in the fallback branch, `find_package_handle_standard_args()` logs and error message. In this message it includes the bogus empty value as: `(found version "")`: ``` Could NOT find Libssh2 (missing: LIBSSH2_INCLUDE_DIR LIBSSH2_LIBRARY) (found version "") ``` https://github.com/curl/curl/actions/runs/11509727553/job/32040378958?pr=15408#step:31:99 Clear the version number to avoid the confusion: ``` Could NOT find Libssh2 (missing: LIBSSH2_INCLUDE_DIR LIBSSH2_LIBRARY) ``` https://github.com/curl/curl/actions/runs/11510022503/job/32041149129?pr=15408#step:31:99 Seen with CMake v3.30.5. Follow-up to 7bab201 #15193 Closes #15409
vszakats
added a commit
that referenced
this pull request
Dec 16, 2024
Use `CMAKE_REQUIRED_LINK_DIRECTORIES` with CMake 3.31.0 and upper, in local macro `curl_required_libpaths()`. Kitware/CMake@9e95bd4 https://gitlab.kitware.com/cmake/cmake/-/commit/9e95bd49f278cd2a05caf21fd624a41e4bfaba60 https://gitlab.kitware.com/cmake/cmake/-/merge_requests/9795 https://cmake.org/cmake/help/v3.31/module/CheckSymbolExists.html Tested OK with cmake 3.31.0-rc1. Follow-up to 01a8157 #15271 Follow-up to 7bab201 #15193 Closes #15280
vszakats
added a commit
that referenced
this pull request
Dec 17, 2024
brotli, c-ares, libpsl, libssh2, nghttp2, nghttp3, ntgcp2, zstd. Also: Add workaround for CMake reporting successful libssh2 detection, but leaving the header directory empty, and causing `libssh2.h` not found while compiling. It happens when `pkgconf` is not detecting libssh2 dependency libcrypto in Homebrew after `brew unlink openssl` (as in GHA/macos). The workaround is to require a non-empty header directory to consider the detection successful. This workaround may need to be tweaked and/or applied to other Find modules. Follow-up to 7bab201 #15193 Closes #15408
pps83
pushed a commit
to pps83/curl
that referenced
this pull request
Apr 26, 2025
- update mbedTLS repo URL. - switch local mbedTLS build to use CMake, and Ninja. CMake build is required to create and install mbedTLS `pkg-config` files. (as of v3.6.1) `-DCMAKE_POSITION_INDEPENDENT_CODE=ON` required to avoid this error when linking mbedtls to `libcurl.so`: ``` /usr/bin/ld: /home/runner/mbedtls/lib/libmbedcrypto.a(cipher.c.o): warning: relocation against `mbedtls_cipher_base_lookup_table' in read-only section `.text' /usr/bin/ld: /home/runner/mbedtls/lib/libmbedtls.a(ssl_tls.c.o): relocation R_X86_64_PC32 against symbol `mbedtls_x509_crt_profile_suiteb' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: final link failed: bad value ``` Ref: https://github.com/curl/curl/actions/runs/11245069259/job/31264386723#step:40:43 - make local mbedTLS build 10x smaller by omitting programs and tests. - GHA/linux: fix cmake warning by adding `-B .` option. - GHA/linux: add build-only cmake job for packaged mbedTLS (2.x). - fix compiler warning when building with mbedTLS 2.x: ``` /home/runner/work/curl/curl/lib/vtls/mbedtls.c:344:1: error: ‘mbed_cipher_suite_get_str’ defined but not used [-Werror=unused-function] 344 | mbed_cipher_suite_get_str(uint16_t id, char *buf, size_t buf_size, | ^~~~~~~~~~~~~~~~~~~~~~~~~ ``` Ref: https://github.com/curl/curl/actions/runs/11244999065/job/31264168295#step:40:50 Also in preparation for curl#15193 Closes curl#15208
pps83
pushed a commit
to pps83/curl
that referenced
this pull request
Apr 26, 2025
…ustls, wolfSSL
Also:
- detect and add required system libraries for Rustls on macOS and
non-Windows.
- add Linux CMake jobs for the touched dependencies.
Caveats:
- MSH3 generates a broken `libmsh3.pc`, so needs manual config.
Upstream PR: nibanks/msh3#225
- Rustls `.pc` file missing, so needs manual config.
An internal change worthy of mention is that we are using the lib path
and name information returned by `pkg-config` as-is. Meaning the libname
doesn't include the full path, like it's usual with native cmake
detection. The path comes separately and needs to be rolled separately.
For this we add it to targets via `link_directories()`. We also keep tab
of them in `CURL_LIBDIRS` and use that in `libcurl.pc`. Feature checks
also need to receive these paths. CMake doesn't offer
a `CMAKE_REQUIRED_*` variable for this purpose, only
a `CMAKE_REQUIRED_LINK_OPTIONS` accepting raw linker flags. Add a macro
to convert a list of paths to linker options to solve it. wolfSSL
requires this for now.
Closes curl#15193
pps83
pushed a commit
to pps83/curl
that referenced
this pull request
Apr 26, 2025
- limit `SIZEOF_SA_FAMILY_T` detection to non-Windows. - make sure `sys/socket.h` exists before detecting `SIZEOF_SA_FAMILY_T`. - limit `mach_absolute_time()` detection to `APPLE`. Drop from Windows pre-cache. - skip `HAVE_LIBSOCKET` detection for Windows, drop pre-cached value. - drop redundant pre-cached `HAVE_LIBZ` for Windows. - `curl_required_libpaths()`: stop accepting multiple arguments. To prepare for `CMAKE_REQUIRED_LINK_DIRECTORIES` support. Follow-up to 7bab201 curl#15193 - GSS: fix recent rebase mistakes: - fix variable name. - do not add a header twice. Follow-up to 91d451b curl#15157 - GSS: quote a variable. Closes curl#15271
pps83
pushed a commit
to pps83/curl
that referenced
this pull request
Apr 26, 2025
Add a build-only cmake job with system mbedTLS package and `pkg-config` enabled. Ubuntu 24.04 comes with mbedTLS 2.28.8 which supports `pkg-config`. Follow-up to 7bab201 curl#15193 Closes curl#15286
pps83
pushed a commit
to pps83/curl
that referenced
this pull request
Apr 26, 2025
To sync with other similar variables and hide them from cmake UIs. Follow-up to 7bab201 curl#15193 Closes curl#15407
pps83
pushed a commit
to pps83/curl
that referenced
this pull request
Apr 26, 2025
`pkg_check_modules()` seems to leave `<PACKAGE>_VERSION` defined with an empty value, if the package is not found. When the package is also not found in the fallback branch, `find_package_handle_standard_args()` logs and error message. In this message it includes the bogus empty value as: `(found version "")`: ``` Could NOT find Libssh2 (missing: LIBSSH2_INCLUDE_DIR LIBSSH2_LIBRARY) (found version "") ``` https://github.com/curl/curl/actions/runs/11509727553/job/32040378958?pr=15408#step:31:99 Clear the version number to avoid the confusion: ``` Could NOT find Libssh2 (missing: LIBSSH2_INCLUDE_DIR LIBSSH2_LIBRARY) ``` https://github.com/curl/curl/actions/runs/11510022503/job/32041149129?pr=15408#step:31:99 Seen with CMake v3.30.5. Follow-up to 7bab201 curl#15193 Closes curl#15409
pps83
pushed a commit
to pps83/curl
that referenced
this pull request
Apr 26, 2025
Use `CMAKE_REQUIRED_LINK_DIRECTORIES` with CMake 3.31.0 and upper, in local macro `curl_required_libpaths()`. Kitware/CMake@9e95bd4 https://gitlab.kitware.com/cmake/cmake/-/commit/9e95bd49f278cd2a05caf21fd624a41e4bfaba60 https://gitlab.kitware.com/cmake/cmake/-/merge_requests/9795 https://cmake.org/cmake/help/v3.31/module/CheckSymbolExists.html Tested OK with cmake 3.31.0-rc1. Follow-up to 01a8157 curl#15271 Follow-up to 7bab201 curl#15193 Closes curl#15280
pps83
pushed a commit
to pps83/curl
that referenced
this pull request
Apr 26, 2025
brotli, c-ares, libpsl, libssh2, nghttp2, nghttp3, ntgcp2, zstd. Also: Add workaround for CMake reporting successful libssh2 detection, but leaving the header directory empty, and causing `libssh2.h` not found while compiling. It happens when `pkgconf` is not detecting libssh2 dependency libcrypto in Homebrew after `brew unlink openssl` (as in GHA/macos). The workaround is to require a non-empty header directory to consider the detection successful. This workaround may need to be tweaked and/or applied to other Find modules. Follow-up to 7bab201 curl#15193 Closes curl#15408
pps83
pushed a commit
to pps83/curl
that referenced
this pull request
Apr 26, 2025
- add `iphlpapi` library for c-ares. Ref: curl/curl-for-win@082d98b - fix to not add system libs if the dependency was not found. librtmp, Rustls, wolfSSL Follow-up to 421e592 curl#15832 Follow-up to 7bab201 curl#15193 Closes curl#16089
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Also:
non-Windows.
Caveats:
libmsh3.pc, so needs manual config.Upstream PR: fix generated
libmsh3.pcfile nibanks/msh3#225.pcfile missing, so needs manual config.An internal change worthy of mention is that we are using the lib path
and name information returned by
pkg-configas-is. Meaning the libnamedoesn't include the full path, like it's usual with native cmake
detection. The path comes separately and needs to be rolled separately.
For this we add it to targets via
link_directories(). We also keep tabof them in
CURL_LIBDIRSand use that inlibcurl.pc. Feature checksalso need to receive these paths. CMake doesn't offer
a
CMAKE_REQUIRED_*variable for this purpose, onlya
CMAKE_REQUIRED_LINK_OPTIONSaccepting raw linker flags. Add a macroto convert a list of paths to linker options to solve it. wolfSSL
requires this for now.
w/o whitespace: https://github.com/curl/curl/pull/15193/files?w=1