Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Xavier Leroy <xavier.leroy@inria.fr>
To: Claudio Sacerdoti Coen <sacerdot@cs.unibo.it>
Cc: OCAML <caml-list@inria.fr>
Subject: Re: [Caml-list] Unused .cma and .so
Date: Fri, 26 Apr 2002 10:16:47 +0200	[thread overview]
Message-ID: <20020426101646.A24598@pauillac.inria.fr> (raw)
In-Reply-To: <20020415192121.A11023@cs.unibo.it>; from sacerdot@cs.unibo.it on Mon, Apr 15, 2002 at 07:21:21PM +0200

>  I used to think that linking a .cma when no module inside it is required
>  is completely hurtless. I was wrong: it seems that .so added during linking
>  of those .cma are loaded. To me, this seems a feature with a
>  counter-intuitive semantics.
>  Is there any way to disable this behaviour?

No, because it is actually necessary.

External functions declared in .mli files are expanded inline into
client code.  For instance, if we have a module A with signature

        external f : ... = "my_f"
        val g : ...

references to A.f in client code are expanded inline into C calls to "my_f",
while references to A.g leave an explicit reference to A in client code.

Now, assume that we have a.cma composed of the module A above and of
a C library dlla.so defining my_f.  If the client code never references A.g,
the linker will correctly discard the Caml code for A.  However, it
must link dlla.so so that inlined references to "my_f" are satisfied.  

If you're linking with ocamlopt or ocamlc -custom, the C linker will
be passed liba.a and will actually discard it if there are no
references to my_f.  But doing the same thing with the pure bytecode
compiler ocamlc is very hard: there is no standard API to examine
the dependencies of DLLs, and the C part of a library can reference
directly functions form the C part of another library.

- Xavier Leroy
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


  parent reply	other threads:[~2002-04-26  8:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-15 17:21 Claudio Sacerdoti Coen
2002-04-15 17:49 ` Warp
2002-04-16  7:49   ` Claudio Sacerdoti Coen
2002-04-26  8:16 ` Xavier Leroy [this message]
2002-04-26 10:57   ` Claudio Sacerdoti Coen

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=20020426101646.A24598@pauillac.inria.fr \
    --to=xavier.leroy@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=sacerdot@cs.unibo.it \
    /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