<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/117438>117438</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [clang] clang -M should print expanded paths
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          xtexChooser
      </td>
    </tr>
</table>

<pre>
    When using `clang -M`, some c++ standard library headers' paths are not real paths.

For example, on AOSC OS (a usr-merged Linux distribution), `/bin/../lib64/gcc/` ... are emitted. These paths are valid for IO operations (`/bin` is linked to `/usr/bin` on usr-merged distributions, thus `/bin/../lib64` is equivalent to `/usr/lib64`), but not for Make and Ninja. Both make and ninja canonicalize them to `/lib64`, which does not exist, and they always regards these targets as dirty and rebuilds them everytime.

```
xtex@xtex1 ~ (main)> cat test.cpp
#include <cstdio>

int main() { return 0; }
xtex@xtex1 ~ (main)> clang -M test.cpp
test.o: test.cpp \
 /bin/../lib64/gcc/x86_64-aosc-linux-gnu/13.2.0/../../../../include/c++/13.2.0/cstdio \
 /bin/../lib64/gcc/x86_64-aosc-linux-gnu/13.2.0/../../../../include/c++/13.2.0/x86_64-aosc-linux-gnu/bits/c++config.h \
 /bin/../lib64/gcc/x86_64-aosc-linux-gnu/13.2.0/../../../../include/c++/13.2.0/pstl/pstl_config.h \
  /usr/include/tbb/tbb.h /usr/include/stdio.h \
 /usr/include/bits/libc-header-start.h \
 /usr/lib/clang/18/include/stdarg.h \
(some paths are emitted)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzEVcGO2zYQ_Rr6MrAgUbZlH3RYe2OgQNM9pECPASmOJSYUqZJDx-6h315Q0sZeNyl6W0AgoSHnvcfhzFCEoFuLWLP1nq2fFyJS53x9IbwcOucC-oV06lr_0aGFGLRtgW3yxgjbwvIj2-SMHyC4HqFhfM_4HgIJq4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