[llvm-bugs] [Bug 33161] New: Missing symbols in libLLVM.so when built with clang-4.0

via llvm-bugs llvm-bugs at lists.llvm.org
Wed May 24 16:17:08 PDT 2017


https://bugs.llvm.org/show_bug.cgi?id=33161

            Bug ID: 33161
           Summary: Missing symbols in libLLVM.so when built with
                    clang-4.0
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: tstellar at gmail.com
                CC: chandlerc at gmail.com, dgregor at apple.com,
                    llvm-bugs at lists.llvm.org

Created attachment 18504
  --> https://bugs.llvm.org/attachment.cgi?id=18504&action=edit
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

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170524/865ff40d/attachment-0001.html>


More information about the llvm-bugs mailing list