-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmake: lib order fixes for picky linkers (e.g. binutils ld
)
#16182
Closed
Conversation
This file contains 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
This comment was marked as resolved.
This comment was marked as resolved.
ld
ld
ld
)
ae8ce20
to
25ebdb3
Compare
This issue was never addressed in cmake so far. curl-for-win worked thanks to the `--start-group` workaround used there. The accurate solution is to either pass what's necessary multiple times, or arrange the libs in an order that make it work by default, without duplications. Only binutils ld is affected. llvm's lld and other linkers are not known to be so picky. ``` x86_64-w64-mingw32-ld: 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: libressl/lib/libcrypto.a(bss_sock.c.obj):bss_sock.c:(.text$sock_free[sock_free]+0x30): undefined reference to `__imp_shutdown' x86_64-w64-mingw32-ld: 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: libressl/lib/libcrypto.a(gcm128.c.obj):gcm128.c:(.text$CRYPTO_gcm128_init[CRYPTO_gcm128_init]+0x98): undefined reference to `__imp_ntohl' x86_64-w64-mingw32-ld: libressl/lib/libcrypto.a(gcm128.c.obj):gcm128.c:(.text$CRYPTO_gcm128_setiv[CRYPTO_gcm128_setiv]+0x1f1): undefined reference to `__imp_ntohl' x86_64-w64-mingw32-ld: libressl/lib/libcrypto.a(gcm128.c.obj):gcm128.c:(.text$CRYPTO_gcm128_setiv[CRYPTO_gcm128_setiv]+0x228): undefined reference to `__imp_ntohl' x86_64-w64-mingw32-ld: libressl/lib/libcrypto.a(gcm128.c.obj):gcm128.c:(.text$CRYPTO_gcm128_setiv[CRYPTO_gcm128_setiv]+0x24f): undefined reference to `__imp_ntohl' x86_64-w64-mingw32-ld: libressl/lib/libcrypto.a(gcm128.c.obj):gcm128.c:(.text$CRYPTO_gcm128_encrypt[CRYPTO_gcm128_encrypt]+0x98): more undefined references to `__imp_ntohl' follow ```
``` /usr/lib/gcc-cross/aarch64-linux-gnu/12/../../../../aarch64-linux-gnu/bin/ld: /home/runner/work/curl/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: /home/runner/work/curl/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: /home/runner/work/curl/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_' ``` https://github.com/curl/curl/actions/runs/13157270420/job/36717189086?pr=16182#step:3:5285
``` /usr/bin/x86_64-w64-mingw32-ld: /home/runner/work/curl/curl/libpsl/_x64-win-ucrt/usr/lib/libpsl.a(psl.o):(.text$psl_is_cookie_domain_acceptable+0xef): undefined reference to `__imp_WSAStringToAddressW' ``` https://github.com/curl/curl/actions/runs/13157579253/job/36718144881?pr=16182#step:3:5354
This reverts commit 457e251.
To help catching these issues.
Use noh3 to save CI time.
``` /usr/bin/i686-w64-mingw32-ld: /home/runner/work/curl/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: /home/runner/work/curl/curl/libssh/_x86-win-ucrt-libressl/usr/lib/libssh.a(connect.c.obj):(.text$ssh_connect_host_nonblocking+0x18a): undefined reference to `WspiapiFreeAddrInfo@4' /usr/bin/i686-w64-mingw32-ld: /home/runner/work/curl/curl/libssh/_x86-win-ucrt-libressl/usr/lib/libssh.a(connect.c.obj):(.text$ssh_connect_host_nonblocking+0x23e): undefined reference to `WspiapiGetAddrInfo@16' /usr/bin/i686-w64-mingw32-ld: /home/runner/work/curl/curl/libssh/_x86-win-ucrt-libressl/usr/lib/libssh.a(connect.c.obj):(.text$ssh_connect_host_nonblocking+0x29d): undefined reference to `WspiapiFreeAddrInfo@4' /usr/bin/i686-w64-mingw32-ld: /home/runner/work/curl/curl/libssh/_x86-win-ucrt-libressl/usr/lib/libssh.a(connect.c.obj):(.text$ssh_connect_host_nonblocking+0x388): undefined reference to `WspiapiFreeAddrInfo@4' /usr/bin/i686-w64-mingw32-ld: /home/runner/work/curl/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: /home/runner/work/curl/curl/libssh/_x86-win-ucrt-libressl/usr/lib/libssh.a(connect.c.obj):(.text$ssh_connect_host_nonblocking+0x4a8): undefined reference to `WspiapiFreeAddrInfo@4' /usr/bin/i686-w64-mingw32-ld: /home/runner/work/curl/curl/libssh/_x86-win-ucrt-libressl/usr/lib/libssh.a(connect.c.obj):(.text$ssh_connect_host_nonblocking+0x568): undefined reference to `WspiapiFreeAddrInfo@4' /usr/bin/i686-w64-mingw32-ld: /home/runner/work/curl/curl/libssh/_x86-win-ucrt-libressl/usr/lib/libssh.a(connect.c.obj):(.text$ssh_connect_host_nonblocking+0x57c): undefined reference to `gai_strerrorA' /usr/bin/i686-w64-mingw32-ld: /home/runner/work/curl/curl/libssh/_x86-win-ucrt-libressl/usr/lib/libssh.a(connect.c.obj):(.text$ssh_connect_host_nonblocking+0x5c4): undefined reference to `WspiapiFreeAddrInfo@4' ``` https://github.com/curl/curl/actions/runs/13163986294/job/36739557888?pr=16182#step:3:5127 ``` /usr/bin/i686-w64-mingw32-ld: /home/runner/work/curl/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: /home/runner/work/curl/curl/libssh/_x86-win-ucrt-libressl/usr/lib/libssh.a(kex.c.obj):(.text$ssh_client_select_hostkeys+0x151): undefined reference to `FIPS_mode' /usr/bin/i686-w64-mingw32-ld: /home/runner/work/curl/curl/libssh/_x86-win-ucrt-libressl/usr/lib/libssh.a(kex.c.obj):(.text$ssh_set_client_kex+0x90): undefined reference to `FIPS_mode' /usr/bin/i686-w64-mingw32-ld: /home/runner/work/curl/curl/libssh/_x86-win-ucrt-libressl/usr/lib/libssh.a(kex.c.obj):(.text$ssh_add_to_default_algos+0x24): undefined reference to `FIPS_mode' /usr/bin/i686-w64-mingw32-ld: /home/runner/work/curl/curl/libssh/_x86-win-ucrt-libressl/usr/lib/libssh.a(kex.c.obj):(.text$ssh_remove_from_default_algos+0x22): undefined reference to `FIPS_mode' /usr/bin/i686-w64-mingw32-ld: /home/runner/work/curl/curl/libssh/_x86-win-ucrt-libressl/usr/lib/libssh.a(kex.c.obj):(.text$ssh_remove_from_default_algos+0x59): more undefined references to `FIPS_mode' follow /usr/bin/i686-w64-mingw32-ld: /home/runner/work/curl/curl/libssh/_x86-win-ucrt-libressl/usr/lib/libssh.a(options.c.obj):(.text$ssh_options_set_algo+0x2f): undefined reference to `FIPS_mode' /usr/bin/i686-w64-mingw32-ld: /home/runner/work/curl/curl/libssh/_x86-win-ucrt-libressl/usr/lib/libssh.a(options.c.obj):(.text$ssh_options_set+0x16a): undefined reference to `FIPS_mode' /usr/bin/i686-w64-mingw32-ld: /home/runner/work/curl/curl/libssh/_x86-win-ucrt-libressl/usr/lib/libssh.a(options.c.obj):(.text$ssh_options_set+0x942): undefined reference to `FIPS_mode' /usr/bin/i686-w64-mingw32-ld: /home/runner/work/curl/curl/libssh/_x86-win-ucrt-libressl/usr/lib/libssh.a(options.c.obj):(.text$ssh_options_get+0xab): undefined reference to `FIPS_mode' /usr/bin/i686-w64-mingw32-ld: /home/runner/work/curl/curl/libssh/_x86-win-ucrt-libressl/usr/lib/libssh.a(options.c.obj):(.text$ssh_options_get+0xd3): undefined reference to `FIPS_mode' /usr/bin/i686-w64-mingw32-ld: /home/runner/work/curl/curl/libssh/_x86-win-ucrt-libressl/usr/lib/libssh.a(options.c.obj):(.text$ssh_options_get+0xff): more undefined references to `FIPS_mode' follow ``` https://github.com/curl/curl/actions/runs/13163986294/job/36739557888?pr=16182#step:3:5121
71c670a
to
abf6b27
Compare
vszakats
added a commit
to curl/curl-for-win
that referenced
this pull request
Feb 6, 2025
…[ci skip] Please report if any untested build combinations fail due to wrong lib order. curl/curl@e0443a7 curl/curl#16182
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.
This issue was not addressed with CMake builds so far. curl-for-win
worked thanks to its
-Wl,--start-group
workaround. It affectsbinutils
ld
linking statically. Shared linking and llvm'slld
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
andbcrypt
last, and move SSH libs first due to their dependence on crypto
backends and zlib compression.
Also:
options than the default to extend build coverage too:
libssh
,zlib-ng
, 32-bit.Examples of issues fixed:
Windows LibreSSL, libpsl vs. ws2_32:
Ref: https://github.com/curl/curl/actions/runs/13157579253/job/36718144881?pr=16182#step:3:5354
Linux libssh2 vs. zlib:
Ref: https://github.com/curl/curl/actions/runs/13157270420/job/36717189086?pr=16182#step:3:5285
Windows libssh vs. ws2_32 and LibreSSL:
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
Another, related, goal is to sync lib order with autotools.
A notable difference is that autotools prepends detected libs, while cmake this was so far done for a couple of libs only.
Order of dependency detection is also not synced between autotools and cmake.
This PR doesn't want to address these, but may be a step towards.