ygrek / ocurl

OCaml bindings to libcurl
https://ygrek.org/p/ocurl
MIT License
59 stars 32 forks source link

ocurl started to fail to install on windows #77

Closed aryx closed 1 week ago

aryx commented 1 month ago
#=== ERROR while compiling ocurl.0.9.2 ========================================#
# context     2.0.10 | win32/x86_64 | ocaml-variants.4.14.2+mingw64c | git+https://github.com/ocaml-opam/opam-repository-mingw.git#sunset
# path        D:/a/semgrep-proprietary/semgrep-proprietary/_opam/.opam-switch/build/ocurl.0.9.2
# command     D:\cygwin\bin\make.exe
# exit-code   2
# env-file    D:/.opam/log/ocurl-4640-3c14c6.env
# output-file D:/.opam/log/ocurl-4640-3c14c6.out
### output ###
# make[1]: Entering directory '/cygdrive/d/a/semgrep-proprietary/semgrep-proprietary/_opam/.opam-switch/build/ocurl.0.9.2'
# make[1]: Leaving directory '/cygdrive/d/a/semgrep-proprietary/semgrep-proprietary/_opam/.opam-switch/build/ocurl.0.9.2'
# make[1]: Entering directory '/cygdrive/d/a/semgrep-proprietary/semgrep-proprietary/_opam/.opam-switch/build/ocurl.0.9.2'
# ocamlc.opt -c -g -bin-annot curl.mli -o curl.cmi
# ocamlc.opt -c -g -bin-annot curl.ml -o curl.cmo
# ocamlc.opt -c -ccopt "-g -O2  -DHAVE_CONFIG_H -Wall -Wundef" curl-helper.c
# In file included from curl-helper.c:23:
# curl-helper.c: In function 'handle_15':
# curl-helper.c:1654:59: error: 'CURLOPT_15' undeclared (first use in this function); did you mean 'CURLOPT_ECH'?
#  1654 | #define SETOPT_VAL(name, conv) SETOPT_VAL_(handle_##name, CURLOPT_##name, conv)
#       |                                                           ^~~~~~~~
# curl-helper.c:1654:32: note: in expansion of macro 'SETOPT_VAL_'
#  1654 | #define SETOPT_VAL(name, conv) SETOPT_VAL_(handle_##name, CURLOPT_##name, conv)
#       |                                ^~~~~~~~~~~
# curl-helper.c:1655:27: note: in expansion of macro 'SETOPT_VAL'
#  1655 | #define SETOPT_BOOL(name) SETOPT_VAL(name, Bool_val)
#       |                           ^~~~~~~~~~
# curl-helper.c:2794:1: note: in expansion of macro 'SETOPT_BOOL'
#  2794 | SETOPT_BOOL( TCP_FASTOPEN)
#       | ^~~~~~~~~~~
# curl-helper.c:1654:59: note: each undeclared identifier is reported only once for each function it appears in
#  1654 | #define SETOPT_VAL(name, conv) SETOPT_VAL_(handle_##name, CURLOPT_##name, conv)
#       |                                                           ^~~~~~~~
# curl-helper.c:1654:32: note: in expansion of macro 'SETOPT_VAL_'
#  1654 | #define SETOPT_VAL(name, conv) SETOPT_VAL_(handle_##name, CURLOPT_##name, conv)
#       |                                ^~~~~~~~~~~
# curl-helper.c:1655:27: note: in expansion of macro 'SETOPT_VAL'
#  1655 | #define SETOPT_BOOL(name) SETOPT_VAL(name, Bool_val)
#       |                           ^~~~~~~~~~
# curl-helper.c:2794:1: note: in expansion of macro 'SETOPT_BOOL'
#  2794 | SETOPT_BOOL( TCP_FASTOPEN)
#       | ^~~~~~~~~~~
# curl-helper.c: At top level:
# curl-helper.c:3291:22: error: 'handle_TCP_FASTOPEN' undeclared here (not in a function)
#  3291 | #define HAVE(name) { handle_ ## name, "CURLOPT_"#name }
#       |                      ^~~~~~~
# curl-helper.c:3291:22: note: in definition of macro 'HAVE'
#  3291 | #define HAVE(name) { handle_ ## name, "CURLOPT_"#name }
#       |                      ^~~~~~~
# curl-helper.c:1654:44: warning: 'handle_15' defined but not used [-Wunused-function]
#  1654 | #define SETOPT_VAL(name, conv) SETOPT_VAL_(handle_##name, CURLOPT_##name, conv)
#       |                                            ^~~~~~~
# curl-helper.c:1641:13: note: in definition of macro 'SETOPT_VAL_'
#  1641 | static void func_name(Connection *conn, value option) \
#       |             ^~~~~~~~~
# curl-helper.c:1655:27: note: in expansion of macro 'SETOPT_VAL'
#  1655 | #define SETOPT_BOOL(name) SETOPT_VAL(name, Bool_val)
#       |                           ^~~~~~~~~~
# curl-helper.c:2[794](https://github.com/semgrep/semgrep-proprietary/actions/runs/9368254072/job/25789817055?pr=1644#step:9:795):1: note: in expansion of macro 'SETOPT_BOOL'
#  2794 | SETOPT_BOOL( TCP_FASTOPEN)
#       | ^~~~~~~~~~~
# make[1]: *** [Makefile:128: curl-helper.o] Error 2
# make[1]: Leaving directory '/cygdrive/d/a/semgrep-proprietary/semgrep-proprietary/_opam/.opam-switch/build/ocurl.0.9.2'
# make: *** [Makefile:61: all] Error 2

<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
+- The following actions failed
| - build ocurl 0.9.2
+- 
+
aryx commented 1 month ago

This used to work fine; not sure what changed recently, but it does not build anymore on windows. I've tried on a fresh cygwin and fresh install of fdopen opam for windows and got the error too.

ygrek commented 1 month ago

this looks like C compiler or headers issue/change.

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>

#include <caml/config.h> /* defines HAS_UNISTD */
#ifdef HAS_UNISTD
#include <unistd.h>
#endif
/* suppress false gcc warning on seekFunction */
#define CURL_DISABLE_TYPECHECK
#include <curl/curl.h>

#include <caml/alloc.h>
#include <caml/memory.h>
#include <caml/mlvalues.h>
#include <caml/callback.h>
#include <caml/fail.h>
#include <caml/unixsupport.h>
#include <caml/custom.h>
#include <caml/threads.h>

int main()
{
return TCP_FASTOPEN;
}

does this compile and return 15?

aryx commented 1 month ago

It does not compile.

pad@xayr ~/work
$ ocamlc.opt -c -ccopt "-g -O2 -DHAVE_CONFIG_H -Wall -Wundef" test.c
In file included from C:/cygwin64/home/pad/.opam/ocaml-variants.4.14.0+mingw64/lib/ocaml/caml/config.h:45,
                 from test.c:6:
C:/cygwin64/home/pad/.opam/ocaml-variants.4.14.0+mingw64/lib/ocaml/caml/compatibility.h:71:34: error: expect
ed declaration specifiers or ‘...’ before string constant
   71 | #define callback CAML_DEPRECATED("callback", "caml_callback") caml_callback
      |                                  ^~~~~~~~~~
C:/cygwin64/home/pad/.opam/ocaml-variants.4.14.0+mingw64/lib/ocaml/caml/compatibility.h:71:46: error: expect
ed declaration specifiers or ‘...’ before string constant
   71 | #define callback CAML_DEPRECATED("callback", "caml_callback") caml_callback
      |                                              ^~~~~~~~~~~~~~~

pad@xayr ~/work
aryx commented 1 month ago

Different error though than the one I had when installing ocurl

aryx commented 1 month ago

It does not compile either on my arch linux machine though:

/home/pad/work/EXPERIMENTS/ocurl $ ocamlc.opt -c -ccopt "-g -O2 -DHAVE_CONFIG_H -Wall -Wundef" test.c 
test.c: In function ‘main’:
test.c:25:8: error: ‘TCP_FASTOPEN’ undeclared (first use in this function); did you mean ‘MSG_FASTOPEN’?
   25 | return TCP_FASTOPEN;
      |        ^~~~~~~~~~~~
      |        MSG_FASTOPEN
test.c:25:8: note: each undeclared identifier is reported only once for each function it appears in
/home/pad/work/EXPERIMENTS/ocurl $ 
nojb commented 1 month ago

I think you should replace TCP_FASTOPEN by CURLOPT_TCP_FASTOPEN in the test file.

aryx commented 1 month ago

still, this does not explain the compilation error in windows

aryx commented 1 month ago

and why suddently ocurl can't be installed under windows (I use fdopen opam for windows)

nojb commented 1 month ago

It is probably related in some way with #52; you may want to downgrade back to 0.9.1.

nojb commented 1 month ago

@ygrek TCP_FASTOPEN is defined in the Windows headers (probably included transitively by unixsupport.h) with the value 15.

nojb commented 1 month ago

@ygrek TCP_FASTOPEN is defined in the Windows headers (probably included transitively by unixsupport.h) with the value 15.

Maybe #undef TCP_FASTOPEN could be a way around.

aryx commented 1 month ago

oh indeed, I was able to install ocurl 0.9.1 on windows! Thx!

aryx commented 1 month ago

weird though, 0.9.2 is from 2022 so why suddently it started to fail to install under windows in the last week?

ygrek commented 1 month ago

@ygrek TCP_FASTOPEN is defined in the Windows headers (probably included transitively by unixsupport.h) with the value 15.

that's what i wanted to test with that code, that explains

ygrek commented 1 month ago

@ygrek TCP_FASTOPEN is defined in the Windows headers (probably included transitively by unixsupport.h) with the value 15.

Maybe #undef TCP_FASTOPEN could be a way around.

short term yes, but meh long term should generate code with something better than cpp