Version française
Home     About     Download     Resources     Contact us    
Browse thread
Incremental linking
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Xavier Leroy <Xavier.Leroy@i...>
Subject: Re: [Caml-list] Incremental linking
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