From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 77DCABC37 for ; Wed, 30 Sep 2009 10:08:02 +0200 (CEST) X-IronPort-AV: E=Sophos;i="4.44,479,1249250400"; d="scan'208";a="33843325" Received: from estephe.inria.fr ([128.93.11.95]) by mail2-relais-roc.national.inria.fr with ESMTP; 30 Sep 2009 10:08:02 +0200 Message-ID: <4AC311E2.7030409@inria.fr> Date: Wed, 30 Sep 2009 10:08:02 +0200 From: Xavier Leroy User-Agent: Thunderbird 2.0.0.17 (X11/20080929) MIME-Version: 1.0 To: Dawid Toton Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Incremental linking References: <4AC25433.1060709@uj.edu.pl> In-Reply-To: <4AC25433.1060709@uj.edu.pl> Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; cmx:01 associative:01 ocamlopt:01 ocamlopt:01 -pack:01 compilation:01 cmx:01 compilation:01 gerd:01 stolpmann:01 cmxa:01 cmxa:01 link-time:01 ocaml:01 incremental:01 Dawid Toton wrote: > I have lot of modules and they are compiled to native code. > So I have .cmx and .o files and want to link them faster. > Is is possible to make linking an associative operation acting on modules? > [...] > Documentation of ld says that files produced with --relocatable can be > used as intermediate partially linked files. Can something like this be > done with object code produced by ocamlopt? Yes. "ocamlopt -pack" actually calls "ld -r" underneath to consolidate several compilation units in a single .cmx/.o file. "ld -r" will resolve references between these compilation units. Gerd Stolpmann wrote: > Well, you can link several .cmx files (and their accompanying .o files) > to a .cmxa file (and an accompanying .a file): ocamlopt -a From a linking standpoint, "ocamlopt -a" is equivalent to "ar": it does not resolve any references, just concatenates individual .cmx/.o files in a single .cmxa/.a file. That can still speed up linking a bit, since reading one big .a file is faster than reading a zillion small .o files. Generally speaking, I'm somewhat surprised that linking time is an issue for Dawid. Modern Unix linkers are quite fast, and the additional link-time work that OCaml does is small. Let us know if you manage to narrow the problem. - Xavier Leroy