Skip to content

--emit dep-info should support emitting "phony" dependencies for input files #28735

Closed
@froydnj

Description

@froydnj

Running something like:

rustc --emit dep-info -o x.o lib.rs

will produce a depfile containing a rule like:

x.o: /path/to/lib.rs /path/to/a.rs /path/to/b.rs

This output has a problem: if a.rs is deleted from the filesystem and dependencies on it erased from lib.rs, then make will attempt to look for a rule to generate a.rs when we request that things be remade. Not finding one, it will helpfully complain that there is no rule to make a.rs and exit.

This can, of course, be worked around by clearing out your entire build directory and starting over, but this seems undesirable.

GCC has an option (-MP) to produce "phony" targets for all the dependencies of the object file; this prevents issues in cases like the above:

x.o: /path/to/lib.rs /path/to/a.rs /path/to/b.rs

/path/to/lib.rs:

/path/to/a.rs:

/path/to/b.rs:

since make now understands how to "generate" a.rs if it doesn't find it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions