Skip to content
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_addrinfo.c error: 'getaddrinfo' undeclared in old-MinGW CI builds #9214

Closed
bagder opened this issue Jul 26, 2022 · 5 comments
Closed

curl_addrinfo.c error: 'getaddrinfo' undeclared in old-MinGW CI builds #9214

bagder opened this issue Jul 26, 2022 · 5 comments
Labels
build CI Continuous Integration cmake Windows Windows-specific

Comments

@bagder
Copy link
Member

bagder commented Jul 26, 2022

The appveyor CI builds with cmake using Visual Studio 2022 are permafailing since a while back. See log

The compiler errors are:

C:/projects/curl/lib/curl_addrinfo.c: In function 'Curl_getaddrinfo_ex':
C:/projects/curl/lib/curl_addrinfo.c:192:5: error: implicit declaration of function 'freeaddrinfo'; did you mean 'getaddrinfo'? [-Werror=implicit-function-declaration]
  192 |     freeaddrinfo(aihead);
      |     ^~~~~~~~~~~~
      |     getaddrinfo
C:/projects/curl/lib/curl_addrinfo.c:192:5: error: nested extern declaration of 'freeaddrinfo' [-Werror=nested-externs]
C:/projects/curl/lib/curl_addrinfo.c: In function 'curl_dbg_getaddrinfo':
C:/projects/curl/lib/curl_addrinfo.c:556:14: error: 'getaddrinfo' undeclared (first use in this function); did you mean 'addrinfo'?
  556 |   int res = (getaddrinfo)(hostname, service, hints, result);
      |              ^~~~~~~~~~~
      |              addrinfo
C:/projects/curl/lib/curl_addrinfo.c:556:14: note: each undeclared identifier is reported only once for each function it appears in
cc1.exe: all warnings being treated as errors
make[2]: *** [lib/CMakeFiles/libcurl.dir/build.make:242: lib/CMakeFiles/libcurl.dir/curl_addrinfo.c.obj] Error 1
@bagder bagder added build cmake Windows Windows-specific CI Continuous Integration labels Jul 26, 2022
@gvanem
Copy link
Contributor

gvanem commented Jul 27, 2022

Looks like a _WIN32_WINNT >= 0x0602 is not set on AppVeyor. But I fail to understand which SDK is used and how CMake uses it.

Edit. From the above log, it seems to use the old SDK under C:\Program Files\Microsoft SDKs\Windows\v7.1.

@mback2k
Copy link
Member

mback2k commented Aug 15, 2022

Ping @MarcelRaad

@MarcelRaad
Copy link
Member

MarcelRaad commented Aug 15, 2022

This is the classic MinGW build, which uses MinGW's own SDK and defaults to _WIN32_WINNT = 0x500.
The output clearly says "-- Looking for freeaddrinfo - not found", so we shouldn't try to use it. I haven't investigated yet what broke it.

@MarcelRaad
Copy link
Member

MarcelRaad commented Aug 15, 2022

8ba22ff removed forcing _WIN32_WINNT to 0x501, which previously made getaddrinfo and freeaddrinfo available for classic MinGW.
But why does

check_symbol_exists(getaddrinfo "${CURL_INCLUDES}" HAVE_GETADDRINFO)
set HAVE_GETADDRINFO? The autotools builds correctly determines it to be unavailable, and I currently don't have a CMake setup usable with classic MinGW 😕

@vszakats
Copy link
Member

vszakats commented Aug 15, 2022

@MarcelRaad: In CMake/Platforms/WindowsCache.cmake there is this:

    if(ENABLE_IPV6)
      set(HAVE_GETADDRINFO 1)
    else()
      set(HAVE_GETADDRINFO 0)
    endif()

Can it be related to this issue?

(Half-guessing, so this may totally be wrong, but this file seems to be offering predefined configuration values for Windows, and for these, the actual test is not performed?)

bagder added a commit that referenced this issue Aug 30, 2022
The Visual Studio 2022 / cmake / msys build has failed to build for
months. Removing it.

Fixes #9214
bagder added a commit that referenced this issue Aug 30, 2022
vszakats added a commit to vszakats/curl that referenced this issue Aug 30, 2022
[TODO: commit message]

Ref: curl#9393
Ref: curl#9214

Closes #xxxx
Fixes #xxxx
@vszakats vszakats changed the title curl_addrinfo.c error: 'getaddrinfo' undeclared in Visual Studio 2022 CI builds curl_addrinfo.c error: 'getaddrinfo' undeclared in MSYS-classic CI builds Aug 30, 2022
vszakats added a commit to vszakats/curl that referenced this issue Aug 30, 2022
Commit d08ee3c (in 2013) added logic
that automatically assumed `getaddrinfo()` to be present for builds with
IPv6 enabled. As it turns out, certain toolchains (e.g. classic MSYS) by
default target older Windows versions, and thus do not support
`getaddrinfo()` out of the box. This fact was masked for a while by CMake
builds forcing a newer Windows version, but that logic got deleted in
commit 8ba22ff. Since then, some builds
started failing due to IPv6 enabled, `HAVE_GETADDRINFO` being set, but
`getaddrinfo()` in fact missing.

It also turns out that IPv6 works without `getaddrinfo()` since commit
67a08dc (from 2019, via curl#4662). So, to
resolve all this, we can now revert the initial commit, thus restoring
correct `getaddrinfo()` detection and support IPv6 regardless of its
outcome.

Reported-by: Daniel Stenberg

Fixes curl#9214
Fixes curl#9393
Fixes curl#9395
Closes curl#9396
@vszakats vszakats changed the title curl_addrinfo.c error: 'getaddrinfo' undeclared in MSYS-classic CI builds curl_addrinfo.c error: 'getaddrinfo' undeclared in legacy MinGW CI builds Aug 30, 2022
@vszakats vszakats changed the title curl_addrinfo.c error: 'getaddrinfo' undeclared in legacy MinGW CI builds curl_addrinfo.c error: 'getaddrinfo' undeclared in old-MinGW CI builds Aug 30, 2022
vszakats added a commit to vszakats/curl that referenced this issue Aug 30, 2022
Commit d08ee3c (in 2013) added logic
that automatically assumed `getaddrinfo()` to be present for builds with
IPv6 enabled. As it turns out, certain toolchains (e.g. "original" MinGW)
by default target older Windows versions, and thus do not support
`getaddrinfo()` out of the box. The issue was masked for a while by CMake
builds forcing a newer Windows version, but that logic got deleted in
commit 8ba22ff. Since then, some CI
builds started failing due to IPv6 enabled, `HAVE_GETADDRINFO` set, but
`getaddrinfo()` in fact missing.

It also turns out that IPv6 works without `getaddrinfo()` since commit
67a08dc (from 2019, via curl#4662). So, to
resolve all this, we can now revert the initial commit, thus restoring
`getaddrinfo()` detection and support IPv6 regardless of its outcome.

Reported-by: Daniel Stenberg

Fixes curl#9214
Closes curl#9396
vszakats added a commit to vszakats/curl that referenced this issue Aug 31, 2022
1. Re-enable `HAVE_GETADDRINFO` detection on Windows

Commit d08ee3c (in 2013) added logic
that automatically assumed `getaddrinfo()` to be present for builds with
IPv6 enabled. As it turns out, certain toolchains (e.g. original MinGW)
by default target older Windows versions, and thus do not support
`getaddrinfo()` out of the box. The issue was masked for a while by CMake
builds forcing a newer Windows version, but that logic got deleted in
commit 8ba22ff. Since then, some CI
builds started failing due to IPv6 enabled, `HAVE_GETADDRINFO` set, but
`getaddrinfo()` in fact missing.

It also turns out that IPv6 works without `getaddrinfo()` since commit
67a08dc (from 2019, via curl#4662). So, to
resolve all this, we can now revert the initial commit, thus restoring
`getaddrinfo()` detection and support IPv6 regardless of its outcome.

Reported-by: Daniel Stenberg

2. Omit `bcrypt` with original MinGW

Original (aka old/legacy) MinGW versions do not support `bcrypt`
(introduced with Vista). We already have logic to handle that in
`lib/rand.c` and autotools builds, where we do not call the unsupported
API and do not link `bcrypt`, respectively, when using old MinGW.

This patch ports that logic to CMake, fixing the link error:
`c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: cannot find -lbcrypt`

Ref: curl#9396 (comment)
Ref: https://ci.appveyor.com/project/curlorg/curl/builds/44624888/job/40vle84cn4vle7s0#L508
Regression since 7617251

Fixes curl#9214
Fixes curl#9393
Fixes curl#9395
Closes curl#9396
vszakats added a commit to vszakats/curl that referenced this issue Aug 31, 2022
1. Re-enable `HAVE_GETADDRINFO` detection on Windows

   Commit d08ee3c (in 2013) added logic
   that automatically assumed `getaddrinfo()` to be present for builds
   with IPv6 enabled. As it turns out, certain toolchains (e.g. original
   MinGW) by default target older Windows versions, and thus do not
   support `getaddrinfo()` out of the box. The issue was masked for
   a while by CMake builds forcing a newer Windows version, but that
   logic got deleted in commit 8ba22ff.
   Since then, some CI builds started failing due to IPv6 enabled,
   `HAVE_GETADDRINFO` set, but `getaddrinfo()` in fact missing.

   It also turns out that IPv6 works without `getaddrinfo()` since commit
   67a08dc (from 2019, via curl#4662). So,
   to resolve all this, we can now revert the initial commit, thus
   restoring `getaddrinfo()` detection and support IPv6 regardless of its
   outcome.

   Reported-by: Daniel Stenberg

2. Omit `bcrypt` with original MinGW

   Original (aka old/legacy) MinGW versions do not support `bcrypt`
   (introduced with Vista). We already have logic to handle that in
   `lib/rand.c` and autotools builds, where we do not call the
   unsupported API and do not link `bcrypt`, respectively, when using
   original MinGW.

   This patch ports that logic to CMake, fixing the link error:
   `c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: cannot find -lbcrypt`

   Ref: https://ci.appveyor.com/project/curlorg/curl/builds/44624888/job/40vle84cn4vle7s0#L508
   Regression since 7617251

Fixes curl#9214
Fixes curl#9393
Fixes curl#9395
Closes curl#9396
vszakats added a commit to vszakats/curl that referenced this issue Aug 31, 2022
1. Re-enable `HAVE_GETADDRINFO` detection on Windows

   Commit d08ee3c (in 2013) added logic
   that automatically assumed `getaddrinfo()` to be present for builds
   with IPv6 enabled. As it turns out, certain toolchains (e.g. original
   MinGW) by default target older Windows versions, and thus do not
   support `getaddrinfo()` out of the box. The issue was masked for
   a while by CMake builds forcing a newer Windows version, but that
   logic got deleted in commit 8ba22ff.
   Since then, some CI builds started failing due to IPv6 enabled,
   `HAVE_GETADDRINFO` set, but `getaddrinfo()` in fact missing.

   It also turns out that IPv6 works without `getaddrinfo()` since commit
   67a08dc (from 2019, via curl#4662). So,
   to resolve all this, we can now revert the initial commit, thus
   restoring `getaddrinfo()` detection and support IPv6 regardless of its
   outcome.

   Reported-by: Daniel Stenberg

2. Omit `bcrypt` with original MinGW

   Original (aka legacy/old) MinGW versions do not support `bcrypt`
   (introduced with Vista). We already have logic to handle that in
   `lib/rand.c` and autotools builds, where we do not call the
   unsupported API and do not link `bcrypt`, respectively, when using
   original MinGW.

   This patch ports that logic to CMake, fixing the link error:
   `c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: cannot find -lbcrypt`

   Ref: https://ci.appveyor.com/project/curlorg/curl/builds/44624888/job/40vle84cn4vle7s0#L508
   Regression since 7617251

Fixes curl#9214
Fixes curl#9393
Fixes curl#9395
Closes curl#9396
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build CI Continuous Integration cmake Windows Windows-specific
5 participants