<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 - cross linker with system directory fails with misleading error message"
href="https://bugs.llvm.org/show_bug.cgi?id=43738">43738</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>cross linker with system directory fails with misleading error message
</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>normal
</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>denik@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, peter.smith@linaro.org
</td>
</tr></table>
<p>
<div>
<pre>Let's build arm64 object file.
$ clang --sysroot=/build/arm64-generic --target=aarch64 -o test.o -c test.c
Sanity check that lld passes with the correct library directory:
$ ld.lld --sysroot=/build/arm64-generic -m aarch64linux -shared -o test.so
-L/build/arm64-generic/usr/lib64 test.o -lc
$ echo $?
0
When we add a system directory BEFORE the sysroot library directory lld fails
with misleading error message:
$ ld.lld --sysroot=/build/arm64-generic -m aarch64linux -shared -o test.so
-L/usr/lib64 -L/build/arm64-generic/usr/lib64 test.o -lc
ld.lld: error: test.o is incompatible with aarch64linux
$ echo $?
1
If we add a system directory AFTER the sysroot library directory lld passes:
$ ld.lld --sysroot=/build/arm64-generic -m aarch64linux -shared -o test.so
-L/build/arm64-generic/usr/lib64 -L/usr/lib64 test.o -lc
$ echo $?
0
Here is the behavior of ld.gold (case when lld failed).
It skips incompatible libraries until it finds the right one:
$ ld.gold --sysroot=/build/arm64-generic -m aarch64linux -shared -o test.so
-L/usr/lib64 -L/build/arm64-generic/usr/lib64 test.o -lc
/usr/x86_64-pc-linux-gnu/binutils-bin/2.27.0/ld.gold.real: warning: skipping
incompatible /usr/lib64/libc.so while searching for c
$ echo $?
0</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>