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 DA6D07F6CC for ; Wed, 4 Feb 2015 15:52:58 +0100 (CET) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of gabriel.scherer@gmail.com) identity=pra; client-ip=209.85.213.173; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="gabriel.scherer@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of gabriel.scherer@gmail.com designates 209.85.213.173 as permitted sender) identity=mailfrom; client-ip=209.85.213.173; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="gabriel.scherer@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-ig0-f173.google.com) identity=helo; client-ip=209.85.213.173; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="postmaster@mail-ig0-f173.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0A8AQBpMdJUm63VVdFag1hZBIJ9r3KPSoVxAoEOB0MBAQEBAREBAQEBAQYLCwkULoQNAQEEEhEEGQEbEgsBAwwGBQsNAgIJHQICIgERAQUBChIGExIQh3YBAxENs3g+MYsugWuCd4s8ChknAwpUhRcBAQEBAQUBAQEBAQEWAQUOgROOJDMHgmiBQQWESwqOC4VZgRc2jVmBcxIjgQwJhBE9MYJCAQEB X-IPAS-Result: A0A8AQBpMdJUm63VVdFag1hZBIJ9r3KPSoVxAoEOB0MBAQEBAREBAQEBAQYLCwkULoQNAQEEEhEEGQEbEgsBAwwGBQsNAgIJHQICIgERAQUBChIGExIQh3YBAxENs3g+MYsugWuCd4s8ChknAwpUhRcBAQEBAQUBAQEBAQEWAQUOgROOJDMHgmiBQQWESwqOC4VZgRc2jVmBcxIjgQwJhBE9MYJCAQEB X-IronPort-AV: E=Sophos;i="5.09,518,1418079600"; d="scan'208";a="98844827" Received: from mail-ig0-f173.google.com ([209.85.213.173]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 04 Feb 2015 15:52:57 +0100 Received: by mail-ig0-f173.google.com with SMTP id a13so35024105igq.0 for ; Wed, 04 Feb 2015 06:52:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=zMgRni4nLMe40tjYTgMKnzIS51Cv8cXiWLDw+GPdbps=; b=a4Il9PaB/SA2Gozo4UkQR9HemMWKnl5AW52Xtnb99fPf4KdbouAazrA73l7Gv3/e5t 0+1nwFnFY2EtuaxPsznqgs3B2KGy9doWKjaIUu+L1bqLEu7I/n/J7+9xQ3HWK3YRoPec hwuzDFv02vb17cCSyB1ZEHiAHHWHsMqfHrE11NpKN7hA82hawe3FIhY43Kd8p4ranpx3 yd6fn2yY/6iy/8EBhe81UM5zlIsqyQnDcj2SINMQ0GNl6vYMVN//tAzsil0MYZWilTXC XRL7GBnKwtfqarqZ2tIoX7XZLou9Ov2UnXYHK47VS9EUpFIzpGnQRM+Q+fueC2/wWkvK xNxg== X-Received: by 10.42.12.147 with SMTP id y19mr2109376icy.80.1423061576861; Wed, 04 Feb 2015 06:52:56 -0800 (PST) MIME-Version: 1.0 Received: by 10.36.13.195 with HTTP; Wed, 4 Feb 2015 06:52:16 -0800 (PST) In-Reply-To: References: <7bca26c097b73f653bd8bbfa1a07eaa8@nleyten.com> <20150123164111.GA16664@yquem.inria.fr> <0fd907ee06bedeff816160b9e7b9c027@nleyten.com> <6829d3482c94fbe2e22dd1574618e86e@nleyten.com> <5c76729753733a2ccbf1cad96879c312@nleyten.com> From: Gabriel Scherer Date: Wed, 4 Feb 2015 15:52:16 +0100 Message-ID: To: Dario Teixeira Cc: caml users Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Caml-list] Forcing OCamlbuild to compile a file before another I thought a bit more about this and here is a plan that seems reasonable (I fact-checked it with Pierre Chambart and Beno=C3=AEt Vaugon) and does not require changing ocamldep. 1) add a notion of foo.mlalias files with content of the form M :=3D Foo_M Z :=3D Bar_Z ... with a rule .mlalias -> .cmi that generates the .ml and compiles it with -no-alias-deps (note that by design it never has any dependency) 2) add the following rules in the code that computes dependencies from the output of ocamldep: if the module depends on Foo (which is the name of an alias file) and M, and (M :=3D Bar) is in foo.mlalias, then also add Bar as a dependency This should solve the problem of false cyclic dependencies caused by using short names inside the project itself. Remarks: - I considered, instead of a .mlalias file with a specific syntax, allowing to tag any .ml file as an alias-giving files; that makes the system more complex, because the alias-giving files may contain other OCaml statements than alias definitions, and thus have some dependencies (and we don't want to get in the business of trying to guess which modules are just aliases or real dependencies, or having to inspect .cmi files after-the-fact to rebuild the aliasing map). The downside is that people with an existing -no-alias-deps scheme suddenly willing to use ocamlbuild would have to rewrite some stuff first. (The other direction can be made automatic by a .mlalias -> .ml.inferred rule) - The restriction that the .mlalias file only contains module aliases and not other things you might want to have in a prelude/header is not really a restriction, as "include Foo" (where Foo is the name of the aliases-defining module) should work. I have not tested it, though. - It might be possible to implement this at the plugin level. The .mlalias rule could be proposed as a plugin. I'm less confident about the dependency-mangling logic, but the idea would be to overload the existing ".ml -> .ml.depends" rule to change the .ml.depends result (instead of its interpretation by ocamlbuild as I had in mind above). On Wed, Feb 4, 2015 at 2:18 PM, Dario Teixeira wrote: > Hello again Gabriel, > >> I haven't given much thought to it yet, but here would a sketchy idea >> of how to better support -no-alias-deps in OCamlbuild: >> >> ocamldep) extend ocamldep with a new -paths (as an extension over >> -modules) that returns not just the modules M appearing at the >> beginning of paths in source files, but the full module-longident (eg. >> M.Foo.Bar if you access the value M.Foo.Bar.baz or constructor >> M.Foo.Bar.Foobar) >> >> ocamlbuild) use ocamldep -modules (this happens in >> ocaml_utils.ml:read_path_dependencies), and for a non-singleton path >> of the form Foo.Bar, first type-check the compilation unit Foo, then >> inspect the .cmi to know whether Bar is defined as a module alias of >> Foo, and in that case depend on the aliased compilation unit >> >> (This should be done as a modification to the tool itself rather than >> a plugin, I think.) > > > Yes, I agree that all these tweaks to support -no-alias-deps should > ideally be part of OCamlbuild+OCamldep and work out-of-the-box. > Moreover, the modifications you suggest are in line with what I'm > planning to implement as a myocamlbuild plugin (I'll have to do it > as a plugin because I don't want to wait for a future OCaml release). > > The table below lists the dependencies of my dummy project, as computed > by the alias-oblivious OCamldep and what they actually are: > > OCamldep: Actual: > > Foo.ml: Foo_a, Foo_b, Foo_c (none) > Foo_a.ml: Foo Foo > Foo_b.ml: Foo, A Foo, Foo_a > Foo_c.ml: Foo, A, B Foo, Foo_a, Foo_b > > So basically I'll postprocess the output of OCamldep: whenever it finds > that a module depends both on Foo and on an alias declared in Foo, then > I'll replace the alias with the actual module. In addition, all of Foo's > dependencies must be cleared as well (it's more practical to just invoke > non_dependency for this purpose). > > My initial idea was to manipulate the dependency graph instead of resorti= ng > to postprocessing OCamldep's output. Alas, as you made clear on your oth= er > message, OCamlbuild does not actually construct a dependency graph before > the "real" compilation starts. > > Thanks again for your time! > Kind regards, > Dario Teixeira > > > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa.inria.fr/sympa/arc/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs