<p dir="auto">When using <code class="notranslate">--emit=dep-info</code> in a makefile, a missing file (due to being renamed or re-factored away) will cause make to terminate the build instantly.</p>
<p dir="auto">GCC/Clang mitigate this by using the <code class="notranslate">-MP</code> flag when creating dependencies, which emits extra rules of the form <code class="notranslate">dependency:</code> to tell make to ignore the files if they are missing.</p>
<p dir="auto">Running something like:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="rustc --emit dep-info -o x.o lib.rs"><pre class="notranslate"><code class="notranslate">rustc --emit dep-info -o x.o lib.rs
</code></pre></div>
<p dir="auto">will produce a depfile containing a rule like:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="x.o: /path/to/lib.rs /path/to/a.rs /path/to/b.rs"><pre class="notranslate"><code class="notranslate">x.o: /path/to/lib.rs /path/to/a.rs /path/to/b.rs
</code></pre></div>
<p dir="auto">This output has a problem: if <code class="notranslate">a.rs</code> is deleted from the filesystem and dependencies on it erased from <code class="notranslate">lib.rs</code>, then <code class="notranslate">make</code> will attempt to look for a rule to generate <code class="notranslate">a.rs</code> when we request that things be remade.  Not finding one, it will helpfully complain that there is no rule to make <code class="notranslate">a.rs</code> and exit.</p>
<p dir="auto">This can, of course, be worked around by clearing out your entire build directory and starting over, but this seems undesirable.</p>
<p dir="auto">GCC has an option (<code class="notranslate">-MP</code>) to produce "phony" targets for all the dependencies of the object file; this prevents issues in cases like the above:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="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:"><pre class="notranslate"><code class="notranslate">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:
</code></pre></div>
<p dir="auto">since <code class="notranslate">make</code> now understands how to "generate" <code class="notranslate">a.rs</code> if it doesn't find it.</p>