From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id KAA24521; Fri, 26 Apr 2002 10:18:04 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id KAA24666 for ; Fri, 26 Apr 2002 10:18:03 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g3Q8Glf05416; Fri, 26 Apr 2002 10:16:47 +0200 (MET DST) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id KAA24787; Fri, 26 Apr 2002 10:16:47 +0200 (MET DST) Date: Fri, 26 Apr 2002 10:16:47 +0200 From: Xavier Leroy To: Claudio Sacerdoti Coen Cc: OCAML Subject: Re: [Caml-list] Unused .cma and .so Message-ID: <20020426101646.A24598@pauillac.inria.fr> References: <20020415192121.A11023@cs.unibo.it> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: <20020415192121.A11023@cs.unibo.it>; from sacerdot@cs.unibo.it on Mon, Apr 15, 2002 at 07:21:21PM +0200 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > 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