caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Alain Frisch <frisch@clipper.ens.fr>
To: caml-list@inria.fr
Subject: Using primitives from dl libs
Date: Tue, 26 Dec 2000 18:10:59 +0100 (MET)	[thread overview]
Message-ID: <Pine.GSO.4.04.10012261726040.21454-100000@clipper.ens.fr> (raw)

Hello,

a few months ago, Nicolas George posted to this mailing list a patch
to allow using external (C) primitives without building a custom
runtime system (ocamlrun):
http://caml.inria.fr/archives/200004/msg00104.html

I am working on a similar solution. My approach is to add a new kind
of dynamically linked primitive declaration in the source code. For
instance:

external test : unit -> unit = "/home/frisch/caml/dl/test.so/ml_test"

ml_test is a C function defined in test.c (compiled to test.o then
converted to test.so with ld -shared).

Technically, I add a new section in the bytecode file listing the
primitives with a / in their name. The modified ocamlrun "dlopens"
the corresponding libraries at runtime. The patch (to the bytecode linker
and to ocamlrun) is really small.

Compared to Nicolas's solution, the advantage is to get rid of
the "primitive database" (a separate file indicating where to find
each primitive). Also, it is still possible to use statically linked
libraries.

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.

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

Any suggestion about this design ?

-- 
  Alain Frisch



             reply	other threads:[~2000-12-26 20:33 UTC|newest]

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

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=Pine.GSO.4.04.10012261726040.21454-100000@clipper.ens.fr \
    --to=frisch@clipper.ens.fr \
    --cc=caml-list@inria.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).