<html>
<head>
<base href="https://llvm.org/bugs/" />
</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 --- - lld reports "Undefined symbol" for shared lib's dependencies"
href="https://llvm.org/bugs/show_bug.cgi?id=23035">23035</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>lld reports "Undefined symbol" for shared lib's dependencies
</td>
</tr>
<tr>
<th>Product</th>
<td>lld
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>FreeBSD
</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>davide@freebsd.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>emaste@freebsd.org
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>When a .so depends on another .so, but the 2nd .so is not a direct dependency
of the binary and is not specified on the command line, lld fails due to
"Undefined symbol" errors on the first .so.
[ main.c ]
#include <stdio.h>
int fn1(int);
int
main(int argc, char *argv[])
{
printf("fn1(argc) = %d\n", fn1(argc));
return 0;
}
[ lib1.c ]
int fn2(int);
int
fn1(int a)
{
return fn2(a + 1);
}
[ lib2.c ]
int
fn2(int a)
{
return a + 2;
}
Build the shared libs and main.o:
% clang -Wall -g -fPIC -shared -o lib2.so lib2.c
% clang -Wall -g -fPIC -shared -o lib1.so ./lib2.so lib1.c
% clang -Wall -g -o main.o -c main.c
Link with bfd ld:
% clang -Wall -g -rpath . -o main main.o lib1.so
% ./main
fn1(argc) = 4
Link with lld:
% clang -B. -Wall -g -rpath . -o main main.o lib1.so
warning: ignoring unknown argument: --enable-new-dtags
Undefined symbol: lib1.so: fn2
symbol(s) not found
clang: error: linker command failed with exit code 1 (use -v to see invocation)</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>