From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id AE9CEBBAF for ; Thu, 11 Nov 2010 12:57:57 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AloEAFNp20yE4zwegWdsb2JhbACiQRUBARYiIsA2hUoEiliDCw X-IronPort-AV: E=Sophos;i="4.59,182,1288566000"; d="scan'208";a="86775832" Received: from osiris.lip6.fr ([132.227.60.30]) by mail1-smtp-roc.national.inria.fr with ESMTP; 11 Nov 2010 12:57:57 +0100 Received: from tibre.lip6.fr (tibre.lip6.fr [132.227.74.2]) by osiris.lip6.fr (8.14.4/lip6) with ESMTP id oABBvukE008978 ; Thu, 11 Nov 2010 12:57:56 +0100 (CET) X-pt: osiris.lip6.fr Received: from [127.0.0.1] (postepwang [132.227.83.184]) by tibre.lip6.fr (8.14.4/8.13.3) with ESMTP id oABBvsZs028427; Thu, 11 Nov 2010 12:57:54 +0100 (MET) Subject: Re: [Caml-list] ocamlclean : an OCaml bytecode cleaner (Was: (Announce) "OCAPIC" : OCaml for PIC18 microcontrollers) Mime-Version: 1.0 (Apple Message framework v1081) Content-Type: text/plain; charset=us-ascii From: Philippe Wang In-Reply-To: Date: Thu, 11 Nov 2010 12:57:54 +0100 Cc: Philippe Wang , caml-list@inria.fr Content-Transfer-Encoding: quoted-printable Message-Id: <283988DF-2604-4407-A6DB-4F2BA6F0FF62@lip6.fr> References: <951AD91B-DA92-4F92-AE90-86A13DDB2357@lip6.fr> <87wroqpcny.fsf@frosties.localdomain> <2728CE5E-1335-4D6B-983D-305E6E5DA344@lip6.fr> <26FB93F3-065E-46C0-9767-0244B419626D@lip6.fr> To: Julien Signoles X-Mailer: Apple Mail (2.1081) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.5 (osiris.lip6.fr [132.227.60.30]); Thu, 11 Nov 2010 12:57:56 +0100 (CET) X-Scanned-By: MIMEDefang 2.68 on 132.227.60.30 X-Spam: no; 0.00; ocaml:01 bytecode:01 ocaml:01 pervasives:01 pervasives:01 iter:01 endline:01 bytecode:01 dynlink:01 cmo:01 cmo:01 compile-time:01 stdlib:01 statically:01 dynlink:01 Hello, ocamlclean removes code to which there is no possible path. For = instance, this program : let plop =3D 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 =3D List.map succ [1;2;3];; let _ =3D 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