opam-repository
opam-repository copied to clipboard
Cannot compile ocaml-base-compiler.4.10.0 under MSVC+Cygwin
Hi, I’m using Opam under Cygwin with the MSVC64 compiler. When initializing Opam, I configure it to build the ocaml-base-compiler.4.10.0 package. The build script I’m using is essentially the same as Opam CI. You can see the build log on AppVeyor and the code that produced it.
The command is essentially:
OPAMROOT="$(cygpath -m "${PREFIX}/opam")"; export OPAMROOT
OPAMSWITCH=default; export OPAMSWITCH
opam init -y -a --disable-sandboxing \
-c "ocaml-base-compiler.${OCAML_VERSION}" \
"$OPAM_REPO"
However, I have two issues:
-
OCAML_STDLIB_DIRThis variable seems to be generated from OCaml's configure script. The problem is that the path is in the Windows format. The backlash are not escaped and are considered as 'unknown escape sequences' in C code. I have not been able to override this variable. I tried setting
OCAMLLIBwith mixed path style (Windows path with forward slashes), to no avail. An excerpt of the error:gcc -c -O2 -fno-strict-aliasing -fwrapv -Wall -fno-common -fno-tree-vrp -g -D_FILE_OFFSET_BITS=64 -U_WIN32 -D_REENTRANT -DCAML_NAME_SPACE -DOCAML_STDLIB_DIR='"C:\cygwin64\opt\OCamlPlatform\opam\ocaml-base-compiler.4.10.0/lib/ocaml"' -o dynlink_b.o dynlink.c - dynlink.c: In function ‘parse_ld_conf’: - dynlink.c:91:32: warning: unknown escape sequence: '\c' - 91 | if (stdlib == NULL) stdlib = OCAML_STDLIB_DIR; - | ^~~~~~~~~~~~~~~~ - dynlink.c:91:32: warning: unknown escape sequence: '\o' - dynlink.c:91:32: warning: unknown escape sequence: '\O' - dynlink.c:91:32: warning: unknown escape sequence: '\o' - dynlink.c:91:32: warning: unknown escape sequence: '\o' -
flexdll.h: No such file or directoryMy guess is that it is possible that during the compilation of ocaml-compiler-base, the
flexdlldirectory of the OCaml sources is not populated with Flexdll, or that the compiler gets wrong paths to the flexdll installation. What’s the play here? Should Flexdll be installed globally?- gcc -c -O2 -fno-strict-aliasing -fwrapv -Wall -fno-common -fno-tree-vrp -g -D_FILE_OFFSET_BITS=64 -U_WIN32 -D_REENTRANT -DCAML_NAME_SPACE -o unix_b.o unix.c - unix.c:35:10: fatal error: flexdll.h: No such file or directory - 35 | #include "flexdll.h" - | ^~~~~~~~~~~ - compilation terminated. - make[1]: *** [Makefile:341: unix_b.o] Error 1
Thanks!
You're doing this with normal opam-repository, right? This simply doesn't work at the moment - opam-repository doesn't support building ocaml-base-compiler on MSVC.
Oh, thanks.
Why doesn’t opam-repository support MSVC? What can be done to fix that?
Start in ocaml/opam#246 and go from there 🙂
(also https://fdopen.github.io/opam-repository-mingw/ if you're not already aware)
I'm on in this as part of the upgrade of ocaml-base-compiler packages to support Windows for 2.2.0
i moved this issue to opam-repository as it is now mostly an opam-repository issue since the release of opam.2.2.0~alpha
@MisterDA given all the windows improvements that occurred since 2020 is this issue still relevant ? Otherwise we should move on to close this.
I was so young and full of hope! Glad to see this one fixed.