LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 22593 - lib/libLLVMRuntimeDyld.so build failure with gcc-5
Summary: lib/libLLVMRuntimeDyld.so build failure with gcc-5
Status: RESOLVED FIXED
Alias: None
Product: libraries
Classification: Unclassified
Component: System Library (show other bugs)
Version: trunk
Hardware: PC Linux
: P normal
Assignee: Unassigned LLVM Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-15 04:07 PST by octoploid
Modified: 2015-02-18 05:44 PST (History)
5 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description octoploid 2015-02-15 04:07:57 PST
Building llvm with gcc-5 I get:

[1456/1987] Linking CXX shared library lib/libLLVMRuntimeDyld.so
FAILED: : && /usr/bin/g++  -fPIC -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-maybe-uninitialized -Wnon-virtual-dtor -Wno-comment -std=c++11 -ffunction-sections -fdata-sections -O3 -fno-strict-aliasing -march=native -pipe  -Wl,-z,defs   -Wl,-O3 -Wl,--gc-sections -shared -Wl,-soname,libLLVMRuntimeDyld.so -o lib/libLLVMRuntimeDyld.so lib/ExecutionEngine/RuntimeDyld/CMakeFiles/LLVMRuntimeDyld.dir/RuntimeDyld.cpp.o lib/ExecutionEngine/RuntimeDyld/CMakeFiles/LLVMRuntimeDyld.dir/RuntimeDyldChecker.cpp.o lib/ExecutionEngine/RuntimeDyld/CMakeFiles/LLVMRuntimeDyld.dir/RuntimeDyldELF.cpp.o lib/ExecutionEngine/RuntimeDyld/CMakeFiles/LLVMRuntimeDyld.dir/RuntimeDyldMachO.cpp.o  lib/libLLVMMC.so lib/libLLVMObject.so lib/libLLVMSupport.so -Wl,-rpath,"\$ORIGIN/../lib" && :
lib/ExecutionEngine/RuntimeDyld/CMakeFiles/LLVMRuntimeDyld.dir/RuntimeDyld.cpp.o:RuntimeDyld.cpp:function llvm::RTDyldMemoryManager::getSymbolAddress(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&): error: undefined reference to 'llvm::RTDyldMemoryManager::getSymbolAddressInProcess(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
lib/ExecutionEngine/RuntimeDyld/CMakeFiles/LLVMRuntimeDyld.dir/RuntimeDyld.cpp.o:RuntimeDyld.cpp:function llvm::RuntimeDyldImpl::resolveExternalSymbols(): error: undefined reference to 'llvm::RTDyldMemoryManager::getSymbolAddressInProcess(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
lib/ExecutionEngine/RuntimeDyld/CMakeFiles/LLVMRuntimeDyld.dir/RuntimeDyldChecker.cpp.o:RuntimeDyldChecker.cpp:function llvm::RuntimeDyldCheckerImpl::getSymbolRemoteAddr(llvm::StringRef) const: error: undefined reference to 'llvm::RTDyldMemoryManager::getSymbolAddressInProcess(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
collect2: error: ld returned 1 exit status

The missing symbol is defined in lib/ExecutionEngine/CMakeFiles/LLVMExecutionEngine.dir/RTDyldMemoryManager.cpp.o
adding it to the link command "fixes" the issue.
Comment 1 octoploid 2015-02-15 06:46:13 PST
gcc correctly devirtualizes in this case:

markus@x4 llvm_build % cat RuntimeDyld.ii
namespace std
{
inline namespace __cxx11
{
}
template <typename> struct char_traits;
template <typename> class allocator;
namespace __cxx11
{
template <typename _CharT, typename = char_traits<_CharT>,
          typename = allocator<_CharT> >
class basic_string
{
  struct _Alloc_hider
  {
    _Alloc_hider (int);
  } _M_dataplus;

public:
  basic_string (void *) : _M_dataplus (0) {}
};
}
}

namespace llvm
{
class RTDyldMemoryManager
{
public:
  void getSymbolAddressInProcess (const std::basic_string<char> &);
  virtual int
  getSymbolAddress (std::basic_string<int>)
  {
    getSymbolAddressInProcess (0);
  }
};
class A
{
  RTDyldMemoryManager *MemMgr;
  void resolveExternalSymbols ();
};
void
A::resolveExternalSymbols ()
{
  MemMgr->getSymbolAddress (0);
}
}

markus@x4 llvm_build % g++ -O2 -c -std=c++11 RuntimeDyld.ii
markus@x4 llvm_build % nm RuntimeDyld.o| grep _ZN4llvm19RTDyldMemoryManager25getSymbolAddressInProcessERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
                 U _ZN4llvm19RTDyldMemoryManager25getSymbolAddressInProcessERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE

Also happens with gcc-4.9.
Comment 2 Lang Hames 2015-02-15 17:23:24 PST
Hi Octoploid,

Thanks for tracking this down. I've tried to fix this dependency issue in r229343. Could you try that out and see if it fixes the issue?

Cheers,
Lang.
Comment 3 octoploid 2015-02-16 02:29:59 PST
(In reply to comment #2)
> Thanks for tracking this down. I've tried to fix this dependency issue in
> r229343. Could you try that out and see if it fixes the issue?

Yes it does. Thanks.
Comment 4 Marc Dietrich 2015-02-17 08:36:17 PST
same error compiling mesa with gcc 5 and llvm 3.6(rc):

/bin/sh ../../../../libtool  --tag=CXX   --mode=link g++-5  -O2  -Wall -fno-strict-aliasing -fno-builtin-memcmp  -shared -module -no-undefined -avoid-version -Wl,--gc-sections -Wl,--no-undefined -Wl,--version-script=../../../../src/gallium/targets/omx/omx.sym -L/usr/lib64  -O2  -o libomx_mesa.la -rpath /usr/lib64/bellagio libomx_mesa_la-target.lo ../../../../src/gallium/state_trackers/omx/libomxtracker.la ../../../../src/gallium/auxiliary/libgalliumvlwinsys.la ../../../../src/gallium/auxiliary/libgalliumvl.la ../../../../src/gallium/auxiliary/libgallium.la ../../../../src/util/libmesautil.la -lomxil-bellagio  -lX11-xcb -lX11 -lxcb-dri2 -lxcb  -ldrm  -lm  -lpthread -ldl ../../../../src/loader/libloader.la  ../../../../src/gallium/drivers/r600/libr600.la -ldrm_radeon  -ldrm   ../../../../src/gallium/winsys/radeon/drm/libradeonwinsys.la ../../../../src/gallium/drivers/radeon/libradeon.la  -lLLVMAsmParser -lLLVMR600CodeGen -lLLVMipo -lLLVMVectorize -lLLVMR600AsmParser -lLLVMR600Desc -lLLVMR600Info -lLLVMR600AsmPrinter -lLLVMBitWriter -lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMCodeGen -lLLVMScalarOpts -lLLVMProfileData -lLLVMInstCombine -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMX86Desc -lLLVMMCDisassembler -lLLVMX86Info -lLLVMX86AsmPrinter -lLLVMX86Utils -lLLVMMCJIT -lLLVMTarget -lLLVMRuntimeDyld -lLLVMExecutionEngine -lLLVMObject -lLLVMMCParser -lLLVMBitReader -lLLVMMC -lLLVMCore -lLLVMSupport -lrt -ldl -ltinfo -latomic -lpthread -lz -lm 
libtool: link: g++-5  -fPIC -DPIC -shared -nostdlib /usr/lib64/gcc/x86_64-suse-linux/5/../../../../lib64/crti.o /usr/lib64/gcc/x86_64-suse-linux/5/crtbeginS.o  .libs/libomx_mesa_la-target.o  -Wl,--whole-archive ../../../../src/gallium/state_trackers/omx/.libs/libomxtracker.a ../../../../src/gallium/auxiliary/.libs/libgalliumvlwinsys.a ../../../../src/gallium/auxiliary/.libs/libgalliumvl.a ../../../../src/gallium/auxiliary/.libs/libgallium.a ../../../../src/util/.libs/libmesautil.a ../../../../src/loader/.libs/libloader.a ../../../../src/gallium/drivers/r600/.libs/libr600.a ../../../../src/gallium/winsys/radeon/drm/.libs/libradeonwinsys.a ../../../../src/gallium/drivers/radeon/.libs/libradeon.a -Wl,--no-whole-archive  -Wl,-rpath -Wl,/usr/lib64 -Wl,-rpath -Wl,/usr/lib64 -L/usr/lib64 -lnettle /usr/lib64/libomxil-bellagio.so -lX11-xcb -lX11 -lxcb-dri2 -lxcb -lexpat /usr/lib64/libdrm_radeon.so /usr/lib64/libdrm.so -lelf -lLLVMAsmParser -lLLVMR600CodeGen -lLLVMipo -lLLVMVectorize -lLLVMR600AsmParser -lLLVMR600Desc -lLLVMR600Info -lLLVMR600AsmPrinter -lLLVMBitWriter -lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMCodeGen -lLLVMScalarOpts -lLLVMProfileData -lLLVMInstCombine -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMX86Desc -lLLVMMCDisassembler -lLLVMX86Info -lLLVMX86AsmPrinter -lLLVMX86Utils -lLLVMMCJIT -lLLVMTarget -lLLVMRuntimeDyld -lLLVMExecutionEngine -lLLVMObject -lLLVMMCParser -lLLVMBitReader -lLLVMMC -lLLVMCore -lLLVMSupport -lrt -ldl -ltinfo -latomic -lpthread -lz -L/usr/lib64/gcc/x86_64-suse-linux/5 -L/usr/lib64/gcc/x86_64-suse-linux/5/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/opt/intel/composer_xe_2015.0.090/compiler/lib/intel64 -L/opt/intel/composer_xe_2015.0.090/ipp/../compiler/lib/intel64 -L/opt/intel/composer_xe_2015.0.090/ipp/lib/intel64 -L/opt/intel/composer_xe_2015.0.090/mkl/lib/intel64 -L/opt/intel/composer_xe_2015.0.090/tbb/lib/intel64/gcc4.4 -L/usr/lib64/gcc/x86_64-suse-linux/5/../../../../x86_64-suse-linux/lib -L/usr/lib64/gcc/x86_64-suse-linux/5/../../.. -lstdc++ -lm -lc -lgcc_s /usr/lib64/gcc/x86_64-suse-linux/5/crtendS.o /usr/lib64/gcc/x86_64-suse-linux/5/../../../../lib64/crtn.o  -O2 -Wl,--gc-sections -Wl,--no-undefined -Wl,--version-script=../../../../src/gallium/targets/omx/omx.sym -O2   -Wl,-soname -Wl,libomx_mesa.so -o .libs/libomx_mesa.so
../../../../src/gallium/auxiliary/.libs/libgallium.a(lp_bld_misc.o):lp_bld_misc.cpp:function llvm::RTDyldMemoryManager::getSymbolAddress(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&): error: undefined reference to 'llvm::RTDyldMemoryManager::getSymbolAddressInProcess(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
collect2: error: ld returned 1 exit status
Comment 5 Lang Hames 2015-02-17 12:24:56 PST
CCing Hans Wennborg, who's managing the release.

Hans - Would it be possible to cherry-pick r229343 into the release branch?
Comment 6 Marc Dietrich 2015-02-17 15:23:08 PST
I already tried this with no success. Maybe a mesa patch is needed instead? My lib shows getSymbolAddressInProcess is an unresolved symbol for some reason (getSymbolAddress is ok).
Comment 7 Lang Hames 2015-02-17 15:48:38 PST
Hi Mark,

You might need to add RuntimeDyld to your list of dependencies a la r229351.

Cheers,
Lang.
Comment 8 Hans Wennborg 2015-02-17 15:50:08 PST
(In reply to comment #5)
> CCing Hans Wennborg, who's managing the release.
> 
> Hans - Would it be possible to cherry-pick r229343 into the release branch?

Since we're doing an rc4 anyway, I've merged it (and r229351) in r229553.
Comment 9 Lang Hames 2015-02-17 15:51:57 PST
Thanks Hans.
Comment 10 Marc Dietrich 2015-02-18 04:01:12 PST
We are already linking agaist LLVMRuntimeDyld.so, but the problem is that the symbol is unresolvable:

# nm /usr/lib64/libLLVMRuntimeDyld.so  | grep InProc
U _ZN4llvm19RTDyldMemoryManager25getSymbolAddressInProcessERKSs

Somehow this works with gcc-4.9 but fails with gcc-5.
Comment 11 octoploid 2015-02-18 04:35:14 PST
(In reply to comment #10)
> We are already linking agaist LLVMRuntimeDyld.so, but the problem is that
> the symbol is unresolvable:
> 
> # nm /usr/lib64/libLLVMRuntimeDyld.so  | grep InProc
> U _ZN4llvm19RTDyldMemoryManager25getSymbolAddressInProcessERKSs
> 
> Somehow this works with gcc-4.9 but fails with gcc-5.

gcc-5 uses a new C++ ABI. If you want to use LLVM libraries with gcc-5
you must build LLVM with gcc-5, too. Building LLVM with gcc-4.9 and 
then using gcc-5 to build e.g. mesa will fail. 
Another possibility is to use -D_GLIBCXX_USE_CXX11_ABI=0 with gcc-5 to 
switch back to the old ABI.
Both ABIs live in the same .so file.
Comment 12 Marc Dietrich 2015-02-18 05:44:13 PST
ahh, you are right. Using -D_GLIBCXX_USE_CXX11_ABI=0 fixes the problem. Sorry for the noise.