<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/74363>74363</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
non-system clang compiler couldn't use/find system compiler-rt
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
MehdiChinoune
</td>
</tr>
</table>
<pre>
When building a clang compiler with `-DCLANG_DEFAULT_RTLIB=compiler-rt` It finds the system compiler-rt and links against it, but after installation it couldn't use/find the system compiler-rt and wants a compiler-rt that exist in its installation path.
```
ld: error: could not open 'C:/_/B/src/build-CLANG64-instrument/lib/clang/17/lib/windows/libclang_rt.builtins-x86_64.a': No such file or directory
```
This doesn't happen with both libc++ and libunwind when clang configured to use them (`-DCLANG_DEFAULT_UNWINDLIB=libunwind -DCLANG_DEFAULT_CXX_STDLIB=libc++`), So something wrong with compiler-rt searching method.
Why does clang link and use any system libgcc/gcc_eh library, but requires compiler-rt to be installed in the same path.
I think the issue comes from https://github.com/llvm/llvm-project/blob/6886a52d/clang/lib/Driver/ToolChain.cpp#L660 and https://github.com/llvm/llvm-project/blob/6886a52d6dbefff77f33de12ff85d654e2557f81/clang/lib/Driver/ToolChain.cpp#L670 because It uses `llvm::sys::path` to search in.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyklF2v4jYQhn-NuRmBEucLLnLBR1MhnZ6LLqvdO-TEE-KuY1PbWZZ_X42BHk57VGlVCYXYjGbemfdhhPfqZBBrVmxYsZuJKQzW1b_hINV2UMZOBmetldf6y4AG2klpqcwJBHRamBN0djwrjQ4uKgzAymS-276sX3897n5p1p9fDsffDy_7Dct2j8C5C6xMYB-gV0Z6CAOCv_qAIzyFgDAStDLfPIiTUMYHUIHxLbRTANEHdECXQmsRlDWgAnR20tIwXgWYPDLeUP7_Sn8RJnhq5Ok-DCIA_lBUj7L692XOIgwLluxYsmZlcv_Eo5YsWwM6Zx29RDFgbAB7RgOMV1uWrRlvjow3G8Yb7zrGmzjOeRxYmc-plJtGNIHxRquW8SYOmfEmrf6-uigj7cXfzvH3owsLyhSU8fMfy_JY5gvBeEVCXi34qRugVxrBOpDKYResu37YxWFQHqRFf5vjIM6kPlrb2jAAVWR8w_jmblA7GdIDF4LjQYTp1WlyKCFYsoI8GIHx5Qd0fH79sn_d3Qh5y_bPqO3Xr8dPh7ewuwaSzVdExScL3o4YBkLz4iw9SfSztR6F62IABVp59_HLcI0d39UTc7E3Ei7M9QGPVu2pI8tOXXfEOAkn3PWBpMM_J-UoyzNMFlp8AISSiIo4ihHfkRSfeyD132KE8n5CSoUeemdHGEI4-xtAJEGFYWoXnR0JAv398TU_O_sHdkRPqy2xUi6XpSi4fCLpBtHOqe_oGG8O1urtIJRZdOcz49lLWSax__9bspQt9n1fVX2WSUx53y8LWRY58qKo-mX6M5KqBFrsBFmyj_9uT5smysjWLFv7q7-90FRpuwR7txuUWcxknclVthIzrNMqSat0labpbKiXVZJJ7FeY8z6XVdIXOUcssMp5seqXyUzVPOFZypM8XeVFUi7aTOZpz7MWyyTDZcbyBEeh9IK0LKw7zaJ1dZVnZTbTokXt42bl_N4spyXr6ji7djp5lida-eDfMgQVNNbGmvljb71ftB_vuX_vuNnkdP3TLkb9tFxiC38FAAD__0gMARY">