Version française
Home     About     Download     Resources     Contact us    
Browse thread
effect of -thread with ocamlc/ocamlopt -c
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jonathan Roewen <jonathan.roewen@g...>
Subject: Re: [Caml-list] effect of -thread with ocamlc/ocamlopt -c
Oh wait, I'm sorry. Yes, there is good reason: it uses a different
version of Pervasives internals.

Depending on when linking is done for each part, you may end up with
conflicting implementations of Pervasives in your final program: so
[IO] operations that can block will block whole program instead of
running thread blocking, and another thread running instead.

So maybe if it uses no IO, and no threading functions, it might be
okay -- there are no guarantees when you do these sorts of things (:

Jonathan

On 9/13/06, Trevor Jim <trevor@research.att.com> wrote:
> I have a question about the effect of -thread when used
> with ocamlc/ocamlopt -c.
>
> The manual states:
>
>   All object files on the command line must also have been compiled
>   with the -thread option
>
> However, in compiling a large number of files I have not yet found a
> case where -thread made a difference in the output of ocamlc or
> ocamlopt (provided of course that module Thread is not used).  In
> other words, the binary output is identical.
>
> So, in general, can I take a .cmo or .cmx file that was NOT compiled
> with -thread and link it with the threads library threads.cma or
> threads.cmxa?
>
> And, in general, can I take a .cmo or .cmx file that WAS compiled with
> -thread but which does not use module Thread, and link it into a
> program without the threads library?
>
>
> Here's why this matters to me.  I have a large app (galax, with 300+
> modules) that started out unthreaded.  I have added a threaded server,
> which extends the app with one file that uses the Thread module.  So I
> have a server that needs to be threaded, plus all the old programs
> (galax compiler, etc.) that don't need to be threaded.  Linking in the
> threads library causes the programs that don't use or need threads to
> slow down by 2-30 times.
>
> Since the program is so large, I would prefer not to have to compile
> each module twice, once with threads and once without.
>
> Also, it relies on a large number of libraries.  I don't want to have
> to have two versions of each library.
>
> But the manual seems to imply that I need to do that.
>
> -Trevor
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>