caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Xavier Leroy <Xavier.Leroy@inria.fr>
To: Alain Frisch <frisch@clipper.ens.fr>
Cc: caml-list@inria.fr
Subject: Re: Using primitives from dl libs
Date: Thu, 28 Dec 2000 18:24:04 +0100	[thread overview]
Message-ID: <20001228182404.B20636@pauillac.inria.fr> (raw)
In-Reply-To: <Pine.GSO.4.04.10012261726040.21454-100000@clipper.ens.fr>; from frisch@clipper.ens.fr on Tue, Dec 26, 2000 at 06:10:59PM +0100

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



      reply	other threads:[~2000-12-30 21:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-12-26 17:10 Alain Frisch
2000-12-28 17:24 ` Xavier Leroy [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20001228182404.B20636@pauillac.inria.fr \
    --to=xavier.leroy@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=frisch@clipper.ens.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).