From: "Nicolás Ojeda Bär" <nicolas.ojeda.bar@lexifi.com>
To: Ian Zimmerman <itz@very.loosely.org>
Cc: Caml Mailinglist <caml-list@inria.fr>
Subject: Re: [Caml-list] How to use -map , -no-alias-deps and friends?
Date: Wed, 31 Jul 2019 21:52:25 +0000 [thread overview]
Message-ID: <CADK7aFOg80EPQA-eASO9XTJOfjTGab9SpmbUP+0rzg7FCN7FxQ@mail.gmail.com> (raw)
In-Reply-To: <20190731211816.x5vj472m34cshifj@matica.foolinux.mooo.com>
Dear Ian,
The short answer is: "use dune". I don't think anyone actually
compiles with modules aliases by hand, it is tricky, and dune really
makes it a breeze.
If regardless of that you want to figure it out, I would suggest you
forget your Makefile and try to reduce the example to the absolute
minimum (say, a library with a single module) and figure out which
steps are necessary to compile by hand. As far as I remember, the
manual, while brief, is correct (ocamldep -map will accept both an .ml
or an .mli).
Best wishes,
--
Nicolás OJEDA BÄR
nicolas.ojeda.bar@lexifi.com
https://www.lexifi.com
On Wed, Jul 31, 2019 at 11:18 PM Ian Zimmerman <itz@very.loosely.org> wrote:
>
> I'm having hellish time with them.
>
> I'm trying to build a simple library Aaa; let's assume bytecode only at
> this point. It should make available submodules like Aaa.Strutils,
> Aaa.Listutils et cetera from other packages, yet when building the
> library I want cross-module references look like Strutils , Listutils et
> cetera. This seems to be precisely the situation these knobs were meant
> for; and yet I just cannot make it work.
>
> It doesn't help that the two pieces of the manual explaining this,
> namely sections 14.2 and 8.9, are in less than perfect alignment: 8.9
> seems to suggest that the "map" file should be Aaa.ml (ie. an
> implementation file), and that there should be no corresponding
> interface file, but 14.2 shows -map mylib.mli passed to ocamldep.
>
> Here's my latest attempt. First, the Makefile:
>
> #! /usr/bin/make -f
>
> SHELL = /bin/sh
> PATH != eval "`opam env`" ; echo "$${PATH}"
> export PATH
>
> OCAMLFLAGS = -no-alias-deps -w -49 # add other options for ocamlc here
>
> # The list of object files for AAA
> AAA_SUBMODULES != echo Aaa__*.ml
> AAA_INTERFACES = $(AAA_SUBMODULES:.ml=.mli)
>
> AAA_NATIVEOBJS != ./linkorder.sh native Aaa $(AAA_SUBMODULES) $(AAA_INTERFACES)
> AAA_BYTEOBJS != ./linkorder.sh byte Aaa $(AAA_SUBMODULES) $(AAA_INTERFACES)
>
> .PHONY: byte native
>
> byte: Aaa.cma
>
> native: Aaa.cmxa
>
> Aaa.cma: $(AAA_BYTEOBJS) Aaa.cmo
> ocamlc -a -o Aaa.cma $(OCAMLFLAGS) $(AAA_BYTEOBJS) Aaa.cmo
>
> Aaa.cmxa: $(AAA_NATIVEOBJS) Aaa.cmx
> ocamlopt -a -o Aaa.cmxa $(OCAMLFLAGS) $(AAA_NATIVEOBJS) Aaa.cmx
>
> # Common rules
> .SUFFIXES: .ml .mli .cmo .cmi .cmx
>
> .ml.cmo:
> ocamlc $(OCAMLFLAGS) -open Aaa -c $<
>
> .ml.cmx:
> ocamlopt $(OCAMLFLAGS) -open Aaa -c $<
>
> Aaa.cmo: Aaa.ml
> ocamlc $(OCAMLFLAGS) -c Aaa.ml
>
> Aaa.cmx: Aaa.ml
> ocamlopt $(OCAMLFLAGS) -c Aaa.ml
>
> .mli.cmi:
> ocamlc $(OCAMLFLAGS) -open Aaa -c $<
>
> # Dependencies
> .depend: Makefile $(AAA_INTERFACES) $(AAA_SUBMODULES) Aaa.ml
> ocamldep -map Aaa.ml $(AAA_INTERFACES) $(AAA_SUBMODULES) -as-map Aaa.ml > .depend
>
> include .depend
>
> # Test suite
> RunTests: Aaa.cma RunTests.ml
> ocamlfind ocamlc -package qcheck-core -package qcheck-core.runner -o RunTests -linkpkg Aaa.cma RunTests.ml
>
> .PHONY: clean test
>
> test: RunTests
> ./RunTests
>
> clean:
> rm -f *.cma *.cmxa *.cmo *.o *.cmx *.cmi .depend RunTests
>
> # makefile ends here
>
> Here's Aaa.ml:
>
> module Colorspec = Aaa__Colorspec
> module Exnutils = Aaa__Exnutils
> module HashedString = Aaa__HashedString
> module Ioutils = Aaa__Ioutils
> module Listutils = Aaa__Listutils
> module Resultx = Aaa__Resultx
> module Sm = Aaa__Sm
> module Strutils = Aaa__Strutils
>
> ... and in this iteration, there is no Aaa.mli.
>
> This produces the following output:
>
> matica!91 aaa$ make
> Fatal error: exception Failure("Aaa.mli : empty map file or parse error")
> Fatal error: exception Failure("Aaa.mli : empty map file or parse error")
> ocamldep -map Aaa.ml Aaa__Colorspec.mli Aaa__Exnutils.mli Aaa__HashedString.mli Aaa__Ioutils.mli Aaa__Listutils.mli Aaa__Resultx.mli Aaa__Sm.mli Aaa__Strutils.mli Aaa__Colorspec.ml Aaa__Exnutils.ml Aaa__HashedString.ml Aaa__Ioutils.ml Aaa__Listutils.ml Aaa__Resultx.ml Aaa__Sm.ml Aaa__Strutils.ml -as-map Aaa.ml > .depend
> Fatal error: exception Failure("Aaa.mli : empty map file or parse error")
> Fatal error: exception Failure("Aaa.mli : empty map file or parse error")
> ocamlc -no-alias-deps -w -49 -c Aaa.ml
> ocamlc -a -o Aaa.cma -no-alias-deps -w -49 Aaa.cmo
> matica!92 aaa$ ls
> Aaa.cma Aaa__Colorspec.mli Aaa__Ioutils.ml Aaa__Resultx.mli LICENSE install.sh
> Aaa.cmi Aaa__Exnutils.ml Aaa__Ioutils.mli Aaa__Sm.ml META linkorder.sh
> Aaa.cmo Aaa__Exnutils.mli Aaa__Listutils.ml Aaa__Sm.mli Makefile
> Aaa.ml Aaa__HashedString.ml Aaa__Listutils.mli Aaa__Strutils.ml ORIGINAL_VERSION
> Aaa__Colorspec.ml Aaa__HashedString.mli Aaa__Resultx.ml Aaa__Strutils.mli RunTests.ml
>
> So, an archive file gets created, but obviously doesn't contain any real
> code.
>
> Virtual hugs for setting me on the right path.
>
> --
> Please don't Cc: me privately on mailing lists and Usenet,
> if you also post the followup to the list or newsgroup.
> To reply privately _only_ on Usenet and on broken lists
> which rewrite From, fetch the TXT record for no-use.mooo.com.
next prev parent reply other threads:[~2019-07-31 21:52 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-31 21:18 Ian Zimmerman
2019-07-31 21:52 ` Nicolás Ojeda Bär [this message]
2019-08-06 18:47 ` Ian Zimmerman
2019-08-07 20:32 ` [Caml-list] opam and dune [Was: How to use -map] Ian Zimmerman
2019-08-08 1:38 ` Rudi Grinberg
2019-08-08 17:48 ` Hendrik Boom
2019-08-08 17:53 ` Rudi Grinberg
2019-08-08 19:38 ` Daniel Bünzli
2019-11-15 0:32 ` Ian Zimmerman
2019-08-08 18:05 ` Yawar Amin
2019-08-08 19:03 ` Josh Berdine
2019-07-31 22:07 ` [Caml-list] How to use -map , -no-alias-deps and friends? Florian Angeletti
2019-07-31 23:14 ` Ian Zimmerman
2019-08-01 9:40 ` Florian Angeletti
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=CADK7aFOg80EPQA-eASO9XTJOfjTGab9SpmbUP+0rzg7FCN7FxQ@mail.gmail.com \
--to=nicolas.ojeda.bar@lexifi.com \
--cc=caml-list@inria.fr \
--cc=itz@very.loosely.org \
/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