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

    <tr>
        <th>Summary</th>
        <td>
            lld-link doesn't find libraries in winsysroot
        </td>
    </tr>

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

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

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

<pre>
    ```
$ touch foo.c
$ clang-cl -o foo.obj -c foo.c
$ lld-link -out:foo.dll -dll foo.obj -winsysroot:/path/to/winsysroot user32.lib
lld-link: error: could not open 'user32.lib': No such file or directory
```
Using defaultlib does work:
```
$ lld-link -out:foo.dll -dll foo.obj -winsysroot:/path/to/winsysroot -defaultlib:user32.lib
```
The problem is that `addWinSysRootLibSearchPaths` is called too late.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysUsGO2zoM_Br5QthQ6Nh-OfiQh4VPRVF0W_QsS4ytLSMGktxF_r5QdrtpFz0WMGzBM8OhhjQp-SUQjar7X3UPldnyKnFc2ATnt3M1i7uOqtevj35Q-qhwD1k2u8JJpLH3n5ZNWGrLUMsNkvkJavuexexq9uE71LJl1R4L7JihLq832bMP6ZqiSKEonC4mrwqnLAqnOwZbothiw35-MfhVXLVHoBglloOVjR0EySAXCqBw-E2GQ6F8FEi3G3kmkAjOR7JZ4vW17z8T-Jp8WMDRyWyc2c_ghBI8Syy-f1X884vXd3fVHt_H8M79y0pwiTIzncEnyKvJoHptnPvmw-M1fRbJH_z8SCba9ZPJa1K9LkxrmMlBFgE2mZrKja07tAdT0bjrB9xpbNuuWse-J_yv27ctopv1rjd4IkOHA5ajJqr8iBpxhzho3eGua-zQEu33ejCztoZOaq_pbDw3zD_OjcSl8iltNHaHYacrNjNxum0pYqBnuIEKsSxtHIumnrclqb1mn3K6V8k-M41v2ZdJBYVDhpMPDtjP0URPCXyAe7zVFnlcc76klyEonBaf121urJwVTqX666e-RHkimxVOt56SwunW888AAAD__wXnEAg">