Skip to content

Conversation

vszakats
Copy link
Member

@vszakats vszakats commented Jul 13, 2025

LIBSSH2_PC_LIBS_PRIVATE ends up in Libs.private in libssh2.pc.

The order and duplication may be significant for linkers that rely on
strict lib order and unable to resolve symbols without it. Such linker
is binutils ld. De-duplication can break it.

As of now there is no purposeful duplication in libs in libssh2, thus
the de-duplication most likely did not affect actual builds.

It was originally introduced to avoid a repeat -lz (with
a zlib-enabled OpenSSL or wolfSSL build.) To keep this feature, this
patch makes sure to only delete duplicates that are next to each other.

Follow-up to 6464301 #1131

And the libs listed in `Libs.private` in `libssh2.pc` with it.

The order and repetition might be significant for linkers that rely on
strict lib order and unable to resolve symbols without it. Such linker
is binutils `ld`.

This also syncs this snippet with curl.

De-duplication was originally introduced to avoid a repeat `-lz`. It
means after this patch a repeat `-lz` is back again. (with
a zlib-enabled OpenSSL or wolfSSL build.)

One safe way to de-duplicate would be to remove dupes when they appear
right next to each other. This is an excercise for another PR, because
cmake doesn't have such built-in function. Meanwhile, such duplicates
don't cause harm, and only make the output less clean-looking and
introduce potential differences between `libssh2.pc` generated by cmake
and autotools. (those aren't necessary identical anyway, yet.)

Follow-up to 6464301 libssh2#1131
@vszakats vszakats added the build label Jul 13, 2025
@vszakats vszakats changed the title cmake: do not de-duplicate LIBSSH2_PC_LIBS_PRIVATE cmake: de-duplicate LIBSSH2_PC_LIBS_PRIVATE more carefully Jul 13, 2025
@vszakats vszakats marked this pull request as draft July 13, 2025 17:09
@vszakats vszakats marked this pull request as ready for review July 13, 2025 21:56
@vszakats vszakats closed this in e1da7b2 Jul 13, 2025
@vszakats vszakats deleted the cm-dupe branch July 13, 2025 23:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant