caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Daniel Bünzli" <daniel.buenzli@epfl.ch>
To: caml-list <caml-list@inria.fr>
Subject: How to compile different implementations of the same lib
Date: Wed, 30 Nov 2005 15:38:05 +0100	[thread overview]
Message-ID: <4F70401E-AE91-4E5E-AF67-70FBDCC7C353@epfl.ch> (raw)
In-Reply-To: <20051130.211930.102965761.garrigue@math.nagoya-u.ac.jp>

Le 30 nov. 05 à 13:19, Jacques Garrigue a écrit :

> Note that with native code you must be careful to compile without any
> .cmx around (only .cmi's), as this would induce dependencies on a
> specific version. This also means that you lose inlining (one major
> advantage of native code.)

I don't understand this. Careful to compile what without which cmx  
around ? And where do you lose inlining ?

I recently got into the same kind of situation and I couldn't solve  
it. So I'm seeking advice on how to solve the following the best way.  
I want to give the choice between three implementation of a library  
lib (which also calls C) in both byte and native code.

1. A debugging version compiled with -g, libdebug.cm(x)a.
2. A normal version, lib.cm(x)a
3. An unsafe version compiled with -unsafe and with some validation  
of input parameters removed, libunsafe.cm(x)a.

The input parameter validation code is centralized in a module Check.  
This module has two implementation : one with the actual checks, and  
the other with dumb checks equal to unit. Functions of the library  
are implemented with this idiom :

let f x = Check.arg x; ...

The idea is to compile the unsafe version with the dumb  
implementation of Check and that the optimizer will remove the calls  
to the validation functions.

My questions are,

1. Is it possible for all versions of this library to share the same  
cmi interfaces ? When I tried to do this, I got these inconsistent  
assumption errors.

2. For the unsafe version, will the calls to the Check functions be  
removed by the optimizer ? My understanding is that they will but  
only for native code compilation, i.e. libunsafe.cmxa. In  
libunsafe.cma we will still have the function call overhead.

Thanks for your help,

Daniel


  reply	other threads:[~2005-11-30 14:37 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-30  9:05 Best way to choose an implementation of a lib ? Christophe Raffalli
2005-11-30 12:19 ` [Caml-list] " Jacques Garrigue
2005-11-30 14:38   ` Daniel Bünzli [this message]
2005-11-30 16:09     ` [Caml-list] How to compile different implementations of the same lib Daniel Bünzli
2005-12-01  1:07       ` Jacques Garrigue
2005-12-01  1:53         ` malc
2005-12-01 17:03         ` Christophe Raffalli
2005-12-01 17:54           ` skaller
2005-12-01 20:09             ` Richard Jones
2005-12-01 23:47               ` skaller
2005-12-02  3:29               ` Jacques Garrigue
2005-12-01 21:33             ` Christophe Raffalli
2005-12-02  3:06               ` Jacques Garrigue
2005-11-30 16:24   ` how to detect .cmx incompatibility Stefano Zacchiroli
2005-11-30 19:48   ` [Caml-list] Best way to choose an implementation of a lib ? Eric Cooper
2005-12-01 17:05     ` Christophe Raffalli
2005-12-01 17:31       ` Eric Cooper

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=4F70401E-AE91-4E5E-AF67-70FBDCC7C353@epfl.ch \
    --to=daniel.buenzli@epfl.ch \
    --cc=caml-list@inria.fr \
    /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).