English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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: 2006-09-12 (21:29)
From: Jonathan Roewen <jonathan.roewen@g...>
Subject: Re: [Caml-list] effect of -thread with ocamlc/ocamlopt -c
> The manual states:
>   All object files on the command line must also have been compiled
>   with the -thread option

In current compiler version, all the -thread option does is add the
include directory for threads to the include path automatically, and
set -nopervasives I think (so that it uses the version provided by the
thread library)..

Although, depending on the behaviour of compiler internals isn't
always a good thing ;-)

> 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?

Maybe (for example, the standard library doesn't have a special
compiled version for thread mode) -- just IO I'd be concerned about
wrt runtime behaviour.

> 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?

Most likely yes. But again, you're depending on compiler internals.

> 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.

Without official comment from the ocaml team, expect upgrading to
newer ocaml releases to break things. Otherwise, should work for now.