From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id WAA23583 for caml-red; Sat, 30 Dec 2000 22:38:54 +0100 (MET) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id SAA15739 for ; Thu, 28 Dec 2000 18:24:06 +0100 (MET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id eBSHO5f29781; Thu, 28 Dec 2000 18:24:05 +0100 (MET) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA08211; Thu, 28 Dec 2000 18:24:04 +0100 (MET) Date: Thu, 28 Dec 2000 18:24:04 +0100 From: Xavier Leroy To: Alain Frisch Cc: caml-list@inria.fr Subject: Re: Using primitives from dl libs Message-ID: <20001228182404.B20636@pauillac.inria.fr> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: ; from frisch@clipper.ens.fr on Tue, Dec 26, 2000 at 06:10:59PM +0100 Sender: weis@pauillac.inria.fr > [Dynamic loading of C libraries implementing OCaml external functions] > Yet, I am not satisfied with my solution. Putting an explicit > filename for the library in the source file is ugly for obvious reasons. > Also, the decision to use dl for a specific library should be made during > the linking phase, or best, at runtime: if the bytecode interpreter > does not own a primitive, it searchs it in a shared lib. Yes, I agree it should work this way. > The problem is: in which library should it search ? I try to avoid > the primitive database. A solution is to provide this > information to ocamlrun via the command line (ocamlrun will > look up each primitive in every specified shared library). The solution I considered (but never had the fortitude to implement) is to have an extra section in the bytecode executable listing the shared libraries needed by the executable, i.e. all shared libraries given to the OCaml linker with -cclib. This section would contain short file names (e.g. libunix.so, not /usr/local/lib/ocaml/libunix.so), and the bytecode interpreter would search the corresponding .so files in a number of standard directories (the directory containing the executable + the OCaml standard library directory + the directories searched by the system dynamic loader, for instance). Then, the bytecode interpreter would dlopen() these libraries, and dlsym() them all for each primitive. I'm still not sure how to handle dynamic libraries that do not reside in a standard directory. We could have ocamlrun options or environment variables (similar to LD_LIBRARY_PATH) to specify other directories to search, but this isn't very nice. Perhaps there should be a file (in the stdlib directory) listing the directories to search, a la /etc/ld.so.conf. - Xavier Leroy