<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/54409>54409</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
lld-link's /winsysroot: doesn't handle system libraries passed on command line
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
nico
</td>
</tr>
</table>
<pre>
This works:
```
% cat hello.cc
#include <stdio.h>
int main() { printf("hello\n"); }
% out/gn/bin/clang-cl hello.cc /c /winsysroot ~/src/chrome/src/third_party/depot_tools/win_toolchain/vs_files/3bda71a11e
% out/gn/bin/lld-link /winsysroot:$HOME/src/chrome/src/third_party/depot_tools/win_toolchain/vs_files/3bda71a11e hello.obj
```
But if we explicitly pass libcmt.lib on the link line (which is implicitly linked above due to the `/DEFAULTLIB:libcmt.lib` in a .drectve in hello.obj), it fails:
```
% out/gn/bin/lld-link /winsysroot:$HOME/src/chrome/src/third_party/depot_tools/win_toolchain/vs_files/3bda71a11e hello.obj libcmt.lib
lld-link: error: could not open 'libcmt.lib': No such file or directory
```
Explicitly passing a `/machine:` flag makes it work again.
It should Just Work without needing `/machine:`.
(You can use the sysroot created by `llvm/utils/sysroot.py make-fake` for reproing as well.)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzNVMGO2yAQ_RrnMorlQLKODz5sNom61ba9tKp6WmHAMbsYLMBJ8_cdyCa7UVdqL5UaRdgw4-Hx3mMaK4711055OFj37DN6mxXrrDiPN8XL_zQlC-AsQCe1tjnn51WqDNejkJDROx-EsnmX0c0pqkyAnimTkWVGKsjKFQwOF9u0QFKpbHGHcYLxjK4wZX2FATe1Y8jIdodJ2yaW2nLNzG7K9QUKxMU4HJTxR--sDVhogwve8RjrnO3lZRo65cTjwFw44kzIwYbHYK32pwrpnXcJ9nbvH1ulZQzRRrByxmYz-UeEWoupVub5GlPkl8w_fPn075C9UGKbp_c1TONqDKBaOEiQPwetuAr6CAPzHrRqeB9yfIA1EDoJ6RQ4oLxkeegU7wDtovrLdzFBCmCN3UsQo4Rg04dxT7Jdb7a33x6-Ptyv8PCv1TEIygCDXDjJA36Js1foaAVyBypAy5T-C1v-j_y_5fL6d8J9hoigQDpnXXzhdtQCDNrXDtIg-vINZ6SMKZ8t-BFViHuDdSBUZNC647vsbK4FVmaHpJ-k6RnvUNdICqrRarbDq_osfeQ9tgNgOzxo_pb6-wC-SxA_jj7A95h1UAGXAhgpRSz_TvH8-r4sf9gRO4mB0ctklfOV5U6ygF5qjrGK1vseK41BJfpfkvLhmGBOWxwScOTAycHZdDbsZChAjg6aiJqKilZsEvD4sr7wTUr_my1AWOlR1BLbGzNCJ0xB9lFEx5xCViJ9iA2vBbd9j0npVkxGp-suhCG5lGyjDZGQsckxKxlxf35MEeMTSoVT5f2YjLOYz4tq0tW0pdWcz2TbVIVYzsvFvJqVLW8XLVkWjC4nmjVS-zpbrLBVGnmAVCK2zcV6ompSEFLQ2Q2h86pY5Pxm2VJCBW1mLWOSZvNCYhvWecSRW7ebuDpBasadx6BWPvjXYDTKDvVM22F9NqLErjaK20nat064fwFzE_mK">