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

(MSYS2/MinGW/GCC 14) nonblock.c: In function 'curlx_nonblock': no non-blocking method was found/used/set #13579

Closed
LigH-de opened this issue May 10, 2024 · 21 comments
Labels
build Windows Windows-specific

Comments

@LigH-de
Copy link

LigH-de commented May 10, 2024

I did this

Compiling in media-autobuild suite for Win32 target

  CC       libcurl_la-nonblock.lo
../../lib/nonblock.c: In function 'curlx_nonblock':
../../lib/nonblock.c:82:4: error: #error "no non-blocking method was found/used/set"
   82 | #  error "no non-blocking method was found/used/set"
      |    ^~~~~
make[2]: *** [Makefile:2831: libcurl_la-nonblock.lo] Error 1

logs.zip

HAVE_IOCTLSOCKET_FIONBIO should be defined as 1 in lib/config-win32.h

I expected the following

successful compilation

curl/libcurl version

HEAD

operating system

MSYS2/MinGW

@bagder
Copy link
Member

bagder commented May 10, 2024

How do you build curl?

@LigH-de
Copy link
Author

LigH-de commented May 10, 2024

I start the media-autobuild_suite.bat and wait...

Details are in the attached logs.zip file (several logs and configurations collected by M-AB-S). Head of the make log:

CPPFLAGS:  -DGNUTLS_INTERNAL_BUILD -DNGHTTP2_STATICLIB -DPSL_STATIC
CFLAGS: -D_FORTIFY_SOURCE=2 -fstack-protector-strong -mtune=generic -O2 -pipe -D__USE_MINGW_ANSI_STDIO=1 -mthreads
CXXFLAGS: -D_FORTIFY_SOURCE=2 -fstack-protector-strong -mtune=generic -O2 -pipe -D__USE_MINGW_ANSI_STDIO=1
LDFLAGS: -D_FORTIFY_SOURCE=2 -fstack-protector-strong -mtune=generic -O2 -pipe -D__USE_MINGW_ANSI_STDIO=1 -static-libgcc -static-libstdc++
make -j4 

Configuration:
$ ../configure --prefix=/local32 --disable-shared --enable-static --bindir=/local32/bin-global --with-nghttp2 --with-openssl --without-gnutls --without-mbedtls --without-libssh2 --without-random --without-ca-bundle --without-ca-path --without-librtmp --with-brotli --enable-sspi --disable-debug

@vszakats
Copy link
Member

Normally for mingw-w64, HAVE_IOCTLSOCKET_FIONBIO is defined by autotools via the generated curl_config.h.
Since it isn't, it suggests that the auto-detection fails for some unrelated reason, maybe due to the extra passed options.
Peeking into config.log could give the answer.

@vszakats vszakats added the Windows Windows-specific label May 10, 2024
@LigH-de
Copy link
Author

LigH-de commented May 10, 2024

Yesterday and the day before it still compiled...

@vszakats
Copy link
Member

Our tests are silent about this. It's the line checking if ioctl FIONBIO might be used... yes in the configure output.

Is there any clue in your config.log about this particular check?

@LigH-de
Copy link
Author

LigH-de commented May 10, 2024

https://github.com/curl/curl/files/15273796/logs.zip contains all the log files.

configure:41533: checking if ioctlsocket FIONBIO is compilable
configure:41553: ccache gcc -c -D_FORTIFY_SOURCE=2 -fstack-protector-strong -mtune=generic -O2 -pipe -D__USE_MINGW_ANSI_STDIO=1 -mthreads -Werror-implicit-function-declaration -Wno-system-headers -DGNUTLS_INTERNAL_BUILD -DNGHTTP2_STATICLIB -DPSL_STATIC -IG:/MABS/msys64/mingw32/include -IG:/MABS/msys64/mingw32/include  -IG:/MABS/msys64/mingw32/include -IG:/MABS/local32/include -IG:/MABS/msys64/mingw32/include conftest.c >&5
conftest.c: In function 'main':
conftest.c:152:41: error: passing argument 3 of 'ioctlsocket' from incompatible pointer type [-Wincompatible-pointer-types]
  152 |         if(0 != ioctlsocket(0, FIONBIO, &flags))
      |                                         ^~~~~~
      |                                         |
      |                                         int *
In file included from conftest.c:144:
G:/MABS/msys64/mingw32/include/winsock2.h:1007:76: note: expected 'u_long *' {aka 'long unsigned int *'} but argument is of type 'int *'
 1007 |   WINSOCK_API_LINKAGE int WSAAPI ioctlsocket(SOCKET s,__LONG32 cmd,u_long *argp);
      |                                                                    ~~~~~~~~^~~~
...
configure:41562: result: no
configure:41585: checking if ioctlsocket FIONBIO might be used
configure:41596: result: no

@vszakats
Copy link
Member

Thanks. It's a legit complaint from the compiler, but this check has been like this since forever.

Would this be explained by a compiler upgrade? gcc 14 just happened.

@LigH-de
Copy link
Author

LigH-de commented May 10, 2024

Indeed possible...

gcc.exe (Rev2, Built by MSYS2 project) 14.1.0

@LigH-de LigH-de changed the title (MSYS2/MinGW) nonblock.c: In function 'curlx_nonblock': no non-blocking method was found/used/set (MSYS2/MinGW/GCC 14) nonblock.c: In function 'curlx_nonblock': no non-blocking method was found/used/set May 10, 2024
vszakats added a commit to vszakats/curl that referenced this issue May 10, 2024
```
conftest.c:152:41: error: passing argument 3 of 'ioctlsocket' from incompatible pointer type [-Wincompatible-pointer-types]
  152 |         if(0 != ioctlsocket(0, FIONBIO, &flags))
      |                                         ^~~~~~
      |                                         |
      |                                         int *
```

Reported-by: LigH
Fixes curl#13579
Closes #xxxxx
@vszakats
Copy link
Member

Would this patch fix the build for you?:
4bab28f

@LigH-de
Copy link
Author

LigH-de commented May 10, 2024

I have only little experience in editing the shell scripts used by the suite.
Are you able to provide this change as diff patch? Maybe github can do that if I just know how to build the matching URL...

@vszakats
Copy link
Member

@LigH-de
Copy link
Author

LigH-de commented May 10, 2024

Yes, I discovered how to add this patch and curl builds again.

@vszakats
Copy link
Member

@LigH-de Thanks for testing, and reporting! The fix is merged now.

@mickmack1213
Copy link

Sorry for reviving this. I just wanted to point this line out. I think a similar issue might happen at some point, as the wrong pointer type is passed (long instead of int though)

@vszakats
Copy link
Member

@mickmack1213 Can you paste which line do you mean or give a permalink?

@LigH-de
Copy link
Author

LigH-de commented Aug 28, 2024

this line

This actually is a permalink, it highlights the matching line 3253 in the source view in a reasonably modern webbrowser.

  if test "$curl_cv_func_ioctlsocket_camel" = "yes"; then
    AC_MSG_CHECKING([if IoctlSocket FIONBIO is compilable])
    AC_COMPILE_IFELSE([
      AC_LANG_PROGRAM([[
        $curl_includes_bsdsocket
      ]],[[    # <===
        long flags = 0;
        if(0 != IoctlSocket(0, FIONBIO, &flags))
          return 1;
      ]])
    ],[
      AC_MSG_RESULT([yes])
      tst_compi_ioctlsocket_camel_fionbio="yes"
    ],[
      AC_MSG_RESULT([no])
      tst_compi_ioctlsocket_camel_fionbio="no"
    ])
  fi

But I believe it refers to the following two lines, not the one with the double square brackets.

@vszakats
Copy link
Member

vszakats commented Aug 28, 2024

Ah okay, thanks for the snippet.

(In my browser, your link points to ]],[[. This will change if anything is pushed to master and wasn't clear what it meant. By permalink, I mean one that contains a commit hash to avoid ambiguity: https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-a-permanent-link-to-a-code-snippet)

@vszakats
Copy link
Member

Do you have a documentation link for IoctlSocket()?

@LigH-de
Copy link
Author

LigH-de commented Aug 28, 2024

The official Microsoft Winsock2 documentation specifies the flag (or iMode in the example there) as u_long (assuming that means unsigned long).

@vszakats
Copy link
Member

Are you sure this snippet is for Windows? the casing of the function looks different.

@LigH-de
Copy link
Author

LigH-de commented Aug 28, 2024

No, I only remembered that ioctlsocket is one of the functions in Winsock[2]. But now I noticed that the presence of $curl_includes_bsdsocket slipped me; and BSD Sockets are quite the same.

But I confess, I do not know where exactly the M4 script looks for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Windows Windows-specific
Development

Successfully merging a pull request may close this issue.

4 participants