Skip to content

msvc support #205

Closed
Closed

Description

@shayne-fletcher

I'm sorry if this gets asked a lot... Are there plans afoot to support msvc builds? I gave it a good go yesterday but failed to get a build - I googled around some but couldn't determine unequivocally if support on Win32 with msvc is intended to be supported. Thanks!

Activity

  1. Drup commented on Jan 5, 2016

    @Drup
    Member

    I don't think anyone is working on that, especially since lwt is working on the other linux ports. Patchs are always welcome, though.

  2. johnlepikhin commented on Jan 5, 2016

    @johnlepikhin

    One of my projects successfully works on MSVC+lwt (2.4.8). There was long story about how I prepared build environment, but as far as I remember there was no notable issues with lwt.

    $ ocamlfind.exe list | grep lwt
    lwt (version: 2.4.8)

    $ ocaml -version
    The OCaml toplevel, version 4.02.1

    $ ldd /cygdrive/e/ocamlmsvc32/lib/site-lib/lwt/dlllwt-unix_stubs.dll
    Cannot find FLEXDLL_RELOCATE
    ntdll.dll => /cygdrive/c/Windows/SYSTEM32/ntdll.dll (0x77dd0000)
    KERNEL32.DLL => /cygdrive/c/Windows/SYSTEM32/KERNEL32.DLL (0x77b40000)
    KERNELBASE.dll => /cygdrive/c/Windows/SYSTEM32/KERNELBASE.dll (0x76750000)
    ??? => ??? (0x72010000)
    ??? => ??? (0x763f0000)
    ??? => ??? (0x72320000)
    ??? => ??? (0x76350000)
    ??? => ??? (0x76820000)
    ??? => ??? (0x757f0000)
    ??? => ??? (0x757e0000)
    ??? => ??? (0x77cc0000)
    bcryptPrimitives.dll => /cygdrive/c/Windows/SYSTEM32/bcryptPrimitives.dll (0x75780000)

  3. johnlepikhin commented on Jan 5, 2016

    @johnlepikhin

    Here is my script which prepares Cygwin shell environment to work with MSVC/i686, hope it will help. This is full of mess and I'm not sure all of this is really required.

    $ cat ./.msenv32
    VCPATH="cygpath -p 'C:\Windows\Microsoft.NET\Framework\v4.0.30319;C:\Windows\Microsoft.NET\Framework\v3.5;;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools;;C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\Bin;C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\Bin\VCPackages;;C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\NETFX 4.0 Tools;C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin;;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;C:\Program Files\Microsoft Windows Performance Toolkit'"

    LIBPATH="C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib;C:\Windows\Microsoft.NET\Framework\v4.0.30319;C:\Windows\Microsoft.NET\Framework\v3.5;;C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\Lib;E:\devel\libs\mysql-connector\lib;E:\devel\libs\mysql-connector\lib\vs10;E:\devel\libs\PCRE\lib"

    LIB="$LIBPATH"

    INCLUDE="C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE;C:\Program Files\Microsoft SDKs\Windows\v7.1\INCLUDE;C:\Program Files\Microsoft SDKs\Windows\v7.1\INCLUDE\gl;;C:\Program Files (x86)\flexdll;E:\devel\libs\PCRE\include;E:\devel\libs\mysql-connector\include"

    FLPATH="cygpath 'C:\Program Files (x86)\flexdll'"

    CAMLPATH="e:\ocamlmsvc32\bin"

    PATH="$CAMLPATH:$VCPATH:$FLPATH:$PATH"

    export PATH LIB LIBPATH INCLUDE

  4. shayne-fletcher commented on Jan 7, 2016

    @shayne-fletcher
    Author

    ​Hi Evgenii,​

    On Tue, Jan 5, 2016 at 4:15 PM, Evgenii Lepikhin [email protected]
    wrote:

    One of my projects successfully works on MSVC+lwt (2.4.8). There was long
    story about how I prepared build environment, but as far as I remember
    there was no notable issues with lwt.

    Thanks. I have no problem with OCaml builds wrt msvc (I'm pretty handy at
    that). Where it's falling down with me is with the build procedure for lwt
    itself. The ocamlbuild procedure (at least for me) doesn't work out - do
    you recall doing anything special for that (in abstract, it appears to be
    dumping .obj files into non-expected locations)?

    I didn't push on it hard, I don't mind putting a little more effort into it
    but it would be nice to hear about a success story before investing anymore
    cycles.

    Shayne Fletcher

  5. johnlepikhin commented on Jan 7, 2016

    @johnlepikhin

    I took another try to recompile lwt (with the same environment as in my previous message). There was no issues, all is OK, including tests.

    Administrator@WIN-UC9GUCLA8O0:/cygdrive/e/src/lwt-2.4.8$ make clean
    ./setup.exe -clean
    rm -Rf 'E:\src\lwt-2.4.8_build'

    Administrator@WIN-UC9GUCLA8O0:/cygdrive/e/src/lwt-2.4.8$ ./configure
    not checking for pkg-config
    not checking for libev
    not checking for pthread
    not checking for glib
    not checking for eventfd
    not checking for fd passing
    not checking for sched_getcpu
    not checking for affinity getting/setting
    not checking for credentials getting (Linux)
    not checking for credentials getting (NetBSD)
    not checking for credentials getting (OpenBSD)
    not checking for credentials getting (FreeBSD)
    not checking for credentials getting (getpeereid)
    not checking for fdatasync
    not checking for netdb_reentrant
    Generating C stubs...

    Configuration:
    ocamlfind: ........................................... E:\ocamlmsvc32\bin\ocamlfind.EXE
    ocamlc: .............................................. E:\ocamlmsvc32\bin\ocamlc.opt.EXE
    ocamlopt: ............................................ E:\ocamlmsvc32\bin\ocamlopt.opt.EXE
    ocamlbuild: .......................................... E:\ocamlmsvc32\bin\ocamlbuild.EXE
    Package name: ........................................ lwt
    Package version: ..................................... 2.4.8
    os_type: ............................................. Win32
    system: .............................................. win32
    architecture: ........................................ i386
    ccomp_type: .......................................... msvc
    ocaml_version: ....................................... 4.02.1
    standard_library_default: ............................ e:/ocamlmsvc32/lib
    standard_library: .................................... e:/ocamlmsvc32/lib
    standard_runtime: .................................... ocamlrun
    bytecomp_c_compiler: ................................. cl -nologo -D_CRT_SECURE_NO_DEPRECATE -Ox -MD
    native_c_compiler: ................................... cl -nologo -D_CRT_SECURE_NO_DEPRECATE -Ox -MD
    model: ............................................... default
    ext_obj: ............................................. .obj
    ext_asm: ............................................. .asm
    ext_lib: ............................................. .lib
    ext_dll: ............................................. .dll
    default_executable_name: ............................. camlprog.exe
    systhread_supported: ................................. true
    flexlink: ............................................ C:\Program Files (x86)\flexdll\flexlink.EXE
    FlexDLL version (Win32): ............................. 0.34
    Install architecture-independent files dir: .......... C:\Program Files (x86)\lwt
    Install architecture-dependent files in dir: ......... $prefix
    User executables: .................................... $exec_prefix\bin
    System admin executables: ............................ $exec_prefix\sbin
    Program executables: ................................. $exec_prefix\libexec
    Read-only single-machine data: ....................... $prefix\etc
    Modifiable architecture-independent data: ............ $prefix\com
    Modifiable single-machine data: ...................... $prefix\var
    Object code libraries: ............................... $exec_prefix\lib
    Read-only arch-independent data root: ................ $prefix\share
    Read-only architecture-independent data: ............. $datarootdir
    Info documentation: .................................. $datarootdir\info
    Locale-dependent data: ............................... $datarootdir\locale
    Man documentation: ................................... $datarootdir\man
    Documentation root: .................................. $datarootdir\doc$pkg_name
    HTML documentation: .................................. $docdir
    DVI documentation: ................................... $docdir
    PDF documentation: ................................... $docdir
    PS documentation: .................................... $docdir
    findlib_version: ..................................... 1.5.5
    is_native: ........................................... true
    suffix_program: ...................................... .exe
    Remove a file.: ...................................... del
    Remove a directory.: ................................. rd
    Turn ocaml debug flag on: ............................ true
    Turn ocaml profile flag on: .......................... false
    Compiler support generation of .cmxs.: ............... true
    OCamlbuild additional flags: .........................
    Compiles for Android: ................................ false
    build and install everything: ........................ false
    Build the syntax extension: .......................... true
    Build the ppx syntax extension: ...................... false
    Unix support: ........................................ true
    React helpers: ....................................... false
    Glib integration: .................................... false
    SSL support: ......................................... false
    Preemptive threads support: .......................... true
    Compile with libev support: .......................... false
    Use the libev backend by default: .................... false
    Use pthread: ......................................... false
    Create documentations: ............................... true
    Compile tests executable and library and run them: ... false
    pkg_bytes: ........................................... E:\ocamlmsvc32\lib\site-lib\bytes
    pkg_unix: ............................................ E:\ocamlmsvc32\lib
    pkg_bigarray: ........................................ E:\ocamlmsvc32\lib
    pkg_compiler_libs_common: ............................ E:\ocamlmsvc32\lib\compiler-libs
    pkg_threads: ......................................... E:\ocamlmsvc32\lib
    pkg_camlp4: .......................................... E:\ocamlmsvc32\lib\camlp4
    pkg_camlp4_quotations_o: ............................. E:\ocamlmsvc32\lib\camlp4
    pkg_camlp4_extend: ................................... E:\ocamlmsvc32\lib\camlp4
    ocamldoc: ............................................ E:\ocamlmsvc32\bin\ocamldoc.EXE

    Administrator@WIN-UC9GUCLA8O0:/cygdrive/e/src/lwt-2.4.8$ make
    ./setup.exe -build
    mkdir 'E:\src\lwt-2.4.8_build'
    [...]
    ''E:/ocamlmsvc32/bin/ocamlfind.EXE ocamlopt -c -g -annot -bin-annot -safe-string -I src/core -I src/logger -I src/unix -I syntax -syntax camlp4o -syntax camlp4o -ppopt syntax/pa_lwt_options.cmo -ppopt syntax/pa_lwt.cmo -ppopt syntax/pa_lwt_log.cmo -package unix -package bytes -package bigarray -package camlp4.quotations.o -package camlp4.extend -package camlp4 -syntax camlp4o -I examples/unix -I src/unix -I syntax -o examples/unix/parallelize.cmx examples/unix/parallelize.ml
    ''E:/ocamlmsvc32/bin/ocamlfind.EXE ocamlopt -linkpkg -g -I src/unix -linkpkg -package unix -package bytes -package bigarray -package camlp4.quotations.o -package camlp4.extend -package camlp4 syntax/lwt-syntax.cmxa src/core/lwt.cmxa src/logger/lwt-log.cmxa src/unix/lwt-unix.cmxa examples/unix/parallelize.cmx -o examples/unix/parallelize.native
    Administrator@WIN-UC9GUCLA8O0:/cygdrive/e/src/lwt-2.4.8$
    (OK!)

    Administrator@WIN-UC9GUCLA8O0:/cygdrive/e/src/lwt-2.4.8$ ocaml setup.ml -configure --enable-tests
    [...]
    Administrator@WIN-UC9GUCLA8O0:/cygdrive/e/src/lwt-2.4.8$ make test
    [...]
    ./setup.exe -test
    Running 87 tests for library "core".
    Done. All tests succeeded.
    Running 6 tests for library "unix".
    Done. All tests succeeded.
    Running 1 tests for library "preemptive".
    Done. All tests succeeded.

    (just to check this is not mingw or cygwin library):
    Administrator@WIN-UC9GUCLA8O0:/cygdrive/e/src/lwt-2.4.8$ ldd _build/tests/preemptive/main.native
    ntdll.dll => /cygdrive/c/Windows/SYSTEM32/ntdll.dll (0x77dd0000)
    KERNEL32.DLL => /cygdrive/c/Windows/SYSTEM32/KERNEL32.DLL (0x77b40000)
    KERNELBASE.dll => /cygdrive/c/Windows/SYSTEM32/KERNELBASE.dll (0x76750000)
    WS2_32.dll => /cygdrive/c/Windows/SYSTEM32/WS2_32.dll (0x763f0000)
    MSVCR100.dll => /cygdrive/c/Windows/SYSTEM32/MSVCR100.dll (0x72320000)
    NSI.dll => /cygdrive/c/Windows/SYSTEM32/NSI.dll (0x76350000)
    RPCRT4.dll => /cygdrive/c/Windows/SYSTEM32/RPCRT4.dll (0x76820000)
    SspiCli.dll => /cygdrive/c/Windows/SYSTEM32/SspiCli.dll (0x757f0000)
    CRYPTBASE.dll => /cygdrive/c/Windows/SYSTEM32/CRYPTBASE.dll (0x757e0000)
    sechost.dll => /cygdrive/c/Windows/SYSTEM32/sechost.dll (0x77cc0000)
    bcryptPrimitives.dll => /cygdrive/c/Windows/SYSTEM32/bcryptPrimitives.dll (0x75780000)
    Administrator@WIN-UC9GUCLA8O0:/cygdrive/e/src/lwt-2.4.8$

  6. shayne-fletcher commented on Jan 7, 2016

    @shayne-fletcher
    Author

    ​Hi Evgenii,​

    On Thu, Jan 7, 2016 at 1:20 PM, Evgenii Lepikhin [email protected]
    wrote:

    Administrator@WIN-UC9GUCLA8O0:/cygdrive/e/src/lwt-2.4.8$ make
    ./setup.exe -build
    mkdir 'E:\src\lwt-2.4.8_build'
    [...]

    ​Thanks for this!

    What's been elided in the ellipses there is what needs closer examination.
    In my case, this happens,
    ​
    ​$ make
    ./setup.exe -build
    mkdir src
    mkdir src/core
    [... lots of good stuff...]
    ​
    ​ocamlfind.EXE ocamlc -g -ccopt -Isrc/unix -package unix -package bytes
    -package bigarray -c -o src/unix/lwt_unix_stubs.obj
    src/unix/lwt_unix_stubs.c

    This then generates warnings coming from cl.exe (msvc-12.0 64-bit by the
    way) ...
    cl : Command line warning D9035 : option 'o' has been deprecated and will
    be removed in a future release
    cl : Command line warning D9002 : ignoring unknown option '-g'

    and then later,
    ​
    ​** Fatal error: Cannot find file "src/unix/lwt_unix_stubs.obj"

    Exit code 2 while executing this command:

    ocamlfind.EXE ocamlmklib -o src/unix/lwt-unix_stubs ws2_32.lib
    src/unix/lwt_unix_stubs.obj src/unix/lwt_libev_stubs.obj
    src/unix/lwt_process_stubs.obj src/unix/jobs-unix/lwt_unix_job_access.obj
    src/unix/jobs-unix/lwt_unix_job_chdir.obj
    src/unix/jobs-unix/lwt_unix_job_chmod.obj
    src/unix/jobs-unix/lwt_unix_job_chown.obj
    src/unix/jobs-unix/lwt_unix_job_chroot.obj
    src/unix/jobs-unix/lwt_unix_job_close.obj
    src/unix/jobs-unix/lwt_unix_job_fchmod.obj
    src/unix/jobs-unix/lwt_unix_job_fchown.obj
    src/unix/jobs-unix/lwt_unix_job_fdatasync.obj
    src/unix/jobs-unix/lwt_unix_job_fsync.obj
    src/unix/jobs-unix/lwt_unix_job_ftruncate.obj
    src/unix/jobs-unix/lwt_unix_job_link.obj
    src/unix/jobs-unix/lwt_unix_job_lseek.obj
    src/unix/jobs-unix/lwt_unix_job_mkdir.obj
    src/unix/jobs-unix/lwt_unix_job_mkfifo.obj
    src/unix/jobs-unix/lwt_unix_job_rename.obj
    src/unix/jobs-unix/lwt_unix_job_rmdir.obj
    src/unix/jobs-unix/lwt_unix_job_symlink.obj
    src/unix/jobs-unix/lwt_unix_job_tcdrain.obj
    src/unix/jobs-unix/lwt_unix_job_tcflow.obj
    src/unix/jobs-unix/lwt_unix_job_tcflush.obj
    src/unix/jobs-unix/lwt_unix_job_tcsendbreak.obj
    src/unix/jobs-unix/lwt_unix_job_truncate.obj
    src/unix/jobs-unix/lwt_unix_job_unlink.obj​

    ​Indeed, ​I can find a _build/lwt_unix_stubs.obj but not an
    _build/src/unix/lwt_unix_stubs.obj so I conclude, for whatever reason, the
    binaries that are produced from C files are not getting generated into
    their intended destinations but I'm not clear on what exactly is to blame
    :-/​

    Shayne Fletcher

  7. gasche commented on Jan 7, 2016

    @gasche
    Contributor

    Note that @alainfrisch has just made an upstream commit to disable -g and replace -o by /Fo on MSVC: 2264004cb. This will be in 4.03.

  8. shayne-fletcher commented on Jan 7, 2016

    @shayne-fletcher
    Author

    On Thu, Jan 7, 2016 at 3:26 PM, Gabriel Scherer [email protected]
    wrote:

    Note that @alainfrisch https://github.com/alainfrisch has just made an
    upstream commit to disable -g and replace -o by /Fo on MSVC: 2264004cb
    ocaml/ocaml@2264004
    .

    ​That's a great candidate for what is going wrong here. I haven't yet had
    the opportunity to investigate it by hand but it's been the front-runner in
    my mind as being the cause.

    Shayne Fletcher

  9. gasche commented on Jan 7, 2016

    @gasche
    Contributor

    Indeed, if -o foo/bar.obj is ignored, then bar.obj can end up in the wrong directory.

  10. shayne-fletcher commented on Jan 7, 2016

    @shayne-fletcher
    Author

    On Thu, Jan 7, 2016 at 3:31 PM, Gabriel Scherer [email protected]
    wrote:

    Indeed, if -o foo/bar.obj is ignored, then bar.obj can end up in the
    wrong directory.

    ​And of course, it's still theory but the fact that I'm exercising msvc-12
    (and assume that point is different from other's successful builds​ in the
    past indicating a change in behavior between cl versions), it would explain
    why it exhibits here and not for Evengii. Not impossible for me to confirm
    these suspicions - I'll try to report back on that in the next couple of
    days. That said, the observations and reasoning clearly tie up with high
    probability.

    Shayne Fletcher

  11. gasche commented on Jan 7, 2016

    @gasche
    Contributor

    I would guess that it should not be too hard to backport Alain's change on top of 4.02, build a local switch for this modified version (for example using opam-compiler-conf), and see whether the build works then.

  12. shayne-fletcher commented on Jan 26, 2016

    @shayne-fletcher
    Author

    Happy to report back that I got a build thanks to Alain's change, I got a build of lwt-2.5.1 with msvc-14 :)

    An attempt to build from trunk however seems to have introduced new complications for Windows:

      ocamlfind: Package `oasis.dynrun' not found
      ocamlfind: Package `oasis.dynrun' not found
    

    Anyone know of a resolution for that?

  13. aantron commented on Sep 17, 2016

    @aantron
    Collaborator

    @shayne-fletcher building development versions of Lwt requires OASIS, so you should install that first. Does the problem persist?

  14. shayne-fletcher commented on Sep 19, 2016

    @shayne-fletcher
    Author

    As I recall, the dependency on OASIS led to dependencies on a plethora of other libraries (in order to build OASIS). That quickly turned into a rabbit hole we couldn't see the bottom of and so ended up having to be satisfied with lwt-2.5.1. So sadly, without revisiting that work to re-confirm, the problem (for us), continues to exist.

  15. Drup commented on Sep 20, 2016

    @Drup
    Member

    @shayne-fletcher OASIS is not a built time dependency. If using dev oasis is critical to you, just run oasis setup somewhere easier, mirror that, and use it to install on windows.

  16. shayne-fletcher commented on Sep 21, 2016

    @shayne-fletcher
    Author

    I'll put this back on my stack and report back shortly.

  17. modified the milestone: 2.7.0 on Nov 19, 2016
  18. modified the milestone: 2.7.0 on Dec 22, 2016
  19. aantron commented on May 30, 2017

    @aantron
    Collaborator

    I likewise had problems with the dependencies of OASIS while setting up CI on MSVC; see branches ci-msvc and oasis-free-build. This may be resolved by the jbuilder port in #374. I'll try to set up CI on MSVC again some time after that is merged.

  20. aantron commented on Jun 12, 2017

    @aantron
    Collaborator

    Now that Lwt is ported to jbuilder, I think we need to try building on MSVC, and try to set up CI for it. @shayne-fletcher, could you try pinning Lwt to master and seeing if the development build works now?

  21. aantron commented on Apr 18, 2018

    @aantron
    Collaborator

    Closing due to needed feedback. Please reopen if necessary :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions