<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/54672>54672</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[ld.lld] Duplicate symbol error when processing archive files
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
cmd120
</td>
</tr>
</table>
<pre>
l1_a.c
```
void a()
{
b();
}
```
l1_rem.c
```
void rem()
{
printf("This rem will be a lazy symbol for lld, but will be disarded by gnu ld.\n");
}
```
l2.c
```
void b()
{
rem();
c();
}
```
l3.c
```
void rem()
{
printf("This rem will cause duplicate symbol error with lld.\n");
}
void c()
{
printf("end.\n");
}
```
Way to reproduce the error:
```
clang -c *.c
ar rcs lib1.a l1_a.o l1_rem.o
ar rcs lib2.a l2.o
ar rcs lib3.a l3.o
clang -fuse-ld=lld main.o -l1 -l2 -l3 -L.
```
Output:
```
./lib1.a: lazy definition of rem
./lib2.a(l2.o): reference to rem
./lib1.a(l1_rem.o): definition of rem
ld.lld: error: duplicate symbol: rem
>>> defined at l1_rem.c
>>> l1_rem.o:(rem) in archive ./lib1.a
>>> defined at l3.c
>>> l3.o:(.text+0x0) in archive ./lib3.a
clang-14: error: linker command failed with exit code 1 (use -v to see invocation)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJytU8GOmzAQ_Rq4jILADtnkwCFpuqdKvVTqsTL2ENw6dmSb7KZf3wFCdrubRFupyAjwPOa9eZ6pnTpVpvghMpnk2yRfJ4v8vIbPo9MKRMKWCVudAQ-b8QWgPu_zzRTaXk1C-T3u7zFQ-AbHwWsbmyHIvrU69FB40sZAjSDAiN8nCKd97Qw0zoMxKmGfoO7iBaR0EF6hgvoEO9uBUVlSfrKU70Pa2T3d9Q3VL_Xwy578qFv8fzslRRfIh-5gtBQRJ7_Qe3LsSce2t-2-KS8C5Afo0f6Tx9_FCaIjvQfvVCcRYoujuoSvr_4hjbA7mElI2HpyS3jwMoDRdZFRY_Q97eDceu4thPUQ9n6f9_t82j_TNGTfjBqLb8kn2AttKfPMFHQzujnMvmRXZX7t4qGLt4rIEvY4qiXE2MkKG2111M6Ca4azfo0k0eTvILt3dU2ABj3a3jH3Dl2M6MmA8Y8bBHT8_eQQYLL9XbuMfGd8wj-Pa0xIwyUivBnzC-TVdVFDlrDl0Msr0BaEl60-IrySfoeH3-fgU_4s4nNM2CZ_zq_z8IlnOOhZMf_LAaPtL_Qg3X4vrIJGaEMChnnBZx0poBAKasFlP16zY38IAZF4jo6MI49f5mQ6-VRVXK34SqRRR4NVUm7O3pdb2N6Y0BYtjZeTGIKmfpyKaEhPSDtvqjbGQxhqfqS1I4VdnZHuvkpznB4zyvETJTnyqEPoMNBLOV88sLStpFqpouRlLQqpZMlwuWqWebNoSp7zAjE1okYTer001BafYEjRD3i5TXXFcsZyzouCl6uyyKRkdTlXDwuVN_OaqWSeI82NyXodmfO71FeDpLrbBQoaHWJ4CQoqdGdxsKfPL7rYOl_JvSpYng7M1aD8D7oS5J0">