[LLVMdev] RTTI Madness
Thomas B. Jablin
tjablin at cs.princeton.edu
Thu Jan 28 12:45:07 PST 2010
Lately LLVM has been adding -fno-rtti to most of the compiler. I have a pass which uses LoopPass and which inherits from FunctionPass and a class of my own. If I compile my code with ENABLE_RTTI=1, I can't dynamically load the shared object since it won't be able to find the symbol for LoopPass's typeinfo.
undefined symbol: _ZTIN4llvm8LoopPassE
$ c++filt _ZTIN4llvm8LoopPassE
typeinfo for llvm::LoopPass
Alternatively, if I compile with ENABLE_RTTI=1 then the virtual table for my FunctionPass will be messed up. FunctionPass comes from Pass.cpp in ./lib/VMCore which is built with ENABLE_RTTI=1. The difference in the size of the virtual tables between LLVM's code, which is built with RTTI, and my code, which is built without causes the offsets into my derived class's virtual table to be wrong.
What is the recommended course of action?
I don't mind disabling RTTI globally, but I don't understand how RTTI and non-RTTI code can be correctly dynamically linked when there is multiple-inheritance. Unless someone else has a better idea, my preference would be compiling with ENABLE_RTTI=1 globally until the entire compiler is ready to go RTTI-free.
Alternatively, if anyone knows a safe way to dynamically link RTTI and non-RTTI code, I'd appreciate their expertise.
More information about the llvm-dev