caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Stéphane Glondu" <steph@glondu.net>
To: Alexy Khrabrov <deliverable@gmail.com>
Cc: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] swapping variant modules via subdirectories fails at link time
Date: Sun, 17 Apr 2011 22:49:00 +0200	[thread overview]
Message-ID: <4DAB523C.1030103@glondu.net> (raw)
In-Reply-To: <4D64C4F9-251E-4E76-8269-361C444E8F8F@gmail.com>

Le 15/04/2011 01:32, Alexy Khrabrov a écrit :
> With that a.cmi at the root level, I can remake prog.opt fine.  If I copy or symlink a.cmi to var/, or symlink a.mli there, and try to make prog.var.opt, I get an error at prog.ml that files var/a.cmx and x.cmx make inconsistent assumptions about the interface A.

Aren't you facing inconsistent assumptions over *implementations* instead?

You have to compile your two implementations of A in separate
directories, and compile whatever depends on A in your root directory
with only a.cmi (for example), so that no a.cmx is seen. Then you can
link using either .cmx file.

The reason is that the compiler uses information from .cmx files if they
are available to do some optimizations such as inling. These
optimizations are turned off (but compilations still succeeds) if the
.cmx are missing.

Maybe I can make it clearer with an example tree:

.
|-- a.cmi
|-- a.mli
|-- dir1
|   |-- a.cmi -> ../a.cmi
|   |-- a.cmx
|   |-- a.ml
|   |-- a.mli -> ../a.mli
|   `-- a.o
`-- dir2
    |-- a.cmi -> ../a.cmi
    |-- a.cmx
    |-- a.ml
    |-- a.mli -> ../a.mli
    `-- a.o

Of course, dir1 and dir2 must *not* be in the include patch when
compiling stuff depending on module A.

The ocamlobjinfo (in 3.12) or dumpapprox (in < 3.12) can be useful here:
no A must appear in "implementation assumptions" in whatever
reverse-dependencies of A if you intend to provides several
implementations of A.


Hope this helps,

-- 
Stéphane



  parent reply	other threads:[~2011-04-17 20:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-14 23:32 Alexy Khrabrov
2011-04-15  8:37 ` Goswin von Brederlow
2011-04-17 20:26   ` Alexy Khrabrov
2011-04-17 20:49 ` Stéphane Glondu [this message]
2011-04-19 17:09   ` Alexy Khrabrov

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=4DAB523C.1030103@glondu.net \
    --to=steph@glondu.net \
    --cc=caml-list@inria.fr \
    --cc=deliverable@gmail.com \
    /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).