www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - `dmd -deps` is broken

reply ag0aep6g <anonymous example.com> writes:
Consider these four modules:

     --- foo.d
     import baz;
     alias x = t!();

     --- bar.d
     import baz;
     alias x = t!();

     --- baz.d
     template t() { import qux; }

     --- qux.d
     // empty

Naively, one might draw the dependency graph like so:

     foo → baz ← bar
            ↓
           qux

And that's just what DMD used to do, until it changed in 2.064. That 
version included a fix for issue 9948 ("-deps dependency printing 
incorrect for templates") [1]. The idea described in the issue is to 
skip over baz, because that module itself doesn't really depend on qux. 
Only the modules that instantiate t actually depend on qux.

So since 2.064 `dmd -deps -o- foo.d bar.d` should result in this graph:

     foo → baz ← bar
         ↘     ↙
           qux

But it actually prints this:

     foo (foo.d) : private : baz (baz.d)
     foo (foo.d) : private : qux (qux.d)
     bar (bar.d) : private : baz (baz.d)

The same thing with arrows:

     foo → baz ← bar
      ↓
     qux

It's missing bar's dependency on qux! Looks like a serious bug to me.

Issue 9948 is being described as "not severe, it will just make build 
tools less efficient, because modules need to be compiled needlessly". 
In contrast, the new(er) bug seems severe to me, rendering `dmd -deps` 
useless for anything but the most trivial toy examples.

I suggest reverting to the old behavior. A dependency graph that has 
some unnecessary edges is better than a graph that is missing necessary 
edges.

Any objections? Given how broken `-deps` apparently is, does anyone even 
use it (succesfully)?


[1] https://issues.dlang.org/show_bug.cgi?id=9948
Sep 11 2020
parent ag0aep6g <anonymous example.com> writes:
On 11.09.20 15:32, ag0aep6g wrote:
 I suggest reverting to the old behavior. A dependency graph that has 
 some unnecessary edges is better than a graph that is missing necessary 
 edges.
Pull request for that: https://github.com/dlang/dmd/pull/11723
Sep 11 2020