[llvm-dev] undefined reference to typeinfo for CmpInst

Frank Winter via llvm-dev
Fri, 19 Feb 2016 19:09:11 -0000

Solved. Recompiling LLVM with "-fno-rtti -fPIC" and building my
application with "-fno-rtti" solved the issue.

As a result of this experiment I conclude that the LLVM library cannot
be used in applications that make use of RTTI. I guess that's a bug.

Frank


On 02/19/2016 01:46 PM, Frank Winter via llvm-dev wrote:
> Hi all,
>
> I am having some some trouble with LLVM 3.8... I built it with GCC 4.8.2
> with cmake and no special CXX/C flags. That means in case of GCC that
> RTTI is switched on, I believe.
>
> However, building my MCJIT application against the just built LLVM and
> linking results in:
>
>
libqdp.a(qdp_llvm.o):(.rodata._ZTIN4llvm8FCmpInstE[_ZTIN4llvm8FCmpInstE]+0x10):
> undefined reference to `typeinfo for llvm::CmpInst'
>
libqdp.a(qdp_jit_util.o):(.rodata._ZTIN4llvm16ExtractValueInstE[_ZTIN4llvm16ExtractValueInstE]+0x10):
> undefined reference to `typeinfo for llvm::UnaryInstruction'
>
libqdp.a(qdp_jit_util.o):(.rodata._ZTIN4llvm15InsertValueInstE[_ZTIN4llvm15InsertValueInstE]+0x10):
> undefined reference to `typeinfo for llvm::Instruction'
> collect2: error: ld returned 1 exit status
>
>
> I searched for this and there seem to be two common causes for this
>
> 1) There are virtual functions declared but never defined (I don't
think
> that's the case, since LLVM has nightly tests)
>
> 2) Something's wrong with the RTTI settings.
>
> I greped the LLVM source and it seems typeinfo is never used, so I
> though it's a good idea to build LLVM with RTTI switched off:
>
> However, building LLVM with RTTI switched off (see build script below)
> results during the build in
>
> /usr/bin/ld: ../../lib/libLLVMX86CodeGen.a(X86AsmPrinter.cpp.o):
> relocation R_X86_64_32S against `.rodata' can not be used when making a
> shared object; recompile with -fPIC
> ../../lib/libLLVMX86CodeGen.a: could not read symbols: Bad value
> collect2: error: ld returned 1 exit status
>
> I am not sure how to proceed from here..
>
>
>
> Thanks,
> Frank
>
>
>
> SRC=$HOME/svn/llvm-3.8
>
> CMAKE_BUILD_TYPE="Debug"
> CMAKE_INSTALL_PREFIX="$HOME/toolchain/install/llvm-3.8"
> LLVM_TARGETS_TO_BUILD="X86"
>
> CXX="/dist/gcc-4.8.2/bin/g++"
> CC="/dist/gcc-4.8.2/bin/gcc"
>
> #-DBUILD_SHARED_LIBS="ON" \
>
>
> cmake -G "Unix Makefiles" \
> -DCMAKE_CXX_FLAGS="-fno-rtti" \
> -DCMAKE_C_FLAGS="-fno-rtti" \
> -DCMAKE_CXX_COMPILER=$CXX \
> -DCMAKE_C_COMPILER=$CC \
> -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE \
> -DCMAKE_INSTALL_PREFIX=$CMAKE_INSTALL_PREFIX \
> -DLLVM_TARGETS_TO_BUILD=$LLVM_TARGETS_TO_BUILD \
> $SRC
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev