From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=AWL,DNS_FROM_RFC_ABUSE autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id A40E5BB83 for ; Wed, 13 Sep 2006 18:32:03 +0200 (CEST) Received: from rabbit.math.nagoya-u.ac.jp (rabbit.math.nagoya-u.ac.jp [133.6.130.5]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id k8DGW13T007246 for ; Wed, 13 Sep 2006 18:32:02 +0200 Received: from localhost (moose-172 [172.16.254.3]) by rabbit.math.nagoya-u.ac.jp (8.12.11/3.7W) with ESMTP id k8DGVgF2012805; Thu, 14 Sep 2006 01:31:42 +0900 (JST) Date: Thu, 14 Sep 2006 01:34:33 +0900 (JST) Message-Id: <20060914.013432.41630933.garrigue@math.nagoya-u.ac.jp> To: trevor@research.att.com Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] effect of -thread with ocamlc/ocamlopt -c From: Jacques Garrigue In-Reply-To: <45081CC0.8010004@research.att.com> References: <4506E954.8080207@research.att.com> <45081CC0.8010004@research.att.com> X-Mailer: Mew version 4.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Miltered: at discorde with ID 45083281.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; -thread:01 ocamlc:01 ocamlopt:01 threads:01 threads:01 -thread:01 pervasives:01 unix:01 iirc:01 pervasives:01 -trevor:01 internals:01 threading:01 wrote:01 marshal:01 The question is a bit different depending on whether you use system threads or vmthreads. Note that if your platform supports system threads, they are the ones used with the -thread option, while on platforms without them -thread and -vmthread are equivalent. For system threads, the standard library is unchanged, and you don't need the -thread option for modules that don't use threads. So there is no problem. For vm threads, some modules from the standard library have different implementations (namely, Pervasives, Marshal and Unix). So it is essential that you use the -thread option to link with them. Note however that the interfaces being identical, again you don't need -thread for unrelated modules, so that in practice you shouldn't see any difference with system threads. IIRC, at some point in the past some modified functions were defined as external in the standard library, making interfaces different, so that using -thread everywhere was a strict requirement. Jacques Garrigue From: Trevor Jim > Well, I'm still confused. Consider that a bunch of the standard > libraries use Pervasives, but I can see that the standard library > is not compiled with -thread. So clearly we are meant to use the > standard library compiled without -thread, with threads.cm[x]a. > > So, I still don't understand when I can combine code compiled > without -thread with code compiled with -thread. > > -Trevor > > Jonathan Roewen wrote: > > 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