Merged
Conversation
Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
After migrating libssh to vcpkg, it started linking statically against the binary. With dynamic linkage, DllMain function were already calling ssh_init() [1] so everything was working as intended. This no longer the case since DllMain is not being invoked in static linkage. Linux and macOS is still fine since there's the `libssh_constructor`[2] func marked with __attribute__((constructor)), which works with gcc/clang but not with MSVC. This patch ensures that the library is initialized before first use. [1]: https://github.com/canonical/libssh/blob/f23d1454e50d0dbb314edd9bf4227ab72303484b/src/init.c#L257 [2]: https://github.com/canonical/libssh/blob/f23d1454e50d0dbb314edd9bf4227ab72303484b/src/init.c#L59 Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4812 +/- ##
=======================================
Coverage 87.54% 87.54%
=======================================
Files 258 258
Lines 14155 14155
=======================================
Hits 12391 12391
Misses 1764 1764 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
tobe2098
approved these changes
Apr 11, 2026
tobe2098
approved these changes
Apr 11, 2026
tobe2098
added a commit
that referenced
this pull request
Apr 11, 2026
After migrating libssh to vcpkg, it started linking statically against the binary. With dynamic linkage, the DllMain function was [already calling ssh_init()](https://github.com/canonical/libssh/blob/f23d1454e50d0dbb314edd9bf4227ab72303484b/src/init.c#L257) so everything was working as intended. This is no longer the case since DllMain is not being invoked in static linkage. Linux and macOS are still fine since there's the [libssh_constructor](https://github.com/canonical/libssh/blob/f23d1454e50d0dbb314edd9bf4227ab72303484b/src/init.c#L59) func marked with `__attribute__((constructor))`, which works with gcc/clang but not with MSVC. This PR ensures that the library is initialized before first use for both the daemon and the CLI. <!-- Please include a summary of the changes and the motivation behind them. --> - What does this PR do? Ensures libssh is initialized. - Why is this change needed? Fix broken SSH in Windows. MULTI-2535
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.
After migrating libssh to vcpkg, it started linking statically against the binary. With dynamic linkage, the DllMain function was already calling ssh_init() so everything was working as intended. This is no longer the case since DllMain is not being invoked in static linkage. Linux and macOS are still fine since there's the libssh_constructor func marked with
__attribute__((constructor)), which works with gcc/clang but not with MSVC.This PR ensures that the library is initialized before first use for both the daemon and the CLI.
Ensures libssh is initialized.
Fix broken SSH in Windows.
MULTI-2535