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

    <tr>
        <th>Summary</th>
        <td>
            `clang -v` shows `InstalledDir: /bin` which is a symlink; A lot of `/bin` prefixed paths are then generated by Clang.
        </td>
    </tr>

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

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

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

<pre>
    `PATH` on my setup is accidentally set to have `/bin` before `/usr/bin`. And `/bin` is a symlink towards `/usr/bin`. Because of that, Clang detects its `InstalledDir` to be in `/bin` and I believe this creates a bunch of other problems:

Clang emits system header paths based on clang's argv[0] invocation directory.  So Clang then emits /bin based paths like the following:

    /bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/istream.tcc

These paths go into the clang-generated Makefile dependency rules (-MD) and into the object files as debuginfo.

Then different tools (like ninja or CodeChecker) try to parse these paths and problems occur, when these tools try to "compress" (a.k.a. canonicalize) the paths, without actually resolving them.
    
The above path compresses to

     /include/c++/9/bits/istream.tcc

which does not exist. Correct path resolution would result to:

    /usr/include/c++/9/bits/istream.tcc

because /bin is a symlink towards /usr/bin.

**If such generated paths are indeed caused by the detected `InstalledDir`, all this trouble could be avoided if Clang resolved the path during initialisation.**

Relevant tickets:
+ https://reviews.llvm.org/D37954
+ https://gitlab.kitware.com/cmake/cmake/-/issues/17330
+ https://github.com/ninja-build/ninja/issues/1330
+ https://github.com/Ericsson/codechecker/issues/3645

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJydVdtu4zYQ_Rr5ZWBBkeTbgx9yadA8LFC0-17wMrIYU6TBix336zuk5MTOpotiA4GKKc7MmZkzh9zK87ZYVn_cf_-dXmANDGfwGOIBlAcmhJJoAtM670Kw0LMjAp0t6meuTDLi2Fl32YvevX8p4d7I27PJKfjzoJ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