fdopen / opam-repository-mingw

windows package repository for OPAM (mingw and msvc)
https://fdopen.github.io/opam-repository-mingw/
Creative Commons Zero v1.0 Universal
96 stars 34 forks source link

Weird issue with cygwin linking or something related #39

Closed anmaped closed 7 years ago

anmaped commented 7 years ago

I want to describe here a weird issue that I have when compiling z3 bindings for ocaml 4.03.0 using both 64bit and 32bit version of cygwin.

The issue was started here https://github.com/Z3Prover/z3/issues/1230.

$ ./ml_example
      3 [main] ml_example 340 child_copy: cygheap read copy failed, 0x612E8408..0x612F35E4, done 0, windows pid 340, Win32 error 6
    801 [main] ml_example 340 C:\Users\anmap\Desktop\test\ml_example.exe: *** fatal error - ccalloc would have returned NULL
fdopen commented 7 years ago

No idea about cygwin. The whole cygwin based OCaml toolchain is bitrotten, because it's not widely used.

But the mingw toolchains works for me:

eval $(ocaml-env cygwin)
CXX=x86_64-w64-mingw32-g++ CC=x86_64-w64-mingw32-gcc AR=x86_64-w64-mingw32-ar python scripts/mk_make.py --ml --prefix=$(cygpath -m /usr/x86_64-w64-mingw32/sys-root/mingw)
cd build
make -j8
make install
mv /usr/x86_64-w64-mingw32/sys-root/mingw/lib/libz3.dll /usr/x86_64-w64-mingw32/sys-root/mingw/bin # installed to the wrong location
install -m 0644 libz3.dll.a /usr/x86_64-w64-mingw32/sys-root/mingw/lib # not installed at all !
cd ../examples/ml
ocamlfind ocamlopt -o ml_example.exe -package Z3 -linkpkg ml_example.ml
./ml_example.exe
# long output, but at the end:
# Test passed.
# Disposing...
# Exiting.

The install instructions are incomplete and wrong, but the OCaml related parts seem to work as expected

I've also tried to fix the installer. The call to cygwin's mkpasswd is now avoided whenever possible and if not, /etc/passwd is configured only for the current user. So it hopefully won't download all users account data and it won't trigger the mentioned bug. But because cygwin is a rolling release and there are zillions of different Windows version and installation options, it might still not work or stop working again in the future. Users with special environments can still follow the manual installation instructions.

anmaped commented 7 years ago

@fdopen It's it 👍 Done. We need to use mingw instead of cygwin.

Regarding the installer bug, thank you very much.