[llvm-dev] undefined reference to typeinfo for CmpInst

Frank Winter via llvm-dev llvm-dev at lists.llvm.org
Fri Feb 19 10:46:04 PST 2016

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:

undefined reference to `typeinfo for llvm::CmpInst'
undefined reference to `typeinfo for llvm::UnaryInstruction'
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..






cmake -G "Unix Makefiles" \
-DCMAKE_CXX_FLAGS="-fno-rtti" \
-DCMAKE_C_FLAGS="-fno-rtti" \

More information about the llvm-dev mailing list