`dmd -deps` is broken
ag0aep6g
anonymous at example.com
Fri Sep 11 13:32:39 UTC 2020
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
More information about the Digitalmars-d
mailing list