setup-ocaml
setup-ocaml copied to clipboard
Compile msvc64 variant but pick a specific compiler
Hello,
I need to get an OCaml version (I am not picky here, any version can make it) which would be compiled with the same msvc64 as the current Python version selected in my GitHub Actions. The msvc64c version (almost) doesn't break right away, before flexlink fails reading object files compiled with the msvc64 used by Python.
To put some context, I am compiling a Python library wrapped around an OCaml library, I have been doing quite some manual processing in the past to get it done with Windows, so I know it ends up working, but the challenge now is to get it functional in GitHub Actions.
What would be the proper way to setup the environment before the ./configure script is run? It is actually a bit hard to find the compiler, but it seems it is here for Python 3.9:
'C:\\Program\ Files\ (x86)\\Microsoft\ Visual\ Studio\\2019\\Enterprise\\VC\\Tools\\MSVC\\14.29.30037\\bin\\HostX86\\x64\\cl.exe'
I don't know what version of Visual Studio msvc64c is compiled with in opam-repository-mingw, but if you use the msvc64 variant then it will rebuild OCaml from sources (slower, but it will definitely match).
Are you already wrapping the calls with ocaml-env? That approach is likely to change in the coming months - an alternative would be to call the appropriate vcvars script before calling configure (for example, C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.bat - I'm not sure exactly which versions are in the GitHub Actions runner).
Thank you for your update.
My recipe is here and I debug as I with a tmate shell. My setup-ocaml specification is here:
- name: Use OCaml for Windows
uses: ocaml/setup-ocaml@v2
if: ${{ matrix.os == 'windows-latest' }}
with:
ocaml-compiler: ocaml-variants.4.12.0+msvc64
opam-depext: false
I found the vcvarsall.bat there, but what would be the proper way to use configure the step and specify this vcvarsall.bat before? In debug mode, with Python 3.9, I found cmd vcvarsall.bat x86_amd64 14.29.30037 (from the proper folder) seems to trigger the compilation without error. I need to find the way to integrate it in the .yml.
Or maybe I should just install any compiler first, then build another one in the shell I specify later with msvc64? (sounds overkill)
Found this: https://github.com/ilammy/msvc-dev-cmd (but compilation fails, will try further later...)