New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
curl-config --libs returns incorrect value on cygwin #5793
Comments
Did you build libcurl static only? |
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 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. 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. |
Thanks that input @me-and. I presume we can then consider this case closed @ramsay-jones ? |
On 10/08/2020 22:25, Daniel Stenberg wrote:
Thanks that input @me-and <https://github.com/me-and>. I presume we can then consider this case closed @ramsay-jones <https://github.com/ramsay-jones> ?
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 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 It looks to me as if the generated
based on
but for Cygwin and a number of other platforms
|
Fixes curl-config genreration on cygwin by making sure REQUIRE_LIB_DEPS is set to 'no' there. Assisted-by: Brian Inglis Fixes #5793
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.
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
|
Whoops! I see the patch got mangled. Let me try attaching it instead. |
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
I understood the need for the patch was that Cygwin needs dynamically linked against I did not need a patch because I was able to build both With a large number of Cygwin package
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 |
Fixes a curl-config issue on cygwin by making sure REQUIRE_LIB_DEPS is not considered for the --libs output. Reported-by: ramsay-jones on github Assisted-by: Brian Inglis and Ken Brown Fixes #5793
In the mean time, I created a separate PR with that simpler take. |
Thanks for notifying me, I'll take a look in a few hours tonight. Ironically, I made my change in the context of cross-compiling statically for Windows but not Cygwin. |
I think you're confusing two unrelated things. 'link_all_deplibs' is a libtool variable that affects the linking while building curl itself. If you try to build curl with link_all_deplibs=no, I think you'll find that the executable curl.exe will fail to link because many of the libs it needs will be omitted from the link command line. The default value 'unknown', which is synonymous with 'yes', is correct. On the other hand, the output of 'curl-config --libs', which is the subject of this bug report, affects what other applications need to provide on their link command line when they want to link against libcurl. (This is necessarily dynamic linking, since the Cygwin build of curl disables static libraries.) As the author of this bug report explained very clearly, these applications need to provide only '-lcurl'. The value of link_all_deplibs when curl was built is not relevant. |
While building Also while building Perhaps we need a better understanding of |
On 13/08/2020 16:49, Brian Inglis wrote:
[snip]
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! My question would be why packages appear to be using So now I am unsure exactly where the fix effort should really be directed - Cygwin, 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 |
/me waves to @me-and. I've now had a chance to digest this. I agree with what @kbrow1i is proposing, and hence #5808. My own distribution is Gentoo and More broadly speaking, I think |
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. |
Agreed. |
Patch #5808 disables support for static libraries and I believe that now prevents the
|
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'. |
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. |
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. |
Cheers @bagder and thank you. |
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
|
I did this
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).
$ cygcheck -cd | grep curl
curl 7.71.1-1
libcurl-devel 7.71.1-1
libcurl-doc 7.71.1-1
libcurl4 7.71.1-1
$
The git makefile uses 'curl-config --libs', which produces:
$ curl-config --libs
-lcurl -lnghttp2 -lidn2 -lssh -lpsl -lssl -lcrypto -lldap -llber -lbrotlidec -lbrotlidec -lz
$
Looking at the '/usr/lib/pkgconfig/libcurl.pc' file, I find:
$ cat /usr/lib/pkgconfig/libcurl.pc
...
Libs: -L${libdir} -lcurl
Libs.private: -lnghttp2 -lidn2 -lssh -lpsl -lssl -lcrypto -lldap -llber -lbrotlidec -lbrotlidec -lz
...
$
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. ;-)
I expected the following
git to build correctly!
curl/libcurl version
$ curl -V
curl 7.71.1 (x86_64-pc-cygwin) libcurl/7.71.1 OpenSSL/1.1.1f zlib/1.2.11 brotli/1.0.7 libidn2/2.2.0 libpsl/0.21.0 (+libidn2/2.0.4) libssh/0.8.7/openssl/zlib nghttp2/1.37.0
Release-Date: 2020-07-01
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: AsynchDNS brotli Debug HTTP2 HTTPS-proxy IDN IPv6 Largefile libz NTLM NTLM_WB PSL SSL TLS-SRP TrackMemory UnixSockets
$
operating system
$ uname -a
CYGWIN_NT-10.0 satellite 3.1.6(0.340/5/3) 2020-07-09 08:20 x86_64 Cygwin
$
The text was updated successfully, but these errors were encountered: