You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
curl-config --libs returns incorrect value on cygwin #5793
Last night I updated my cygwin installation and (among others) my curl packages were updated.
This lead to my git build failing while linking git-imap-send.exe as the linker could not find the
libraries: -lnghttp2, -lidn2, -lssh, -lpsl, -lldap, -llber, -lbrotlidec, -lbrotlidec (yes it was noted twice).
I had a quick look at the curl git repo, and this seems to be due to a recent commit 98e5904
(libcurl.pc: Merge Libs.private into Libs for static-only builds, 2020-05-11).
The git Makefile allows me to override the value returned by curl-config, by setting 'CURL_LDFLAGS=-lcurl'
in my config.mak, so I have simple solution for now - just thought you should know. ;-)
On 07/08/2020 09:08, Daniel Stenberg wrote:
Did you build libcurl static only?
Heh, I didn't build libcurl at all. I am simply a user of the libcurl and
libcurl-devel packages on cygwin. The '/var/log/setup.log' file shows that
the cygwin update removed the 'old' 7.66.0-1 packages and installed the
'new' 7.71.1-1 packages. (and _didn't_ install any dependent libraries).
$ cygcheck -cd | grep curl
curl 7.71.1-1
curl-debuginfo 7.71.1-1
libcurl-devel 7.71.1-1
libcurl-doc 7.71.1-1
libcurl4 7.71.1-1
$
[note: I added the curl-debuginfo package today]
The libcurl4 package provides (just) the libcurl dll file, whereas the
libcurl-devel package provides, among other things, the 'import library'
used by the linker (ie. '/usr/lib/libcurl.dll.a'):
$ cygcheck -l libcurl4
/usr/bin/cygcurl-4.dll
$ cygcheck -l libcurl-devel
/usr/bin/curl-config
/usr/include/curl/curl.h
/usr/include/curl/curlver.h
/usr/include/curl/easy.h
/usr/include/curl/mprintf.h
/usr/include/curl/multi.h
/usr/include/curl/stdcheaders.h
/usr/include/curl/system.h
/usr/include/curl/typecheck-gcc.h
/usr/include/curl/urlapi.h
/usr/lib/libcurl.dll.a
/usr/lib/pkgconfig/libcurl.pc
/usr/share/aclocal/libcurl.m4
/usr/share/man/man1/curl-config.1.gz
$
[note: I am assuming that the 7.66.0-1 version of curl-config just returned
'-lcurl' when invoking 'curl-config --libs']
As I said, I can build git without issue by setting 'CURL_LDFLAGS=-lcurl'
in the config.mak file to override the 'curl-config --libs' output, so
we can see:
$ ldd git-imap-send.exe
ntdll.dll => /cygdrive/c/WINDOWS/SYSTEM32/ntdll.dll (0x7ffa7db70000)
KERNEL32.DLL => /cygdrive/c/WINDOWS/System32/KERNEL32.DLL (0x7ffa7d18000
0)
KERNELBASE.dll => /cygdrive/c/WINDOWS/System32/KERNELBASE.dll (0x7ffa7b4
70000)
cygwin1.dll => /usr/bin/cygwin1.dll (0x180040000)
cygcrypto-1.1.dll => /usr/bin/cygcrypto-1.1.dll (0x41c650000)
cygcurl-4.dll => /usr/bin/cygcurl-4.dll (0x5d28e0000)
cygiconv-2.dll => /usr/bin/cygiconv-2.dll (0x3f6900000)
cygintl-8.dll => /usr/bin/cygintl-8.dll (0x5ee2d0000)
cygssl-1.1.dll => /usr/bin/cygssl-1.1.dll (0x5b4450000)
cygz.dll => /usr/bin/cygz.dll (0x597fd0000)
cygbrotlidec-1.dll => /usr/bin/cygbrotlidec-1.dll (0x5deea0000)
cygidn2-0.dll => /usr/bin/cygidn2-0.dll (0x5b8850000)
cyglber-2-4-2.dll => /usr/bin/cyglber-2-4-2.dll (0x3d9860000)
cygnghttp2-14.dll => /usr/bin/cygnghttp2-14.dll (0x5b76c0000)
cygpsl-5.dll => /usr/bin/cygpsl-5.dll (0x5b51c0000)
cygssh-4.dll => /usr/bin/cygssh-4.dll (0x5b4580000)
cygldap-2-4-2.dll => /usr/bin/cygldap-2-4-2.dll (0x5b7fa0000)
cygbrotlicommon-1.dll => /usr/bin/cygbrotlicommon-1.dll (0x5deec0000)
cygunistring-2.dll => /usr/bin/cygunistring-2.dll (0xcd0000)
cyggcc_s-seh-1.dll => /usr/bin/cyggcc_s-seh-1.dll (0x50caa0000)
cygunistring-2.dll => /usr/bin/cygunistring-2.dll (0x5b3b20000)
cyggssapi_krb5-2.dll => /usr/bin/cyggssapi_krb5-2.dll (0x5f6cf0000)
cygsasl2-3.dll => /usr/bin/cygsasl2-3.dll (0x5b4c40000)
cygk5crypto-3.dll => /usr/bin/cygk5crypto-3.dll (0x41bf60000)
cygkrb5-3.dll => /usr/bin/cygkrb5-3.dll (0x4cc8c0000)
cygkrb5support-0.dll => /usr/bin/cygkrb5support-0.dll (0x433a90000)
cygcom_err-2.dll => /usr/bin/cygcom_err-2.dll (0x40f9e0000)
$
... that the dependent dll's are linked, via the cygcurl-4.dll. Indeed, if
we look at the 'import tables' from the '.idata' section of the dll, we
find:
$ objdump -x /usr/bin/cygcurl-4.dll | grep 'DLL Name'
DLL Name: cygbrotlidec-1.dll
DLL Name: cygcrypto-1.1.dll
DLL Name: cygwin1.dll
DLL Name: cygidn2-0.dll
DLL Name: cyglber-2-4-2.dll
DLL Name: cygldap-2-4-2.dll
DLL Name: cygnghttp2-14.dll
DLL Name: cygpsl-5.dll
DLL Name: cygssh-4.dll
DLL Name: cygssl-1.1.dll
DLL Name: cygz.dll
DLL Name: KERNEL32.dll
$
Indeed, all of the dependent dll's are available in /usr/bin. If we take
the libnghttp2 as an example, we see that the library package is installed,
but not the associated '-devel' package. (so the .dll is present, but the
'import library' needed by the linker isn't).
$ cygcheck -cd | grep nghttp2
libnghttp2_14 1.37.0-1
$ cygcheck -l libnghttp2_14
/usr/bin/cygnghttp2-14.dll
$ cygcheck -p libnghttp2-devel
Found 5 matches for libnghttp2-devel
libnghttp2-devel-1.23.1-1 - libnghttp2-devel: HTTP/2 C library
libnghttp2-devel-1.31.0-1 - libnghttp2-devel: HTTP/2 C library
libnghttp2-devel-1.37.0-1 - libnghttp2-devel: HTTP/2 C library
nghttp2-1.23.1-1 - nghttp2: HTTP/2 utilities
nghttp2-1.31.0-1 - nghttp2: HTTP/2 utilities
$ cygcheck -p usr/lib/libnghttp2.dll.a
Found 3 matches for usr/lib/libnghttp2.dll.a
libnghttp2-devel-1.23.1-1 - libnghttp2-devel: HTTP/2 C library
libnghttp2-devel-1.31.0-1 - libnghttp2-devel: HTTP/2 C library
libnghttp2-devel-1.37.0-1 - libnghttp2-devel: HTTP/2 C library
$
[Note: the 'cygcheck -p' invocations search the cygwin.com site, rather
than the local disk.]
So, you could say that installing the 'libcurl-devel' package should
cause all of the dependent library '-devel' packages to be installed
as well. That would (probably) work. But why? Doing so would only
cause the linker to search several import libraries which will _never_
supply any symbols! ;-D
Hmm, I suppose it could be argued that this is a cygwin-specific packaging
issue (no, I am not convinced) and should be addressed by the cygwin
package maintainer. (maybe the cygwin list should be my next port of call).
What do you think?
Thanks!
ATB,
Ramsay Jones
I asked about static vs shared because the configure generated curl-config --libs should only return the full list like that if not built shared, and AFAIK shared builds are by default. For a shared build/lib (which is what you seem to be using) a single -lcurl is probably the correct thing as the rest will then be dynamically linked.
So yeah, it could be a cygwin-specific packaging issue or perhaps even a cygwin-specific configure issue in curl. I don't know.
@ramsay-jones pointed me at this issue; I'm the Cygwin maintainer for Git. This is indeed a Cygwin-specific packaging issue; it looks like the Curl maintainer mistakenly dropped a patch to the compile-time configuration that affects the linking behaviour.
Hmm, I think I would be more interested about the need for a
cygwin specific patch to the curl build system to make it work! ;-)
[Also, I think the cygwin maintainer of the libcurl package is
not convinced by the current patch].
However, if you think this issue is no longer serving a purpose (I guess
the cygwin maintainer can open a new issue if he has a patch he wants
to send upstream), please do close this issue.
Thanks!
ATB,
Ramsay Jones
I think I would be more interested about the need for a cygwin specific patch to the curl build system to make it work! ;-)
I would agree, but I don't see any strong desire to fix that. It seems the curl maintainers in cygwin has been doing their own patches on curl for a very long time without having tried to fix them directly upstream - in curl.
I'm the new Cygwin curl maintainer, and I would prefer to drop local patches if we can get appropriate changes made upstream wherever possible.
The local specific patch against an earlier curl release did not apply, and I did not notice any issues, so I released the package upgrade to the latest curl.
If we need to keep a local patch against curl/-config/.in I don't have a problem, but would prefer to discuss an approach and offer a patch/PR if desirable.
Often product maintainers have their own preferred approaches based on their deep knowledge and experience of the packages they maintain, and will come up with a more general approach than my narrow look at one issue would suggest.
It looks to me as if the generated curl-config --libs statements:
if test "Xyes" = "Xno" -o "Xyes" = "Xyes"; then
echo ${CURLLIBDIR}-lcurl -lnghttp2 -lidn2 -lssh -lpsl -lssl -lcrypto
-lldap -llber -lbrotlidec -lbrotlidec -lz
based on curl-config.in:
if test "X@ENABLE_SHARED@" = "Xno" -o "X@REQUIRE_LIB_DEPS@" = "Xyes"; then
echo ${CURLLIBDIR}-lcurl @LIBCURL_LIBS@
REQUIRE_LIB_DEPS should be no, derived from configure.ac:
if test "X$enable_shared" = "Xyes" -a "X$link_all_deplibs" = "Xno"
then
REQUIRE_LIB_DEPS=no
else
REQUIRE_LIB_DEPS=yes
fi
AC_SUBST(REQUIRE_LIB_DEPS)
AM_CONDITIONAL(USE_EXPLICIT_LIB_DEPS, test x$REQUIRE_LIB_DEPS = xyes)
but for Cygwin and a number of other platforms link_all_deplibs remains defaulted to unknown, so either that variable should be set in Cygwin configure to no, or that condition should perhaps be changed to:
if test "X$enable_shared" = "Xyes" -a "X$link_all_deplibs" != "Xyes"
Thanks! It feels a little risky as this might change a little too much for other platforms, but hey let's try this. See #5804 for what I take is your suggested fix?
This strikes me as a very fragile fix, likely to confuse anyone reading the code in the future, for two reasons.
The libtool manual says the following about link_all_deplibs: "Whether libtool must link a program against all its dependency libraries. Set to ‘yes’ or ‘no’. Default is ‘unknown’, which is a synonym for ‘yes’." But this patch treats 'unknown' as different from 'yes'.
Setting REQUIRE_LIB_DEPS to 'no' on Cygwin gives the impression that we don't need to specify all dependent libraries when building curl on Cygwin. [In fact we do need to do this, and libtool is smart enough to do it regardless of how REQUIRE_LIB_DEPS is defined.]
How about the following much simpler fix, which is essentially what's been done in the Cygwin build of curl for years, until the most recent build:
--- origsrc/curl-7.71.1/curl-config.in 2020-06-27 18:03:53.000000000 -0400
+++ src/curl-7.71.1/curl-config.in 2020-08-12 12:34:53.341934900 -0400
@@ -160,7 +160,7 @@ while test $# -gt 0; do
else
CURLLIBDIR=""
fi
if test "X@ENABLE_SHARED@" = "Xno" -o "X@REQUIRE_LIB_DEPS@" = "Xyes"; then
if test "X@ENABLE_SHARED@" = "Xno"; then
echo ${CURLLIBDIR}-lcurl @LIBCURL_LIBS@
else
echo ${CURLLIBDIR}-lcurl
This strikes me as a very fragile fix, likely to confuse anyone reading the code in the future, for two reasons.
The libtool manual says the following about link_all_deplibs: "Whether libtool must link a program against all its dependency libraries. Set to ‘yes’ or ‘no’. Default is ‘unknown’, which is a synonym for ‘yes’." But this patch treats 'unknown' as different from 'yes'.
I noticed that in the autoconf/libtool docs and thought that perhaps a better option might be to make changes or get changes made in m4/libtool.m4 to set link_all_deplibs=no like Linux in the LT_SHLIBS section.
Setting REQUIRE_LIB_DEPS to 'no' on Cygwin gives the impression that we don't need to specify all dependent libraries when building curl on Cygwin. [In fact we do need to do this, and libtool is smart enough to do it regardless of how REQUIRE_LIB_DEPS is defined.]
I understood the need for the patch was that Cygwin needs dynamically linked against libcurl only link_all_deplibs=no, but statically also needs linked against all the libcurl dependencies link_all_deplibs=yes, effectively the difference between libcurl.pcLibs list and Libs.private list, and that is what I understood to be the meaning of link_all_deplibs.
I did not need a patch because I was able to build both curl and git Cygwin packages, including the git programs where others had issues, with no changes to curl and gitcygport build control scripts in the Cygwin package sources, so was unable to reproduce the issues reported by others.
With a large number of Cygwin package-devel packages and dependencies installed, I understand my development configuration may be atypical, and as curl-config did not generate the expected output, thought consideration should be given to getting that issue fixed.
How about the following much simpler fix, which is essentially what's been done in the Cygwin build of curl for years, until the most recent build:
To include a patch or any code block, use Markdown verbatim code block quotes around content: three graves ``` on separate lines before and after the block. If you also name the language or source type immediately following the graves on the first line - in this case ```patch additional source highlighting may occur. e.g.
--- origsrc/curl-7.71.1/curl-config.in 2020-06-27 18:03:53.000000000 -0400+++ src/curl-7.71.1/curl-config.in 2020-08-12 12:34:53.341934900 -0400@@ -160,7 +160,7 @@ while test $# -gt 0; do
else
CURLLIBDIR=""
fi
- if test "X@ENABLE_SHARED@" = "Xno" -o "X@REQUIRE_LIB_DEPS@" = "Xyes"; then+ if test "X@ENABLE_SHARED@" = "Xno"; then
echo ${CURLLIBDIR}-lcurl @LIBCURL_LIBS@
else
echo ${CURLLIBDIR}-lcurl
While building curl itself, curl-config appears to be generated embedding static tests of the static values of REQUIRE_LIB_DEPS and link_all_deplibs which results in the incorrect output of which you complained: perhaps curl-config should not then be used in building other products.
Also while building git itself, curl-config may be invoked, causing the problems others have experienced, whereas I was unable to reproduce those issues, and git built and tested as expected.
Perhaps we need a better understanding of curl-config, its intent, outputs, and uses of those.
Also /while building |git| itself/, |curl-config| may be invoked, causing the problems others have experienced, whereas I was unable to reproduce those issues, and |git| built and tested as expected.
Brian, if you want to reproduce the git build failure, then all you
need to do is (after building curl) uninstall one or more of the
'-devel' packages of the dependent libraries.
For example, if you uninstall the 'libnghttp2-devel' package, that
will remove (among others) '/usr/lib/libnghttp2.dll.a' (or you could
simply move this file out of the way), so that the linker will not
be able to find it. (rinse and repeat for all the other libraries,
except for libz which git links to directly).
You will then be rewarded with something like the following message
from the linker:
LINK git-imap-send.exe
/usr/lib/gcc/x86_64-pc-cygwin/9.3.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lnghttp2
/usr/lib/gcc/x86_64-pc-cygwin/9.3.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lidn2
/usr/lib/gcc/x86_64-pc-cygwin/9.3.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lssh
/usr/lib/gcc/x86_64-pc-cygwin/9.3.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lpsl
/usr/lib/gcc/x86_64-pc-cygwin/9.3.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lldap
/usr/lib/gcc/x86_64-pc-cygwin/9.3.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -llber
/usr/lib/gcc/x86_64-pc-cygwin/9.3.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lbrotlidec
/usr/lib/gcc/x86_64-pc-cygwin/9.3.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lbrotlidec
collect2: error: ld returned 1 exit status
make: *** [Makefile:2467: git-imap-send.exe] Error 1
[Note: once again, -lbrotlidec is included _twice_ in 'curl-config --libs']
So, the build does not fail for you because you have all of the
'-devel' library packages installed. (although you will spend more
time in the linker).
Note, giving '-lnghttp2 -lidn2 -lssh -lpsl -lssl -lcrypto -lldap -llber
-lbrotlidec -lbrotlidec' to the linker is pretty much the definition
of a waste of time: none of these libraries will resolve a single symbol
during the link! ;-)
HTH.
ATB,
Ramsay Jones
Thank you!
That is likely the link I was missing.
I expected it may have been because I have built a number of (non-Cygwin) packages for my own interest and use and have currently 124 ...-devel packages installed.
I may consider using apt-cyg remove/-s install ...-devel to clean up my environment before regression tests like this.
My question would be why packages appear to be using curl-config for anything other than info, which seems to be its function, perhaps to document the version of libcurl linked, features supported, and perhaps other configuration options or arguments, like the gcc info in /proc/version?
There is a perfectly good /lib/pkgconfig/libcurl.pc file available for use with pkgconf/-config --libs as is usual in builds, which gives the correct expected results for both dynamic and static linking!
So now I am unsure exactly where the fix effort should really be directed - Cygwin, curl, git, libtool, autoconf?
The previous Cygwin patch used to kludge around the problem for Cygwin and we can continue to do so, but there should be an architected approach so that vanilla git, curl, and Cygwin can work together without a new kludge every release or few.
That patch originated from applying a Windows patch to the Cygwin environment, which is as POSIX (and related standards), and Linux compatible, and un-Windows-like, as can be under Windows, and perhaps I should take a look at what that changed, and see how to back out the effects for Cygwin builds, affecting only Windows builds.
That way I can leave aside the issue of whether git, libtool, and autoconf should be using curl-config rather than pkgconf/-config to use libcurl in builds, and any discussions or changes about that.
I've now had a chance to digest this. I agree with what @kbrow1i is proposing, and hence #5808. link_all_deplibs in this context is only relevant when building curl itself and curl-config is only used when building against curl. I don't know why they were ever linked in this way. I recall being confused by this very line when I made the earlier change.
My own distribution is Gentoo and link_all_deplibs is surprisingly unknown here too. curl-config --libs also returns the full set here. Perhaps this affects more distributions than you think. I wasn't hit by the issue though because Gentoo effectively always has the -devel files installed anyway.
More broadly speaking, I think *-config scripts are a horrible kludge that should be phased out. pkg-config does a far better job of handling these things, especially in exotic setups, such as when cross-compiling. Gentoo developers make a concerted effort to remove usage of these scripts in upstream projects where it is feasible.
I'm even happier to agree with #5808 with you @chewi and @bagder agreeing with @kbrow1i as it will resolve @me-and and @ramsay-jones build issues.
Cygwin maintainers @me-and and @kbrow1i - do you think I should build a curl-7.71.1-2 upgrade package ASAP with a local Cygwin curl#5808 patch, or wait for the next official curl release including the patch?
pkg-config does a far better job of handling these things
Agreed. curl-config is older and was added to curl in April 2001 with inspiration from some other project that I now forget which it was. I don't know when pkg-config actually became a real "thing" but curl has supported it since December 2004.
Patch #5808 disables support for static libraries and I believe that now prevents the curl tests from being built or run - alternative suggestions which support a patch to allow both dynamic and static library builds?
Making all in libtest
make[2]: Entering directory '/mnt/c/Users/bwi/src/cygwin/curl/curl-7.71.1-2.x86_64/build/tests/libtest'
CCLD libstubgss.la
libtool: error: can't build x86_64-pc-cygwin shared library unless -no-undefined is specified
make[2]: *** [Makefile:2547: libstubgss.la] Error 1
make[2]: Target 'all' not remade because of errors.
make[2]: Leaving directory '/mnt/c/Users/bwi/src/cygwin/curl/curl-7.71.1-2.x86_64/build/tests/libtest'
Making all in unit
make[2]: Entering directory '/mnt/c/Users/bwi/src/cygwin/curl/curl-7.71.1-2.x86_64/build/tests/unit'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/mnt/c/Users/bwi/src/cygwin/curl/curl-7.71.1-2.x86_64/build/tests/unit'
make[2]: Entering directory '/mnt/c/Users/bwi/src/cygwin/curl/curl-7.71.1-2.x86_64/build/tests'
make[2]: Nothing to be done for 'all-am'.
make[2]: Leaving directory '/mnt/c/Users/bwi/src/cygwin/curl/curl-7.71.1-2.x86_64/build/tests'
make[1]: *** [Makefile:513: all-recursive] Error 1
make[1]: Target 'all' not remade because of errors.
make[1]: Target 'quiet-test' not remade because of errors.
make[1]: Leaving directory '/mnt/c/Users/bwi/src/cygwin/curl/curl-7.71.1-2.x86_64/build/tests'
make: *** [Makefile:1437: test] Error 2
No, it doesn't. cygport does that by default, and it's standard Cygwin practice.
Making all in libtest
make[2]: Entering directory '/mnt/c/Users/bwi/src/cygwin/curl/curl-7.71.1-2.x86_64/build/tests/libtest'
CCLD libstubgss.la
libtool: error: can't build x86_64-pc-cygwin shared library unless -no-undefined is specified
This no longer has anything to do with the bug report. Let's move the discussion to the cygwin-apps list and I'll answer there. I can't do it immediately, but I'll get to it in a couple hours. If you're impatient, search the cygport manual for '-no-undefined'.
Thanks for Cygwin changes included in latest release - our downstream package maintainers and consumers are happy that curl and libcurl build right from download, and downstreams like Cygwin git, and consumers like the OP @ramsay-jones , can now use either your release sources or the Cygwin packaged sources.
It would be good if @ramsay-jones could confirm and close?
Excellent news @BrianInglis. Thanks for the great cooperation and do let us know if there are other cygwin nits existing already now or appearing in the future that we should better fix.
On 24/08/2020 21:49, Brian Inglis wrote:
Thanks for Cygwin changes included in latest release - our downstream package maintainers and consumers are happy that curl and libcurl build right from download, and downstreams like Cygwin git, and consumers like the OP @ramsay-jones <https://github.com/ramsay-jones> , can now use either your release sources or the Cygwin packaged sources.
It would be good if @ramsay-jones <https://github.com/ramsay-jones> could confirm and close?
Ah, sorry, I didn't know you were waiting for me! :(
However, I thought that the issue had already been closed - I saw
a message in the UI that it would be closed by a given commit in
so many hours and I can no longer see the issue, so ...
I don't use the github UI unless I absolutely have to; so, I am
not very familiar with it. I only created a user to enable me
to log an issue (a different project) and this is only the second
time I have used github. (Luckily, firefox had remembered my
password!).
[Although I don't like the github UI, at least the issue workflow
is more convenient to use than subscribing to a very busy mailing
list, just to report an issue.]
I saw Adam confirm that the issue was resolved by the last two
cygwin packages (which I also installed) on the cygwin mailing
list. So, I am happy to also confirm that the issue is resolved.
Thanks!
ATB,
Ramsay Jones
Activity
bagder commentedon Aug 7, 2020
Did you build libcurl static only?
ramsay-jones commentedon Aug 7, 2020
bagder commentedon Aug 8, 2020
I asked about static vs shared because the configure generated
curl-config --libsshould only return the full list like that if not built shared, and AFAIK shared builds are by default. For a shared build/lib (which is what you seem to be using) a single-lcurlis probably the correct thing as the rest will then be dynamically linked.So yeah, it could be a cygwin-specific packaging issue or perhaps even a cygwin-specific configure issue in curl. I don't know.
me-and commentedon Aug 10, 2020
@ramsay-jones pointed me at this issue; I'm the Cygwin maintainer for Git. This is indeed a Cygwin-specific packaging issue; it looks like the Curl maintainer mistakenly dropped a patch to the compile-time configuration that affects the linking behaviour.
I'm expecting this to be fixed in Cygwin shortly; a new patch was proposed at https://cygwin.com/pipermail/cygwin/2020-August/245820.html earlier today.
bagder commentedon Aug 10, 2020
Thanks that input @me-and. I presume we can then consider this case closed @ramsay-jones ?
ramsay-jones commentedon Aug 11, 2020
bagder commentedon Aug 11, 2020
I would agree, but I don't see any strong desire to fix that. It seems the curl maintainers in cygwin has been doing their own patches on curl for a very long time without having tried to fix them directly upstream - in curl.
BrianInglis commentedon Aug 11, 2020
I'm the new Cygwin
curlmaintainer, and I would prefer to drop local patches if we can get appropriate changes made upstream wherever possible.The local specific patch against an earlier
curlrelease did not apply, and I did not notice any issues, so I released the package upgrade to the latestcurl.If we need to keep a local patch against
curl/-config/.inI don't have a problem, but would prefer to discuss an approach and offer a patch/PR if desirable.Often product maintainers have their own preferred approaches based on their deep knowledge and experience of the packages they maintain, and will come up with a more general approach than my narrow look at one issue would suggest.
It looks to me as if the generated
curl-config --libsstatements:based on
curl-config.in:REQUIRE_LIB_DEPSshould beno, derived fromconfigure.ac:but for Cygwin and a number of other platforms
link_all_deplibsremains defaulted tounknown, so either that variable should be set in Cygwinconfiguretono, or that condition should perhaps be changed to:configure: adjust the REQUIRE_LIB_DEPS logic
bagder commentedon Aug 12, 2020
Thanks! It feels a little risky as this might change a little too much for other platforms, but hey let's try this. See #5804 for what I take is your suggested fix?
kbrow1i commentedon Aug 12, 2020
This strikes me as a very fragile fix, likely to confuse anyone reading the code in the future, for two reasons.
The libtool manual says the following about link_all_deplibs: "Whether libtool must link a program against all its dependency libraries. Set to ‘yes’ or ‘no’. Default is ‘unknown’, which is a synonym for ‘yes’." But this patch treats 'unknown' as different from 'yes'.
Setting REQUIRE_LIB_DEPS to 'no' on Cygwin gives the impression that we don't need to specify all dependent libraries when building curl on Cygwin. [In fact we do need to do this, and libtool is smart enough to do it regardless of how REQUIRE_LIB_DEPS is defined.]
How about the following much simpler fix, which is essentially what's been done in the Cygwin build of curl for years, until the most recent build:
--- origsrc/curl-7.71.1/curl-config.in 2020-06-27 18:03:53.000000000 -0400
+++ src/curl-7.71.1/curl-config.in 2020-08-12 12:34:53.341934900 -0400
@@ -160,7 +160,7 @@ while test $# -gt 0; do
else
CURLLIBDIR=""
fi
kbrow1i commentedon Aug 12, 2020
Whoops! I see the patch got mangled. Let me try attaching it instead.
curl-7.71.1-1.src.txt
BrianInglis commentedon Aug 13, 2020
I noticed that in the autoconf/libtool docs and thought that perhaps a better option might be to make changes or get changes made in
m4/libtool.m4to setlink_all_deplibs=nolike Linux in theLT_SHLIBSsection.I understood the need for the patch was that Cygwin needs dynamically linked against
libcurlonlylink_all_deplibs=no, but statically also needs linked against all thelibcurldependencieslink_all_deplibs=yes, effectively the difference betweenlibcurl.pcLibslist andLibs.privatelist, and that is what I understood to be the meaning oflink_all_deplibs.I did not need a patch because I was able to build both
curlandgitCygwin packages, including thegitprograms where others had issues, with no changes tocurlandgitcygportbuild control scripts in the Cygwin package sources, so was unable to reproduce the issues reported by others.With a large number of Cygwin package
-develpackages and dependencies installed, I understand my development configuration may be atypical, and ascurl-configdid not generate the expected output, thought consideration should be given to getting that issue fixed.To include a patch or any code block, use Markdown verbatim code block quotes around content: three graves ``` on separate lines before and after the block. If you also name the language or source type immediately following the graves on the first line - in this case ```patch additional source highlighting may occur. e.g.
bagder commentedon Aug 13, 2020
@chewi, you brought this change of this line in #5373, do you have concerns or other thoughts on this proposed patch?
4 remaining items
BrianInglis commentedon Aug 13, 2020
While building
curlitself,curl-configappears to be generated embedding static tests of the static values ofREQUIRE_LIB_DEPSandlink_all_deplibswhich results in the incorrect output of which you complained: perhapscurl-configshould not then be used in building other products.Also while building
gititself,curl-configmay be invoked, causing the problems others have experienced, whereas I was unable to reproduce those issues, andgitbuilt and tested as expected.Perhaps we need a better understanding of
curl-config, its intent, outputs, and uses of those.ramsay-jones commentedon Aug 13, 2020
BrianInglis commentedon Aug 13, 2020
Thank you!
That is likely the link I was missing.
I expected it may have been because I have built a number of (non-Cygwin) packages for my own interest and use and have currently 124 ...
-develpackages installed.I may consider using
apt-cyg remove/-s install ...-develto clean up my environment before regression tests like this.My question would be why packages appear to be using
curl-configfor anything other than info, which seems to be its function, perhaps to document the version of libcurl linked, features supported, and perhaps other configuration options or arguments, like the gcc info in /proc/version?There is a perfectly good
/lib/pkgconfig/libcurl.pcfile available for use withpkgconf/-config --libsas is usual in builds, which gives the correct expected results for both dynamic and static linking!So now I am unsure exactly where the fix effort should really be directed - Cygwin,
curl,git,libtool,autoconf?The previous Cygwin patch used to kludge around the problem for Cygwin and we can continue to do so, but there should be an architected approach so that vanilla
git,curl, and Cygwin can work together without a new kludge every release or few.That patch originated from applying a Windows patch to the Cygwin environment, which is as POSIX (and related standards), and Linux compatible, and un-Windows-like, as can be under Windows, and perhaps I should take a look at what that changed, and see how to back out the effects for Cygwin builds, affecting only Windows builds.
That way I can leave aside the issue of whether
git,libtool, andautoconfshould be usingcurl-configrather thanpkgconf/-configto uselibcurlin builds, and any discussions or changes about that.chewi commentedon Aug 13, 2020
/me waves to @me-and. 👋
I've now had a chance to digest this. I agree with what @kbrow1i is proposing, and hence #5808.
link_all_deplibsin this context is only relevant when building curl itself andcurl-configis only used when building against curl. I don't know why they were ever linked in this way. I recall being confused by this very line when I made the earlier change.My own distribution is Gentoo and
link_all_deplibsis surprisinglyunknownhere too.curl-config --libsalso returns the full set here. Perhaps this affects more distributions than you think. I wasn't hit by the issue though because Gentoo effectively always has the-develfiles installed anyway.More broadly speaking, I think
*-configscripts are a horrible kludge that should be phased out. pkg-config does a far better job of handling these things, especially in exotic setups, such as when cross-compiling. Gentoo developers make a concerted effort to remove usage of these scripts in upstream projects where it is feasible.BrianInglis commentedon Aug 14, 2020
I'm even happier to agree with #5808 with you @chewi and @bagder agreeing with @kbrow1i as it will resolve @me-and and @ramsay-jones build issues.
Cygwin maintainers @me-and and @kbrow1i - do you think I should build a
curl-7.71.1-2upgrade package ASAP with a local Cygwincurl#5808 patch, or wait for the next officialcurlrelease including the patch?bagder commentedon Aug 14, 2020
Agreed.
curl-configis older and was added to curl in April 2001 with inspiration from some other project that I now forget which it was. I don't know when pkg-config actually became a real "thing" but curl has supported it since December 2004.kbrow1i commentedon Aug 14, 2020
Yes.
BrianInglis commentedon Aug 14, 2020
Patch #5808 disables support for static libraries and I believe that now prevents the
curltests from being built or run - alternative suggestions which support a patch to allow both dynamic and static library builds?kbrow1i commentedon Aug 14, 2020
No, it doesn't. cygport does that by default, and it's standard Cygwin practice.
This no longer has anything to do with the bug report. Let's move the discussion to the cygwin-apps list and I'll answer there. I can't do it immediately, but I'll get to it in a couple hours. If you're impatient, search the cygport manual for '-no-undefined'.
BrianInglis commentedon Aug 15, 2020
Sorry @kbrow1i is correct #5808 is good and has been applied locally to an updated Cygwin
curl{,-devel,-doc}fix release.BrianInglis commentedon Aug 24, 2020
Thanks for Cygwin changes included in latest release - our downstream package maintainers and consumers are happy that curl and libcurl build right from download, and downstreams like Cygwin git, and consumers like the OP @ramsay-jones , can now use either your release sources or the Cygwin packaged sources.
It would be good if @ramsay-jones could confirm and close?
bagder commentedon Aug 24, 2020
Excellent news @BrianInglis. Thanks for the great cooperation and do let us know if there are other cygwin nits existing already now or appearing in the future that we should better fix.
BrianInglis commentedon Aug 25, 2020
Cheers @bagder and thank you.
I am sure someone will let me know quickly if any issues develop.
ramsay-jones commentedon Aug 25, 2020