Bug 93038 - Missing dependencies in depfile for imported files at compilation time
Summary: Missing dependencies in depfile for imported files at compilation time
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: d (show other bugs)
Version: 9.2.1
: P3 normal
Target Milestone: ---
Assignee: Iain Buclaw
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-12-21 13:39 UTC by Pierrick Bouvier
Modified: 2020-03-22 12:20 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2020-03-13 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Pierrick Bouvier 2019-12-21 13:39:05 UTC
Dear GDC developers,

when gdc is used to generate a depfile (make format), if code uses feature import(file), file is not reported in list of dependencies.

I tested with gdc-{8,9,10}.

# cat main.d
import std.stdio;
void main() { writeln(import(".bashrc")); }
# gdc main.d -J. -MMD
# cat main.deps
main.o: main.d

Until version 8, gdc has support for fdeps option. Problem is that format used (dictated by dmd) is useless in Make/Ninja build systems.
# gdc-8 -fdeps main.d -J.
...
depsFile main (main.d) : .bashrc (/home/user/.bashrc)
...

I build my code using meson project, which relies on depfiles created by compiler. Thus, a dependency is missed.

Would that be possible to add file imported at compilation time in list of dependencies? Technically, I think this file is not read at same time than other import, but I still think that would be a great add to gdc.

Thank you,
Pierrick
Comment 1 Iain Buclaw 2020-03-13 21:00:32 UTC
Yes, I have too noticed this and have a fix in the gdc development branch, will backport it to gcc trunk as soon as I cherry-pick out parts not related to supporting the self-hosted front-end.
Comment 2 Pierrick Bouvier 2020-03-13 21:17:29 UTC
(In reply to ibuclaw from comment #1)
> Yes, I have too noticed this and have a fix in the gdc development branch,
> will backport it to gcc trunk as soon as I cherry-pick out parts not related
> to supporting the self-hosted front-end.

Very good news. Hope it will land in first release of gcc-10 first release.
Comment 3 GCC Commits 2020-03-21 23:13:49 UTC
The master branch has been updated by Iain Buclaw <ibuclaw@gcc.gnu.org>:

https://gcc.gnu.org/g:4a01f7b1e73e98a86520d8a825ddd3777faa7c33

commit r10-7320-g4a01f7b1e73e98a86520d8a825ddd3777faa7c33
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Sun Mar 22 00:10:17 2020 +0100

    d: Fix missing dependencies in depfile for imported files (PR93038)
    
    A new field for tracking imported files was added to the front-end, this
    makes use of it by writing all such files in the make dependency list.
    
    gcc/d/ChangeLog:
    
    2020-03-22  Iain Buclaw  <ibuclaw@gdcproject.org>
    
            PR d/93038
            * d-lang.cc (deps_write): Add content imported files to the make
            dependency list.
    
    gcc/testsuite/ChangeLog:
    
    2020-03-22  Iain Buclaw  <ibuclaw@gdcproject.org>
    
            PR d/93038
            * gdc.dg/fileimports/pr93038.txt: New test.
            * gdc.dg/pr93038.d: New test.
Comment 4 Iain Buclaw 2020-03-21 23:47:14 UTC
Exposed information from the front-end, fix committed.
Comment 5 GCC Commits 2020-03-22 12:20:40 UTC
The master branch has been updated by Iain Buclaw <ibuclaw@gcc.gnu.org>:

https://gcc.gnu.org/g:fbe60463bb80d859d4842f0113a6b24fe9cc9bd4

commit r10-7323-gfbe60463bb80d859d4842f0113a6b24fe9cc9bd4
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Sun Mar 22 13:11:10 2020 +0100

    d: Generate phony targets for content imported files (PR93038)
    
    This is in addition to the last change which started including them in
    the make dependency list.
    
    gcc/d/ChangeLog:
    
    2020-03-22  Iain Buclaw  <ibuclaw@gdcproject.org>
    
            PR d/93038
            * d-lang.cc (deps_write): Generate phony targets for content imported
            files.
    
    gcc/testsuite/ChangeLog:
    
    2020-03-22  Iain Buclaw  <ibuclaw@gdcproject.org>
    
            PR d/93038
            * gdc.dg/pr93038b.d: New test.