Bug 21844 – makedeps option adds spurious/incorrect dependency

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2021-04-20T15:46:02Z
Last change time
2022-03-08T16:27:10Z
Keywords
pull
Assigned to
No Owner
Creator
Ichneumwn

Comments

Comment #0 by ichneumwn — 2021-04-20T15:46:02Z
Using ldc2 (1.25.0 (DMD v2.095.1, LLVM 10.0.0) or dmd (DMD64 D Compiler v2.095.0), compiling the following test code: test.d: import std.experimental.logger : info; void main() { info("hello"); } using: dmd -makedeps=deps.txt test.d generates: test.d \ /usr/include/dmd/phobos/std/experimental/logger/package.d \ /usr/include/dmd/druntime/import/object.d \ /usr/include/dmd/druntime/import/core/attribute.d \ ... /usr/include/dmd/druntime/import/core/stdc/fenv.d \ test_loggerconfig.d \ /usr/include/dmd/druntime/import/core/sys/linux/time.d Note the test_loggerconfig.d. This dependency is only generated if info() is used somewhere in the code, i.e. it is not triggered if the body of main is empty in the example above. info() is an alias leading to the template defaultLogFunction in std.experimental.logger.core.d This is an excerpt from the logger.core.d code: template moduleLogLevel(string moduleName) if (moduleName.length) { import std.string : format; mixin(q{ static if (__traits(compiles, {import %1$s : logLevel;})) { import %1$s : logLevel; I guess the import-in-mixin might be throwing off the makedeps logic? This implicit non-existing dependency causes meson/ninja to recompile each time it is invoked Cheers!
Comment #1 by tobias — 2022-03-04T10:03:42Z
mir-core has the same problem, which also boils down to __traits(compiles, import <module>), adding a file to the makedeps. One could argue, that it is correct to add files to the makedeps, but given multiple import paths it's hard to do it correctly.
Comment #2 by dlang-bot — 2022-03-04T12:42:53Z
@Panke created dlang/dmd pull request #13755 "Fix Issue 21844: makedeps contain non-existing files" fixing this issue: - Fix Issue 21844: makedeps contain non-existing files https://github.com/dlang/dmd/pull/13755
Comment #3 by dlang-bot — 2022-03-04T14:30:20Z
@Panke updated dlang/dmd pull request #13756 "Fix issue 21844: makedeps contain non-existing files" fixing this issue: - Fix Issue 21844: makedeps contain non-existing files https://github.com/dlang/dmd/pull/13756
Comment #4 by dlang-bot — 2022-03-05T01:30:09Z
dlang/dmd pull request #13755 "Fix Issue 21844: makedeps contain non-existing files" was merged into stable: - 315fdaf3040cfc37969549bc95c38ff81a4f4aef by Tobias Pankrath: Fix Issue 21844 - makedeps contain non-existing files https://github.com/dlang/dmd/pull/13755
Comment #5 by dlang-bot — 2022-03-08T16:27:10Z
dlang/dmd pull request #13785 "merge stable" was merged into master: - 24aa1e71af36f857c3a0863b4266225061436989 by Tobias Pankrath: Fix Issue 21844 - makedeps contain non-existing files https://github.com/dlang/dmd/pull/13785