caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Multi-threaded programs using MinGW x-compiler
@ 2010-05-24  1:39 Paul Steckler
  2010-05-24 10:03 ` Richard W.M. Jones
  2010-05-24 12:22 ` [Caml-list] " Török Edwin
  0 siblings, 2 replies; 3+ messages in thread
From: Paul Steckler @ 2010-05-24  1:39 UTC (permalink / raw)
  To: caml-list; +Cc: rjones

Has anyone gotten an OCaml multithreaded program to build for Win32 native threads using the
MinGW ocaml cross-compiler?

At least with the Fedora distribution of that compiler, there's a libthreadsnat.a, but it's
missing some symbols.  The source for that library assumes the availability of pthreads
and Unix-style signals on the target.  There is a pthreads library for MingGW, but there
isn't a complete emulation of signals on Windows.  So I think another approach is needed.

Maybe the cross-compiler can instead generate calls to the procedures in the native threads
library that's distributed with the Windows version of OCaml.  That library would have
to be converted, somehow, from the .lib format to the .a format.

-- Paul
--
Paul Steckler
National ICT Australia
paul DOT steckler AT nicta.com.au

The information in this e-mail may be confidential and subject to legal professional privilege and/or copyright. National ICT Australia Limited accepts no liability for any damage caused by this email or its attachments.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Multi-threaded programs using MinGW x-compiler
  2010-05-24  1:39 Multi-threaded programs using MinGW x-compiler Paul Steckler
@ 2010-05-24 10:03 ` Richard W.M. Jones
  2010-05-24 12:22 ` [Caml-list] " Török Edwin
  1 sibling, 0 replies; 3+ messages in thread
From: Richard W.M. Jones @ 2010-05-24 10:03 UTC (permalink / raw)
  To: Paul Steckler; +Cc: caml-list

On Mon, May 24, 2010 at 11:39:07AM +1000, Paul Steckler wrote:
> At least with the Fedora distribution of that compiler, there's a
> libthreadsnat.a, but it's missing some symbols.  The source for that
> library assumes the availability of pthreads and Unix-style signals
> on the target.  There is a pthreads library for MingGW, but there
> isn't a complete emulation of signals on Windows.  So I think
> another approach is needed.

Likely what's happening here is the configure script that we run
(under Fedora of course) is detecting pthreads.  We go through various
hoops to modify the output of the configure script to suite Windows
defaults, since the upstream configure script knows nothing about
cross-compilation.  However we probably didn't adjust the threading
model, because I tend to avoid threads, and in any case this cross-
compiler was more of a technology demonstration than something you'd
necessarily want to use regularly.

The real solution is to get the changes we've already made upstream,
and get the upstream configure script to understand cross-compilation
properly (especially that sizeof(int) on the host != sizeof(int) on
the target).

This is a lot of work, and I don't have the time now, what with the
RHEL 6 crunch happening.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
libguestfs lets you edit virtual machines.  Supports shell scripting,
bindings from many languages.  http://et.redhat.com/~rjones/libguestfs/
See what it can do: http://et.redhat.com/~rjones/libguestfs/recipes.html


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] Multi-threaded programs using MinGW x-compiler
  2010-05-24  1:39 Multi-threaded programs using MinGW x-compiler Paul Steckler
  2010-05-24 10:03 ` Richard W.M. Jones
@ 2010-05-24 12:22 ` Török Edwin
  1 sibling, 0 replies; 3+ messages in thread
From: Török Edwin @ 2010-05-24 12:22 UTC (permalink / raw)
  To: caml-list

On 2010-05-24 04:39, Paul Steckler wrote:
> Has anyone gotten an OCaml multithreaded program to build for Win32 native threads using the
> MinGW ocaml cross-compiler?

I'm not a windows user, but I tried with Debian's mingw32-ocaml package
and wine: it seems to work. I don't know if it uses native threads or
not, but it does import CreateThread.

Here is what I did:
$ cat >x.ml <<EOF
let f_proc1 () = for i=0 to 10 do Printf.printf "(%d)" i; flush stdout done;
                  print_newline() ;;
let t1 = Thread.create f_proc1 () ;;
Thread.join t1 ;;
EOF
$ i586-mingw32msvc-ocamlopt -thread unix.cmxa threads.cmxa  x.ml
$ WINEDEBUG=-all wine camlprog.exe
(0)(1)(2)(3)(4)(5)(6)(7)(8)(9)(10)
$ i586-mingw32msvc-nm camlprog.exe |grep Thread
0042da60 T _CreateThread@24
0042daa0 T _GetCurrentThread@0
0044f3b4 I __imp__CreateThread@24
0044f3e0 I __imp__GetCurrentThread@0
0042ec9c D _camlThread
0042ef98 D _camlThreadUnix
....

Best regards,
--Edwin


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-05-24 12:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-24  1:39 Multi-threaded programs using MinGW x-compiler Paul Steckler
2010-05-24 10:03 ` Richard W.M. Jones
2010-05-24 12:22 ` [Caml-list] " Török Edwin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).