opam-repository icon indicating copy to clipboard operation
opam-repository copied to clipboard

Cannot compile ocaml-base-compiler.4.10.0 under MSVC+Cygwin

Open MisterDA opened this issue 5 years ago • 7 comments

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:

  1. OCAML_STDLIB_DIR

    This 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 OCAMLLIB with 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'
    
  2. flexdll.h: No such file or directory

    My guess is that it is possible that during the compilation of ocaml-compiler-base, the flexdll directory 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!

MisterDA avatar May 19 '20 15:05 MisterDA

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.

dra27 avatar May 19 '20 15:05 dra27

Oh, thanks.

MisterDA avatar May 19 '20 16:05 MisterDA

Why doesn’t opam-repository support MSVC? What can be done to fix that?

MisterDA avatar May 19 '20 16:05 MisterDA

Start in ocaml/opam#246 and go from there 🙂

dra27 avatar May 19 '20 16:05 dra27

(also https://fdopen.github.io/opam-repository-mingw/ if you're not already aware)

dra27 avatar May 19 '20 16:05 dra27

I'm on in this as part of the upgrade of ocaml-base-compiler packages to support Windows for 2.2.0

dra27 avatar Jul 08 '21 10:07 dra27

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

kit-ty-kate avatar Jul 31 '23 13:07 kit-ty-kate

@MisterDA given all the windows improvements that occurred since 2020 is this issue still relevant ? Otherwise we should move on to close this.

dbuenzli avatar Mar 14 '25 22:03 dbuenzli

I was so young and full of hope! Glad to see this one fixed.

MisterDA avatar Mar 15 '25 00:03 MisterDA