mirror of
https://github.com/curl/curl.git
synced 2026-07-26 13:37:21 +03:00
cmake: lib order fixes for picky linkers (e.g. binutils ld)
This issue was not addressed with CMake builds so far. curl-for-win worked thanks to its `-Wl,--start-group` workaround. It affects binutils `ld` linking statically. Shared linking and llvm's `lld` doesn't need strict lib order, and are not affected. The solution is to pass libs in dependency order, with least dependent (e.g. system) libs last. In case of cyclic dependency, may pass libs twice. Fix most issues by moving Windows system libs `ws2_32` and `bcrypt` last, and move SSH libs first due to their dependence on crypto backends and zlib compression. Also: - modify an existing Linux curl-for-win job to use gcc. - add a specific Windows gcc job to test this. Make it use different options than the default to extend build coverage too: `libssh`, `zlib-ng`, 32-bit. - prefer CMake imported targets for OpenSSL and ZLIB. Examples of issues fixed: Windows LibreSSL, libpsl vs. ws2_32: ``` x86_64-w64-mingw32-ld: curl/libressl/lib/libcrypto.a(bss_sock.c.obj):bss_sock.c:(.text$sock_ctrl[sock_ctrl]+0x59): undefined reference to `__imp_shutdown' x86_64-w64-mingw32-ld: curl/libressl/lib/libcrypto.a(gcm128.c.obj):gcm128.c:(.text$CRYPTO_gcm128_init[CRYPTO_gcm128_init]+0x65): undefined reference to `__imp_ntohl' x86_64-w64-mingw32-ld: curl/libpsl/_x64-win-ucrt/usr/lib/libpsl.a(psl.o):(.text$psl_is_cookie_domain_acceptable+0xef): undefined reference to `__imp_WSAStringToAddressW' ``` Ref: https://github.com/curl/curl/actions/runs/13157579253/job/36718144881?pr=16182#step:3:5354 Linux libssh2 vs. zlib: ``` /usr/lib/gcc-cross/aarch64-linux-gnu/12/../../../../aarch64-linux-gnu/bin/ld: curl/libssh2/_a64-linux-gnu-libressl/usr/lib/libssh2.a(unity_0_c.c.o): in function `comp_method_zlib_dtor': (.text.comp_method_zlib_dtor+0x8c): undefined reference to `deflateEnd' /usr/lib/gcc-cross/aarch64-linux-gnu/12/../../../../aarch64-linux-gnu/bin/ld: curl/libssh2/_a64-linux-gnu-libressl/usr/lib/libssh2.a(unity_0_c.c.o): in function `comp_method_zlib_comp': (.text.comp_method_zlib_comp+0x50): undefined reference to `deflate' /usr/lib/gcc-cross/aarch64-linux-gnu/12/../../../../aarch64-linux-gnu/bin/ld: curl/libssh2/_a64-linux-gnu-libressl/usr/lib/libssh2.a(unity_0_c.c.o): in function `comp_method_zlib_init': (.text.comp_method_zlib_init+0x8c): undefined reference to `deflateInit_' ``` Ref: https://github.com/curl/curl/actions/runs/13157270420/job/36717189086?pr=16182#step:3:5285 Windows libssh vs. ws2_32 and LibreSSL: ``` /usr/bin/i686-w64-mingw32-ld: curl/libssh/_x86-win-ucrt-libressl/usr/lib/libssh.a(connect.c.obj):(.text$ssh_connect_host_nonblocking+0x92): undefined reference to `WspiapiGetAddrInfo@16' /usr/bin/i686-w64-mingw32-ld: curl/libssh/_x86-win-ucrt-libressl/usr/lib/libssh.a(connect.c.obj):(.text$ssh_connect_host_nonblocking+0x3d9): undefined reference to `gai_strerrorA' /usr/bin/i686-w64-mingw32-ld: curl/libssh/_x86-win-ucrt-libressl/usr/lib/libssh.a(kex.c.obj):(.text$ssh_client_select_hostkeys+0xd2): undefined reference to `FIPS_mode' /usr/bin/i686-w64-mingw32-ld: curl/libssh/_x86-win-ucrt-libressl/usr/lib/libssh.a(options.c.obj):(.text$ssh_options_set+0x942): undefined reference to `FIPS_mode' ``` Ref: https://github.com/curl/curl/actions/runs/13163986294/job/36739557888?pr=16182#step:3:5127 Ref: https://github.com/curl/curl/actions/runs/13163986294/job/36739557888?pr=16182#step:3:5121 Closes #16182
This commit is contained in:
parent
aa3e4c1db5
commit
e0443a76c4
2 changed files with 33 additions and 11 deletions
28
.github/workflows/curl-for-win.yml
vendored
28
.github/workflows/curl-for-win.yml
vendored
|
|
@ -42,7 +42,7 @@ env:
|
|||
CW_NOPKG: '1'
|
||||
|
||||
jobs:
|
||||
linux-glibc-llvm:
|
||||
linux-glibc-gcc:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
|
|
@ -55,7 +55,7 @@ jobs:
|
|||
run: |
|
||||
git clone --depth 1 https://github.com/curl/curl-for-win
|
||||
mv curl-for-win/* .
|
||||
export CW_CONFIG='-main-werror-linux-a64-x64'
|
||||
export CW_CONFIG='-main-werror-linux-a64-x64-gcc-nolibgroup'
|
||||
export CW_REVISION='${{ github.sha }}'
|
||||
DOCKER_IMAGE='debian:bookworm-slim'
|
||||
export DOCKER_CONTENT_TRUST=1
|
||||
|
|
@ -137,3 +137,27 @@ jobs:
|
|||
'^(CW_|GITHUB_)') \
|
||||
"${DOCKER_IMAGE}" \
|
||||
sh -c ./_ci-linux-debian.sh
|
||||
|
||||
win-gcc-libssh-zlibng-x86:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
path: 'curl'
|
||||
fetch-depth: 8
|
||||
- name: 'build'
|
||||
run: |
|
||||
git clone --depth 1 https://github.com/curl/curl-for-win
|
||||
mv curl-for-win/* .
|
||||
export CW_CONFIG='-main-werror-win-x86-gcc-nolibgroup-libssh1-zlibng'
|
||||
export CW_REVISION='${{ github.sha }}'
|
||||
. ./_versions.sh
|
||||
docker trust inspect --pretty "${DOCKER_IMAGE}"
|
||||
time docker pull "${DOCKER_IMAGE}"
|
||||
docker images --digests
|
||||
time docker run --volume "$(pwd):$(pwd)" --workdir "$(pwd)" \
|
||||
--env-file <(env | grep -a -E \
|
||||
'^(CW_|GITHUB_)') \
|
||||
"${DOCKER_IMAGE}" \
|
||||
sh -c ./_ci-linux-debian.sh
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue