<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - clang produces ambiguous .d files"
   href="https://bugs.llvm.org/show_bug.cgi?id=41379">41379</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang produces ambiguous .d files
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>andrew@ziglang.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Zig runs clang in a child process with `-MD -MF foo.d` and then parses `foo.d`
to find out the list of dependencies of the compilation.

The problem is that with or without `-MV`, the format is ambiguous.

Without -MV, on Windows, I saw this example file:

C:\msys64\home\andy\dev\zig\example\shared_library\zig-cache\tmp\CHLssWPWWG0d-test.obj:
\
  C:\msys64\home\andy\dev\zig\example\shared_library\test.c \
  C:\msys64\home\andy\dev\zig\example\shared_library\zig-cache\mathtest.h \
  C:\Program\ Files\ (x86)\Microsoft\ Visual\
Studio\2017\Community\VC\Tools\MSVC\14.15.16726\lib\x64\\..\..\include\stdint.h
\
  ...

This is impossible to parse correctly - for example an escaped space is
indistinguishable from a path separator and then a space.

When I add `-MV`, the files are double-quote escaped, which fixes the issue.
However, `-MV` appears to not affect the "target", only the prerequisites. So
the problem remains for the target.

Downstream issue: <a href="https://github.com/ziglang/zig/issues/2046">https://github.com/ziglang/zig/issues/2046</a></pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>