[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#564816: libpostgresql-ocaml-dev: Monothreaded toplevel requires module Mutex.



Am Dienstag, den 12.01.2010, 08:57 +0100 schrieb Stéphane Glondu:
> severity 564816 normal
> tags 564816 + upstream
> thanks
> 
> Guillaume Yziquel a écrit :
> > META file seems incorrect. Here's a toplevel session with findlib:
> > [...]
> > # #require "postgresql";;
> > /usr/lib/ocaml/unix.cma: loaded
> > /usr/lib/ocaml/postgresql: added to search path
> > # #require "postgresql";;/postgresql.cma: loaded
> > Error: Reference to undefined global `Mutex'
> 
> I think this is quite common for libraries depending on threads. I guess
> this is because there are multiple implementation of them, so they are
> always explicitly given (on command line, at least).

No, the reason is that the bytecode threading implementation is partly
done within the standard library, and if you say -vmthread a different
version of the standard library is loaded. For native threads this would
not be necessary, but I think ocaml does it the same way (requiring the
switch -thread) for symmetry with the bytecode case.

The existence of these switches (-vmthread, -thread) extends to findlib
in so far multi-threading is handled specially, and you cannot simply
create a dependency on threads.{cma,cmxa}.

> Sure, there is not much choice in the toplevel so I guess we could tweak
> the META file so that #require "postgresql;;" works out of the box. For
> example, we could just load an additional module that would do
> "#thread;;" inside a toplevel. I'm not sure this is the idiomatic way,
> though, nor do I know the guidelines for this.

No, the idiomatic way is to signal an error when the library is loaded
without having enabled threads beforehand:

error(-mt) = "This library requires multi-threading support"

(read: if multi-threading is not enabled, fail with this error message)

Gerd
-- 
------------------------------------------------------------
Gerd Stolpmann, Bad Nauheimer Str.3, 64289 Darmstadt,Germany 
gerd@gerd-stolpmann.de          http://www.gerd-stolpmann.de
Phone: +49-6151-153855                  Fax: +49-6151-997714
------------------------------------------------------------




Reply to: