[Unison-hackers] Unison 2.48 won't build in Cygwin

Chris Prince chris.prince at gmail.com
Thu Jun 4 13:02:06 EDT 2015


I went through the same pain of building 2.48 for Windows a couple months
ago.  And what a struggle it was!

For various reasons, I ended up using my build that wasn't reliant on
Cygwin's DLL, but I did get it working both ways.

I only have my notes for building the non-DLL version (see below).  But I
believe the same changes allowed me to build the Cygwin version using
simply "make clean && make UISTYLE=text".  (You should perhaps omit the
OSARCH=win32 below, I don't remember for sure.)

Windows build instructions for Unison 2.48.3:
* Install the Protz version of OCaml. (
http://protz.github.io/ocaml-installer/)
    - If planning cross-platform use, be warned that apps built using OCaml
4.01 and 4.02 are binary incompatible!
* Start a Cygwin shell (even when not linking against the Cygwin DLL).
* Update PATH so that the Protz /bin dir is first.
* 'cd' into the Unison source directory.
* Edit Makefile.OCaml to use "-Fo" instead of "/Fo".
* export OSARCH=win32
* make clean && make UISTYLE=text STATIC=false
    - Need STATIC=false because STATIC=true passes unrecognized "-static"
argument to OCaml's 'flexdll'.
* Upon link error, change the failed 'ocamlopt' command line as follows,
and run manually:
    - REMOVE this trailing part:  -cclib "-link [...].res" shell32.lib
    - FIX .obj filenames:  change ".obj" to ".o" and remove any DIR/
prefixes from those files

Hope this helps.

--Chris


On Wed, Jun 3, 2015 at 3:37 AM, Andrew Schulman <andrex at utexas.edu> wrote:

> For years I've been able to build Unison in Cygwin, by applying this small
> patch:
>
> diff -urN a/Makefile.OCaml b/Makefile.OCaml
> --- a/Makefile.OCaml  2012-09-21 08:42:17.000000000 -0400
> +++ b/Makefile.OCaml  2013-11-27 11:31:12.392086500 -0500
> @@ -122,8 +122,7 @@
>    ifeq ($(OSARCH),win32gnuc)
>      CWD=.
>      EXEC_EXT=.exe
> -    COBJS+=system/system_win_stubs$(OBJ_EXT) lwt/lwt_unix_stubs$(OBJ_EXT)
> -    WINOBJS=system/system_win.cmo
> +    WINOBJS=
>      SYSTEM=win
>      CLIBS+=-cclib win32rc/unison.res.lib
>      STATIC=false                      # Cygwin is not MinGW :-(
>
> and running
>
>   make OSCOMP=cygwingnuc SYSTEM=generic UISTYLE=text
>
> That worked up through version 2.45.28.  Beginning with 2.47.4, the build
> fails
> on lwt/win/lwt_unix_impl.ml:
>
>
> ocamlopt: lwt/win/lwt_unix_impl.ml ---> lwt/win/lwt_unix_impl.cmx
> ocamlopt -g -I lwt -I ubase -I system -I fsmonitor -I fsmonitor/linux -I
> fsmonitor/windows -I system/generic -I lwt/generic -c ./lwt/win/
> lwt_unix_impl.ml
> File "./lwt/win/lwt_unix_impl.ml", line 655, characters 35-57:
> Error: Unbound module System_impl.Fs.W
> Makefile.OCaml:429: recipe for target 'lwt/win/lwt_unix_impl.cmx' failed
> make: *** [lwt/win/lwt_unix_impl.cmx] Error 2
>
>
> If I don't apply the patch, the build fails on system/system_win_stubs.c:
>
>
> ocamlopt: system/system_win_stubs.c ---> system/system_win_stubs.o
> ocamlopt -g -I lwt -I ubase -I system -I fsmonitor -I fsmonitor/linux -I
> fsmonitor/windows -I system/generic -I lwt/generic -ccopt "-o
> "./system/system_win_stubs.o -c ./system/system_win_stubs.c
> ./system/system_win_stubs.c:19:5: error: unknown type name
> \u2018SOCKET\u2019
>      SOCKET socket;
>      ^
> ./system/system_win_stubs.c: In function \u2018copy_wstring\u2019:
> ./system/system_win_stubs.c:31:3: warning: implicit declaration of function
> \u2018wcslen\u2019 [-Wimplicit-function-declaration]
>    len = 2 * wcslen(s) + 2;  /* NULL character included */
>    ^
> ./system/system_win_stubs.c: In function \u2018win_chmod\u2019:
> ./system/system_win_stubs.c:129:23: error: \u2018_S_IWRITE\u2019 undeclared
> (first use in this function)
>    if (Int_val(perm) & _S_IWRITE)
>                        ^
> ./system/system_win_stubs.c:129:23: note: each undeclared identifier is
> reported
> only once for each function it appears in
> ./system/system_win_stubs.c: In function
> \u2018w_create_process_native\u2019:
> ./system/system_win_stubs.c:453:10: warning: unused variable \u2018h\u2019
> [-Wunused-variable]
>    HANDLE h;
>           ^
> Makefile.OCaml:434: recipe for target 'system/system_win_stubs.o' failed
> make: *** [system/system_win_stubs.o] Error 2
>
>
> I've tried this with various combinations of OSCOMP and SYSTEM, without
> success.
> I confess that I don't know exactly what effect each of those variables
> has.
>
> I think that a lot of the Cygwin-related logic in Makefile.OCaml is way
> out of
> date.  For example, the logic for OSARCH=win32 seems to be obsolete since
> it
> refers only to beta versions of Cygwin that are 10 years old.
>
> Can anyone suggest a fix so that Unison will compile in Cygwin again?
>
> Thanks,
> Andrew
>
> _______________________________________________
> Unison-hackers mailing list
> Unison-hackers at lists.seas.upenn.edu
> http://lists.seas.upenn.edu/mailman/listinfo/unison-hackers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.seas.upenn.edu/pipermail/unison-hackers/attachments/20150604/bf87e734/attachment-0001.html>


More information about the Unison-hackers mailing list