<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - llvm-ar works wrong with thin archives containing object files of same name"
   href="https://bugs.llvm.org/show_bug.cgi?id=45661">45661</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>llvm-ar works wrong with thin archives containing object files of same name
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>lld
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>All Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>qwertytmp1@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, smithp352@googlemail.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>For simplicity, I've prepared several bash files designed to be some sort of
PoC.

0.prepare_object_files.sh
```
#!/bin/bash

mkdir -p keyboard
mkdir -p mouse

touch keyboard/click.o
touch mouse/click.o

```

1.create_thin_archive.sh
```
#!/bin/bash

# set 1st argument as binutil's ar or llvm-ar
AR="$1"

rm -f mouse/built-in.o
rm -f keyboard/built-in.o
rm -f built-in.o

$AR -rcST mouse/built-in.o mouse/click.o \
&& \
$AR -rcST keyboard/built-in.o keyboard/click.o \
&& \
$AR -rcST built-in.o mouse/built-in.o keyboard/built-in.o \
&& \
cat built-in.o
```

To prepare environment (.o files and folders) run:
```
./0.prepare_object_files.sh
```

After this, run PoC with binutil's ar:
```
./1.create_thin_archive.sh ar
```

we'll get following output:
```
!<thin>

//                                              34        `
mouse/click.o/
keyboard/click.o/
...
```


After we run PoC with llvm-ar:
```
./1.create_thin_archive.sh llvm-ar
```

we'll get following output:
```
!<thin>

//                                              18        `
click.o/
click.o/
...
```

And here is a problem. 
Both click.o files located at the same directory level inside of thin archive,
generated by llvm-ar.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>