2

I'm using some LLVM static libs and boost::program_options in my test app. The problem is that source code that uses LLVM libs should be compiled with -fno-rtti (llvm-config -cxxflags return it in output

$ ./llvm-config --cxxflags
-I/Users/user/Documents/dev/src/llvm/installed_local/include  -DNDEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -g -fvisibility-inlines-hidden -fno-exceptions -fno-rtti -fno-common -Woverloaded-virtual -Wcast-qual

) but boost::program_options requires RTTI via boost::any:

/softdev/boost-1.56/include/boost/any.hpp:149:48: error: cannot use typeid with -fno-rtti
            return content ? content->type() : typeid(void);

Compile cmd for my app:

clang++ `${LLVM_BIN}/llvm-config --cxxflags` -I${LLVM_INCLUDE} -I${CLANG_INCLUDE} -I/softdev/boost-1.56/include -c ./lib_linker.cpp -o ./lib_linker_x86_64.o

What should i do in order to compile my app?

PS. The same problem with exceptions - LLVM turns off exceptions with -fno-exceptions but program_options requires them:

/softdev/boost-1.56/include/boost/program_options/value_semantic.hpp:355:20: error: cannot use typeid with -fno-rtti
            return typeid(T);
1
  • for exception, there is no prevention from using -fexception to compile your own project at all, simply remove/replace -fno-exception will be enough; a library is compiled w/o exception has no influence on your client code. for rtti, i guess most of the time you still don't use rtti for llvm Objects. You might need some scripts to handle cxxflags string manipulation. Oct 22, 2014 at 17:58

1 Answer 1

1

You need to recompile LLVM with RTTI and exceptions enabled.

4
  • i've found boost::program_options patch but it seems to be not full: svn.boost.org/trac/boost/ticket/10347. So i had to recompile LLVM with --enable-expensive-checks
    – 4ntoine
    Oct 14, 2014 at 16:49
  • This is surely not the flag which enabled RTTI and exceptions. Your LLVM installation will be very slowed by additional checks which does not make any sense. Oct 15, 2014 at 5:55
  • ok how can i recompile LLVM with RTTI support and without expensive checks?
    – 4ntoine
    Oct 15, 2014 at 6:05
  • i was able to do it using only REQUIRES_RTTI=1 env var while building
    – 4ntoine
    Oct 15, 2014 at 7:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.