From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p3F8che1001891 for ; Fri, 15 Apr 2011 10:38:43 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApMCAE8DqE3ZSMDdkWdsb2JhbACmARQBAQEBCQsLBxQDIohvuneFbgSRbINN X-IronPort-AV: E=Sophos;i="4.64,217,1301868000"; d="scan'208";a="105695784" Received: from fmmailgate01.web.de ([217.72.192.221]) by mail1-smtp-roc.national.inria.fr with ESMTP; 15 Apr 2011 10:38:38 +0200 Received: from smtp04.web.de ( [172.20.0.225]) by fmmailgate01.web.de (Postfix) with ESMTP id B900B18C11504; Fri, 15 Apr 2011 10:37:42 +0200 (CEST) Received: from [78.43.204.177] (helo=frosties.localnet) by smtp04.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.110 #2) id 1QAeX8-00043i-00; Fri, 15 Apr 2011 10:37:42 +0200 Received: from mrvn by frosties.localnet with local (Exim 4.72) (envelope-from ) id 1QAeX8-0001I7-8J; Fri, 15 Apr 2011 10:37:42 +0200 From: Goswin von Brederlow To: Alexy Khrabrov Cc: caml-list References: <4D64C4F9-251E-4E76-8269-361C444E8F8F@gmail.com> Date: Fri, 15 Apr 2011 10:37:42 +0200 In-Reply-To: <4D64C4F9-251E-4E76-8269-361C444E8F8F@gmail.com> (Alexy Khrabrov's message of "Thu, 14 Apr 2011 19:32:16 -0400") Message-ID: <87pqongbah.fsf@frosties.localnet> User-Agent: Gnus/5.110009 (No Gnus v0.9) XEmacs/21.4.22 (linux, no MULE) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: goswin-v-b@web.de X-Sender: goswin-v-b@web.de X-Provags-ID: V01U2FsdGVkX1+YQJKxLimI+kU6eumElf8yGxJoMGPl2VNo2NkK 7VrziRzgeb2VRIs4DSOY311ky04seF8fmdRe6JTo/4DxPPg+W4 b8YgGySrs= Subject: Re: [Caml-list] swapping variant modules via subdirectories fails at link time Alexy Khrabrov writes: > 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 You need to compile a.ml inside var/ instead of compiling var/a.ml. MfG Goswin