caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Philippe Wang <philippe.wang@lip6.fr>
To: Julien Signoles <julien.signoles@gmail.com>
Cc: Philippe Wang <philippe.wang@lip6.fr>, caml-list@inria.fr
Subject: Re: [Caml-list] ocamlclean : an OCaml bytecode cleaner (Was: (Announce) "OCAPIC" : OCaml for PIC18 microcontrollers)
Date: Thu, 11 Nov 2010 12:57:54 +0100	[thread overview]
Message-ID: <283988DF-2604-4407-A6DB-4F2BA6F0FF62@lip6.fr> (raw)
In-Reply-To: <AANLkTi=z+-GA4G1H6v1fDSSzi5AcWWQo2b1v2Gp1wQO-@mail.gmail.com>

Hello,

ocamlclean removes code to which there is no possible path. For instance, this program :
  let plop = List.map succ [1;2;3];;
uses module List (for map) and module Pervasives (for succ) but doesn't use a lot of functions of List or Pervasives (e.g., List.iter, List.fold_left, Pervasives.print_endline). So most functions of modules Pervasives and List are removed from the bytecode executable.

If one dynamically loads some bytecode, for instance the previous program becomes
  let plop = List.map succ [1;2;3];;
  let _ = Dynlink.load "stuff.cmo";;
then stuff.cmo should not reference anything that may not exist, such as Pervasives.(@) since it has been removed by ocamlclean. And we are not supposed to know at compile-time what stuff.cmo needs from stdlib. Hence I guess everything should be kept and ocamlclean not used.

On the other hand, if we statically know what is in stuff.cmo, then why load it dynamically? (I guess the answer can be "just for fun" but I'm not so sure it's such a good answer :-)

Though, I'm not very familiar with Dynlink, and I'm not sure what "Dynlink.allow_only" really does...

I haven't tested using dynlink to load a self-sufficient module. I might work, but I don't really see how it can be usefull anyway...

Cheers,
Philippe Wang

On Nov 11, 2010, at 06:52 AM, Julien Signoles wrote:

> Hello,
> Is ocamlclean compatible with dynamic loading? That is code potentially used by some unknown dynamically-loaded code must be kept.
> --
> Julien


      reply	other threads:[~2010-11-11 11:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <951AD91B-DA92-4F92-AE90-86A13DDB2357@lip6.fr>
2010-11-04 21:44 ` (Announce) "OCAPIC" : OCaml for PIC18 microcontrollers Philippe Wang
2010-11-05 12:35   ` [Caml-list] " Daniel Bünzli
2010-11-05 14:26     ` Philippe Wang
2010-11-06 17:47   ` Goswin von Brederlow
2010-11-06 19:19     ` Philippe Wang
2010-11-11  1:09       ` ocamlclean : an OCaml bytecode cleaner (Was: (Announce) "OCAPIC" : OCaml for PIC18 microcontrollers) Philippe Wang
2010-11-11  5:52         ` [Caml-list] " Julien Signoles
2010-11-11 11:57           ` Philippe Wang [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=283988DF-2604-4407-A6DB-4F2BA6F0FF62@lip6.fr \
    --to=philippe.wang@lip6.fr \
    --cc=caml-list@inria.fr \
    --cc=julien.signoles@gmail.com \
    /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).