From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id D0F597EEEF for ; Sat, 13 Jun 2015 16:36:58 +0200 (CEST) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of tim@gfxmonk.net) identity=pra; client-ip=209.85.213.180; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="tim@gfxmonk.net"; x-sender="tim@gfxmonk.net"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of tim@gfxmonk.net) identity=mailfrom; client-ip=209.85.213.180; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="tim@gfxmonk.net"; x-sender="tim@gfxmonk.net"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-ig0-f180.google.com) identity=helo; client-ip=209.85.213.180; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="tim@gfxmonk.net"; x-sender="postmaster@mail-ig0-f180.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0D6AABeP3xVlLTVVdFcg2RfBoJSRsJBAoEbB0wBAQEBAQESAQEBAQcLCwkfMIQjAQEEDAYRVhAJAgsNAgImAgIiEgEFARwGARIiiA0FlWeQaz4xiz+WWAEBAQEGAQEBAR4KgReKI4QdHhgzB4JogUUFk1uJJoIcgTMUkm6CERIjgRWEMV0BgkYBAQE X-IPAS-Result: A0D6AABeP3xVlLTVVdFcg2RfBoJSRsJBAoEbB0wBAQEBAQESAQEBAQcLCwkfMIQjAQEEDAYRVhAJAgsNAgImAgIiEgEFARwGARIiiA0FlWeQaz4xiz+WWAEBAQEGAQEBAR4KgReKI4QdHhgzB4JogUUFk1uJJoIcgTMUkm6CERIjgRWEMV0BgkYBAQE X-IronPort-AV: E=Sophos;i="5.13,608,1427752800"; d="scan'208";a="136030882" Received: from mail-ig0-f180.google.com ([209.85.213.180]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 13 Jun 2015 16:36:57 +0200 Received: by igbpi8 with SMTP id pi8so28363684igb.0 for ; Sat, 13 Jun 2015 07:36:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type:content-transfer-encoding; bh=1AEh5PtmoTi8ng9ku8U9OfOgukcBJ5LIxz8/aA/vgt0=; b=AtUOg0flRMdbVB5rrxTMTJgShOc/zsmGfkRh1tD4WbFwPpp0HhHhWLi7bnTlaQjZzT ICWVQCBf60N4Dabma0gtN9MWk7kHi9Eqk30HUNxPETBv8eTsjVWLP6Ovj8OhM3OYNq75 IaI4j2wOGGPthza9WjvixMWD0Cp8daC7XQlF9A3p/R958GuuoBGJfEnc/SsWxqbhFT2K 7rZUYe0s4zvzuXYyWNST58jUv0lMvcVeneVPmg/49e02YXHm1SrNq6x6PcG6Jo+74bN7 kM7mOqu62PADRXtegJIoa3bYlb+d8djwUXCTQRbiiXGWgtO9nzIZM6awhPmOhRnGOES3 wIsw== X-Gm-Message-State: ALoCoQmoCKxowHhYOw+RYFM3SLwWVHpzEjPbjlfNDxQR+NZdR049OmJOicyITqb3RXKQhp5OfWGc X-Received: by 10.43.102.132 with SMTP id de4mr21726815icc.13.1434206216029; Sat, 13 Jun 2015 07:36:56 -0700 (PDT) Received: from mail-ie0-f170.google.com (mail-ie0-f170.google.com. [209.85.223.170]) by mx.google.com with ESMTPSA id k81sm4740243iod.31.2015.06.13.07.36.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 13 Jun 2015 07:36:55 -0700 (PDT) Received: by iecrd14 with SMTP id rd14so7876561iec.3 for ; Sat, 13 Jun 2015 07:36:53 -0700 (PDT) X-Received: by 10.42.81.6 with SMTP id x6mr22229619ick.89.1434206213891; Sat, 13 Jun 2015 07:36:53 -0700 (PDT) MIME-Version: 1.0 Received: by 10.50.252.10 with HTTP; Sat, 13 Jun 2015 07:36:33 -0700 (PDT) In-Reply-To: <8AD46EC2-3269-4DD5-B1E7-C518B33EAC07@m4x.org> References: <8AD46EC2-3269-4DD5-B1E7-C518B33EAC07@m4x.org> From: Tim Cuthbertson Date: Sun, 14 Jun 2015 00:36:33 +1000 Message-ID: To: Simon Cruanes , =?UTF-8?B?VMO2csO2ayBFZHdpbg==?= Cc: caml-list@inria.fr Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Caml-list] Determining what code is depending on `Unix` On Sat, Jun 13, 2015 at 10:07 PM, T=C3=B6r=C3=B6k Edwin wrote: > > On 06/13/2015 10:22 AM, Tim Cuthbertson wrote: > > Hi all, > > > > I'm attempting to convert an existing (reasonably small) HTTP server wr= itten in OCaml to run on mirage's xen backend. I've gotten the compiler rea= sonably happy by replacing uses of Unix / Lwt_unix with appropriate mirage-= compatible modules. But when it comes to link time, it seems that my applic= ation is still indirectly depending on Unix: > > > > + ocamlbuild -quiet -cflag -warn-error -cflag +a-3 -build-dir [...]/_bu= ild/mirage-xen -use-ocamlfind -lflags -g,-linkpkg,-dontlink,unix main.nativ= e.o > > + ocamlfind ocamlopt -g -linkpkg -dontlink unix -output-obj -syntax cam= lp4o -package 'fat-filesystem, io-page, mirage-block-xen.front, batteries, = yojson, safepass, sha, lwt, lwt.syntax, mirage-console.xen, mirage-types, m= irage-types.lwt, mirage-net-xen, mirage-types,cohttp,cohttp.lwt, mirage-htt= p, lwt, mirage.runtime, tcpip.stack-direct,tcpip.stack-socket,mirage-clock-= xen,conduit.mirage' src/passe.cmx src/passe_server.cmx src/unikernel.cmx ma= in.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(Ip= addr_unix) > > Command exited with code 2. > > > > I can't figure out why those modules are being linked in, though. I hav= e 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 in= directly. > > > > Is there some way to see a tree / list of "what module in my source cod= e is transitively depending on Unix, and via what modules is that dependenc= y 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 surp= rises 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.fr= ont 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? a= nd you already have mirage-http and cohttp.lwt-core), and then: > > $ ocamlfind query -r -p-format fat-filesystem io-page mirage-block-xen.fr= ont batteries yojson safepass sha lwt lwt.syntax mirage-console.xen mirage-= types mirage-types.lwt mirage-net-xen mirage-types cohttp mirage-http lwt m= irage.runtime mirage-clock-xen conduit.mirage | grep unix > unix > > Best regards, > --Edwin Thanks for the advice, that has gotten me much further. tcpip-stack-direct still seems necessary, but *-socket isn't. I notice `unix` is still in the output after removing these modules (which seems like a bad thing), and yet it successfully compiles main.native.o now. Perhaps that is related to: On Sat, Jun 13, 2015 at 11:06 PM, Simon Cruanes wrote: > > I don't have a general answer for finding such dependencies, but in the l= ist you have it seems there is at least batteries that depends on Unix. > > I thought so too, but I was hoping that I can use toplevel modules (specifically BatList and BatString), so that even though the "batteries" package depends on Unix, those individual modules I'm using don't. In which case the Unix dependency won't actually be needed or referenced. But perhaps the dependencies aren't that fine-grained? (I should probably drop the Batteries dependency since I'm using so little, but it's used more heavily in non-server parts of the same codebase)