From: Florian Angeletti <octa@polychoron.fr>
To: caml-list@inria.fr
Subject: Re: [Caml-list] How to use -map , -no-alias-deps and friends?
Date: Thu, 1 Aug 2019 00:07:44 +0200 [thread overview]
Message-ID: <6480f30b-a2c3-90bc-33b3-6efa2e02f398@polychoron.fr> (raw)
In-Reply-To: <20190731211816.x5vj472m34cshifj@matica.foolinux.mooo.com>
Dear Ian,
As far as I can see your invocation of ocamldep in the .depend target is
mostly fine. You may want to add `-open Aaa` too (another minor issue
here is that `-as-map` is a global flag and does not take an argument) .
The problem seems to come from your undisclosed linkorder script.
Note than another option to compute .depend and the link order is to use
`codept` (available on opam) with the `-no-alias-deps` flag, which
removes the need of declaring any map file by hand.
— octachron.
On 31/07/2019 23:18, Ian Zimmerman 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.
>
next prev parent reply other threads:[~2019-07-31 22:07 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
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 ` Florian Angeletti [this message]
2019-07-31 23:14 ` [Caml-list] How to use -map , -no-alias-deps and friends? 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=6480f30b-a2c3-90bc-33b3-6efa2e02f398@polychoron.fr \
--to=octa@polychoron.fr \
--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