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

    <tr>
        <th>Summary</th>
        <td>
            Cannot find GCC libraries when using --sysroot and --gcc-install-dir
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    Hi,

I'm trying to use clang with a custom sysroot (containing glibc) as well as a custom GCC, as follows:

```
clang++ -fuse-ld=lld --sysroot=sysroot_x86_64_linux/ --gcc-install-dir=gcc_9_x86_64_linux/usr/lib/gcc/x86_64-pc-linux-gnu/9.4.0/ foo.cpp
```

Compilation works as expected, however the linker cannot find libstdc++:

```
ld.lld: error: unable to find library -lstdc++
ld.lld: error: unable to find library -lgcc_s
ld.lld: error: unable to find library -lgcc_s
```

My expectation is that `--gcc-install-dir`  would allow clang to find these libraries, potentially even passing relevant `-L` paths to the linker (lld). Is my expectation wrong?

I take from [this post](https://discourse.llvm.org/t/add-gcc-install-dir-deprecate-gcc-toolchain-and-remove-gcc-install-prefix/65091) from @MaskRay that using `sysroot` and `gcc-install-dir` should be working combination:

> When the GCC installation is not contained in the sysroot, typically the user wants to fix the GCC version as well.
The new --gcc-install-dir= can be used instead.

I have also tried `--gcc-install-dir=` and get the same problems.

Thanks!
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyclM2OozgQx5_GuZRAxkA6HDikk2V2pJ3LaqQ9toxdAW8bG9kmdPbpVwaSme7py66EBMKur1_9q7j3qjOINSmfSXne8Sn01tWCO219x_UV_xl3rZW3-ndF2InQI6HHr4Q9DRDcTZkOgoXJIwjNTQezCj1wEJMPdgB_887aAIQdhDWBKxMNOq1aQVgF3MOMWsf3w-TL6UTYKf66WK3t7El-XIOSPd0eelyCEfZM2DMkl8ljoi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