camke: include libssh2 in Requires.private in the PC file#7215
Open
carlosmn wants to merge 1 commit intolibgit2:mainfrom
Open
camke: include libssh2 in Requires.private in the PC file#7215carlosmn wants to merge 1 commit intolibgit2:mainfrom
Requires.private in the PC file#7215carlosmn wants to merge 1 commit intolibgit2:mainfrom
Conversation
We need this in order for `pkg-config` to be able to tell what you should link
against when building libgit2 statically. We do include libssh2 in
`Libs.private` but not in `Requires.private`. The difference is a bit subtle but
has become important.
You can call `pkg-config --libs --static ${build}/libgit2.pc` and it will give
you what is in the Libs line, and also what the packages from the Requires field
have in theirs. This is what e.g. `rugged` does and it has been working until
recently. An update to openssl to require zstd now means that using `--libs
--static` returns `-lzstd` as well as many others. This means that those who
want to link using that command now need to have the development packages for
zstd installed, which should not be necessary as libgit2 itself doesn't want to
use anything from it.
A better command to use here seems to be `pkg-config --libs --static --pure
${build}/libgit2.pc`. The manpage and help output are not very precise but what
this does is limit the list of dependencies to a single layer, which is what we
want as we would only want to link statically against libgit2 and not the rest
of the libraries.
But trying to do so breaks building with libssh2 as it's included in the Libs
field rather than the Requires, so that command excludes any linking to libssh2.
Put libssh2 in the `Requires.private` field so we correctly express we need to
link to it when linking statically.
This is unfortunately an imperfect fix as now, if we did not find libssh2 via
pkg-config but rather via CMake's `find_package`, the combination of `--static
--pure` does not take `Libs.private` into account. However we only support this
as an edge case and we expect `pkg-config` to be available for the rest of our
dependencies.
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.
We need this in order for
pkg-configto be able to tell what you should link against when building libgit2 statically. We do include libssh2 inLibs.privatebut not inRequires.private. The difference is a bit subtle but has become important.You can call
pkg-config --libs --static ${build}/libgit2.pcand it will give you what is in the Libs line, and also what the packages from the Requires field have in theirs. This is what e.g.ruggeddoes and it has been working until recently. An update to openssl to require zstd now means that using--libs --staticreturns-lzstdas well as many others. This means that those who want to link using that command now need to have the development packages for zstd installed, which should not be necessary as libgit2 itself doesn't want to use anything from it.A better command to use here seems to be
pkg-config --libs --static --pure ${build}/libgit2.pc. The manpage and help output are not very precise but what this does is limit the list of dependencies to a single layer, which is what we want as we would only want to link statically against libgit2 and not the rest of the libraries.But trying to do so breaks building with libssh2 as it's included in the Libs field rather than the Requires, so that command excludes any linking to libssh2.
Put libssh2 in the
Requires.privatefield so we correctly express we need to link to it when linking statically.This is unfortunately an imperfect fix as now, if we did not find libssh2 via pkg-config but rather via CMake's
find_package, the combination of--static --puredoes not takeLibs.privateinto account. However we only support this as an edge case and we expectpkg-configto be available for the rest of our dependencies.I found this via libgit2/rugged#986 and libgit2/rugged#990 but I can't fix it via
--static --pureuntil libgit2 is more accurate about this.I'm not sure about the
-lrtwe have there wrt to this (or in general). The resultinglibgit2.soandlibgit2_testsdon't end up linked against them and removing that line seems to make no difference to the build so maybe it's all part of libc now and a GNU userland doesn't need it?