caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Török Edwin" <edwin+ml-ocaml@etorok.net>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Determining what code is depending on `Unix`
Date: Sat, 13 Jun 2015 15:07:23 +0300	[thread overview]
Message-ID: <557C1CFB.2030600@etorok.net> (raw)
In-Reply-To: <CAC-LLDjUJJhcZEvWid3yfMWq6wjLEg2DHdw4fYaWgXcVD9S6+g@mail.gmail.com>

On 06/13/2015 10:22 AM, Tim Cuthbertson wrote:
> Hi all,
> 
> I'm attempting to convert an existing (reasonably small) HTTP server written in OCaml to run on mirage's xen backend. I've gotten the compiler reasonably happy by replacing uses of Unix / Lwt_unix with appropriate mirage-compatible modules. But when it comes to link time, it seems that my application is still indirectly depending on Unix:
> 
> + ocamlbuild -quiet -cflag -warn-error -cflag +a-3 -build-dir [...]/_build/mirage-xen -use-ocamlfind -lflags -g,-linkpkg,-dontlink,unix main.native.o
> + ocamlfind ocamlopt -g -linkpkg -dontlink unix -output-obj -syntax camlp4o -package 'fat-filesystem, io-page, mirage-block-xen.front, batteries, yojson, safepass, sha, lwt, lwt.syntax, mirage-console.xen, mirage-types, mirage-types.lwt, mirage-net-xen, mirage-types,cohttp,cohttp.lwt, mirage-http, lwt, mirage.runtime, tcpip.stack-direct,tcpip.stack-socket,mirage-clock-xen,conduit.mirage' src/passe.cmx src/passe_server.cmx src/unikernel.cmx main.cmx -o main.native.o
> File "_none_", line 1:
> Error: No implementations provided for the following modules:
>          Unix referenced from /home/tim/.opam/mirage_4_01_0/lib/lwt/lwt-unix.cmxa(Lwt_engine),
>            /home/tim/.opam/mirage_4_01_0/lib/lwt/lwt-unix.cmxa(Lwt_unix),
>            /home/tim/.opam/mirage_4_01_0/lib/ipaddr/ipaddr_unix.cmxa(Ipaddr_unix)
> Command exited with code 2.
> 
> I can't figure out why those modules are being linked in, though. I have grepped all files in _build/mirage-xen/**/*.ml.depends (as well as my own source code), and nothing in there matches "unix", nor mentions any of the modules listed above. The only lwt_* matches are:
> 
> Cohttp_lwt_body
> Lwt_mutex
> Lwt_stream
> 
> Which all seem like they shouldn't depend on unix either directly or indirectly.
> 
> Is there some way to see a tree / list of "what module in my source code is transitively depending on Unix, and via what modules is that dependency inherited?" Or even if there's no way to see a tree, is there a way to do it one step at a time (e.g "what is depending directly on Lwt_unix", then repeat the process for those modules listed until I see something that surprises me)
> 
> Failing that, does anyone have tricks for weeding indirect `Unix` usage out of a codebase which is not directly using it?

'ocamlfind query -r' can be useful, in your case:

$ ocamlfind query -r -p-format fat-filesystem io-page mirage-block-xen.front batteries yojson safepass sha lwt lwt.syntax mirage-console.xen mirage-types mirage-types.lwt mirage-net-xen mirage-types cohttp cohttp.lwt mirage-http lwt mirage.runtime tcpip.stack-direct tcpip.stack-socket mirage-clock-xen conduit.mirage | grep unix
unix
lwt.unix
ipaddr.unix
conduit.lwt-unix
io-page.unix

Drop cohttp.lwt, tcpip.stack-direct, tcpip.stack-socket (use tcpip.xen? and you already have mirage-http and cohttp.lwt-core), and then:

$ ocamlfind query -r -p-format fat-filesystem io-page mirage-block-xen.front batteries yojson safepass sha lwt lwt.syntax mirage-console.xen mirage-types mirage-types.lwt mirage-net-xen mirage-types cohttp mirage-http lwt mirage.runtime mirage-clock-xen conduit.mirage | grep unix
unix

Best regards,
--Edwin


  reply	other threads:[~2015-06-13 12:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-13  7:22 Tim Cuthbertson
2015-06-13 12:07 ` Török Edwin [this message]
2015-06-13 13:06 ` Simon Cruanes
2015-06-13 14:36   ` Tim Cuthbertson
2015-06-14 13:47     ` Simon Cruanes

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=557C1CFB.2030600@etorok.net \
    --to=edwin+ml-ocaml@etorok.net \
    --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;
as well as URLs for NNTP newsgroup(s).