<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 - Missing symbols in libLLVM.so when built with clang-4.0"
href="https://bugs.llvm.org/show_bug.cgi?id=33161">33161</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Missing symbols in libLLVM.so when built with clang-4.0
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</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>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>tstellar@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>chandlerc@gmail.com, dgregor@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=18504" name="attach_18504" title="Test Program">attachment 18504</a> <a href="attachment.cgi?id=18504&action=edit" title="Test Program">[details]</a></span>
Test Program
There are some symbols missing from libLLVM.so when built with clang-4.0. I
can reproduce this when building libLLVM.so from trunk (r303802) and libLLVM.so
from the llvm 4.0 source. I cannot reproduce this when libLLVM.so is built
with gcc-4.8.5.
I think the issue has something to do with the use of 'extern template class
AnalysisManager<Loop, LoopStandardAnalysisResults &>;' in
LoopAnalysisManager.h, but I'm not sure if it is a bug in the LLVM source code
that just happens to work when compiled by gcc, or if it is a miscompile by
clang.
I was looking at the difference between the clang built and llvm built shared
objects and I see:
$ nm --demangle libLLVM-4.0.so.clang4.0 \
| grep 'llvm::AnalysisManager<llvm::Loop,
llvm::LoopStandardAnalysisResults\&>::AnalysisManager(bool)'
00000000013af5f0 W llvm::AnalysisManager<llvm::Loop,
llvm::LoopStandardAnalysisResults&>::AnalysisManager(bool)
00000000013af5f0 W llvm::AnalysisManager<llvm::Loop,
llvm::LoopStandardAnalysisResults&>::AnalysisManager(bool)
$ nm --demangle check-for-broken-symbol.sh libLLVM-4.0.so.gcc4.8.5 \
| grep 'llvm::AnalysisManager<llvm::Loop,
llvm::LoopStandardAnalysisResults\&>::AnalysisManager(bool)'
00000000013f12d0 W llvm::AnalysisManager<llvm::Loop,
llvm::LoopStandardAnalysisResults&>::AnalysisManager(bool)
00000000013f12d0 W llvm::AnalysisManager<llvm::Loop,
llvm::LoopStandardAnalysisResults&>::AnalysisManager(bool)
00000000013f12d0 t llvm::AnalysisManager<llvm::Loop,
llvm::LoopStandardAnalysisResults&>::AnalysisManager(bool)
00000000013f12d0 t llvm::AnalysisManager<llvm::Loop,
llvm::LoopStandardAnalysisResults&>::AnalysisManager(bool)
Attached is a simple program to demonstrate the issue. Make sure to set
LLVM_LIB_PATH and LLVM_INCLUDE_PATH in the Makefile to the correct paths for
your system, and make sure that libLLVM.so has been built by clang.
To reproduce:
$ make gcc-main
gcc -D__STDC_CONSTANT_MACROS -std=c++11 -o gcc-main.o -c main.cpp -I
/home/tstellar/llvm-project/llvm-install/include/
gcc -o gcc-main -L /home/tstellar/llvm-project/llvm-install/lib -lLLVM-4.0
-lstdc++ gcc-main.o
gcc-main.o: In function `main':
main.cpp:(.text+0x1c): undefined reference to
`llvm::AnalysisManager<llvm::Loop,
llvm::LoopStandardAnalysisResults&>::AnalysisManager(bool)'
I also noticed that if I build main.cpp with clang, then the program links
correctly:
$ make clang-main
clang -D__STDC_CONSTANT_MACROS -std=c++11 -o clang-main.o -c main.cpp -I
/usr/include/
gcc -o clang-main -L /usr/lib -lLLVM -lstdc++ clang-main.o</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>