Repository navigation
cmake: reposition ws2_32 to make binutils ld work again - #827
Merged
Merged
Conversation
vszakats
force-pushed
the
cmake-binutils-ld-refix
branch
from
March 8, 2023 16:06
cfe660a to
d01d387
Compare
This restores socket libs to their pre-regression positions. Without this, `ld` doesn't find `ws2_32` symbols when referenced from TLS libs. Regression from 31fb886
vszakats
force-pushed
the
cmake-binutils-ld-refix
branch
from
March 8, 2023 17:52
d01d387 to
2616ebb
Compare
ws2_32 to make binutils ld work again
agreppin
pushed a commit
to agreppin/libssh2
that referenced
this pull request
Jul 14, 2024
This restores socket libs to their pre-regression positions. Without this, `ld` doesn't find `ws2_32` symbols when referenced from TLS libs. Regression from 31fb886
vszakats
added a commit
to vszakats/libssh2
that referenced
this pull request
Jul 13, 2025
The `libssh2.pc` generator logic automatically adds `-lws2_32` while parsing `LIBSSH2_LIBS`, which contains this lib already. Then discard the duplicate. This change introduces a change in the position of `ws2_32` within the lib list. This order might in cases by significant, but: - libssh2 no longer links against `libssl`, which was the library also referencing `ws2_32` and breaking picky binutils `ld` linker when not passed in strict dependency order. Ref: c84745e libssh2#1128 - since switching to INTERFACE targets, cmake messes up the lib order anyway, adding `OpenSSL:Crypto` last, instead of `ws2_32`. This did not seem to cause an issue so far. Ref: df0563a libssh2#1535 Ref: 33b6d5f libssh2#827 Ref: 31fb886 libssh2#811
vszakats
added a commit
that referenced
this pull request
Jul 13, 2025
The `libssh2.pc` generator logic automatically adds `-lws2_32` while parsing `LIBSSH2_LIBS`, which contains this lib already. Then discard the duplicate. This patch introduces a change in the position of `ws2_32` within the lib list advertised via `libssh2.pc` for static builds. This order might in cases by significant, but: - libssh2 no longer links against `libssl`, which was the library also referencing `ws2_32` and breaking picky binutils `ld` linker when not passed in strict dependency order. Ref: c84745e #1128 - since switching to INTERFACE targets, cmake messes up the lib order anyway, adding `OpenSSL:Crypto` last, instead of `ws2_32`. This did not seem to cause an issue so far. Ref: df0563a #1535 For these reasons it seems unlikely this position change could break Windows OpenSSL static gcc/ld builds relying on `libssh2.pc` for their lib list. It least no more than it was before this patch. Turns out these theories don't stand in practice and the order is broken possibly by introducing INTERFACE targets, with or without this patch. `libcrypto` (tested with LibreSSL) is in fact depending on `ws2_32`, and the `bcrypt` dependency is also causing breakage with picky binutils ld. I may try addressing it in a separate PR. Ref: 33b6d5f #827 Ref: 31fb886 #811 Closes #1619
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.
This restores socket libs to their pre-regression positions.
Without this,
lddoesn't findws2_32symbols when referenced from TLS libs.Regression from 31fb886