{"author":"Viktor Szakats","author_email":"commit@vsz.me","author_time":1738757872,"commit_time":1738881304,"committer":"Viktor Szakats","committer_email":"commit@vsz.me","hash":"e0443a76c4fdd7f3b0dc413f1f7f28171b359e15","message":"cmake: lib order fixes for picky linkers (e.g. binutils `ld`)\n\nThis issue was not addressed with CMake builds so far. curl-for-win\nworked thanks to its `-Wl,--start-group` workaround. It affects\nbinutils `ld` linking statically. Shared linking and llvm's `lld`\ndoesn't need strict lib order, and are not affected.\n\nThe solution is to pass libs in dependency order, with least dependent\n(e.g. system) libs last. In case of cyclic dependency, may pass libs\ntwice.\n\nFix most issues by moving Windows system libs `ws2_32` and `bcrypt`\nlast, and move SSH libs first due to their dependence on crypto\nbackends and zlib compression.\n\nAlso:\n- modify an existing Linux curl-for-win job to use gcc.\n- add a specific Windows gcc job to test this. Make it use different\n  options than the default to extend build coverage too: `libssh`,\n  `zlib-ng`, 32-bit.\n- prefer CMake imported targets for OpenSSL and ZLIB.\n\nExamples of issues fixed:\n\nWindows LibreSSL, libpsl vs. ws2_32:\n```\nx86_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'\nx86_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'\nx86_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'\n```\nRef: https://github.com/curl/curl/actions/runs/13157579253/job/36718144881?pr=16182#step:3:5354\n\nLinux libssh2 vs. zlib:\n```\n/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':\n(.text.comp_method_zlib_dtor+0x8c): undefined reference to `deflateEnd'\n/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':\n(.text.comp_method_zlib_comp+0x50): undefined reference to `deflate'\n/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':\n(.text.comp_method_zlib_init+0x8c): undefined reference to `deflateInit_'\n```\nRef: https://github.com/curl/curl/actions/runs/13157270420/job/36717189086?pr=16182#step:3:5285\n\nWindows libssh vs. ws2_32 and LibreSSL:\n```\n/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'\n/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'\n/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'\n/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'\n```\nRef: https://github.com/curl/curl/actions/runs/13163986294/job/36739557888?pr=16182#step:3:5127\nRef: https://github.com/curl/curl/actions/runs/13163986294/job/36739557888?pr=16182#step:3:5121\n\nCloses #16182\n","parents":["aa3e4c1db52bc30cecb31482626518004e9d427f"],"tree_hash":"48d235b97955bcf0e1cd7ea6d5184923b4495f32"}