caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] swapping variant modules via subdirectories fails at link time
@ 2011-04-14 23:32 Alexy Khrabrov
  2011-04-15  8:37 ` Goswin von Brederlow
  2011-04-17 20:49 ` Stéphane Glondu
  0 siblings, 2 replies; 5+ messages in thread
From: Alexy Khrabrov @ 2011-04-14 23:32 UTC (permalink / raw)
  To: caml-list

I have a module a.ml, containing some functions I want to alter in a version of my program.  I'd like to do it on the command line at link time, to obtain either the original, or an altered version.  

Here's the original make line, simplified:

%.cmx: %.ml
	ocamlfind ocamlopt $(DEBUG) $(OPTFLAGS) -package $(PACKAGES) -c $^ -o $@

prog.opt: lib.cmxa a.cmx x.cmx prog.ml
	ocamlfind ocamlopt $(DEBUG) $(OPTFLAGS) -package $(PACKAGES) -linkpkg $^ -o $@

I tried to create the variant by placing an altered version of a.ml in a subdirectory, var/, and linking that:

prog.var.opt: lib.cmxa var/a.cmx x.cmx prog.ml
	ocamlfind ocamlopt $(DEBUG) $(OPTFLAGS) -package $(PACKAGES) -linkpkg $^ -o $@

Further, I've created a.mli at the root level, and compiled it with

ocamlfind ocamlc a.mli

-- it needs lib.cmo to work, a byte-code version of lib.cmxa, which I make first.

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.

The var/a.cmx is made by the same above pattern rule as ./a.cmx.  Even when ./a.cmi and var/a.cmi are the same, the same inconsistent error shows up!  Renaming ./a.ml out of the way and symlinking var/a.ml to ./ remakes prog.opt fine, which I can then rename prog.var.opt manually and hope to do it every time I need that, yet it's tiresome.   What prevents the original scheme from working?

-- Alexy


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-04-19 17:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-14 23:32 [Caml-list] swapping variant modules via subdirectories fails at link time 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
2011-04-19 17:09   ` Alexy Khrabrov

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).