typeinfo for llvm::MCAsmInfo is missing

Hi all.

I fully understand that the problem is a bit OT for llvmdev, but I'm stuck for two days now and I really need some direct push.

To the problem. I have a C++ shared library, that's working with llvm C++ api. Consider a function:

static Object llvm_Target_createMCAsmInfo(Object self, Object tripleName)
{
  llvm::Target target = from_ruby<llvm::Target>(self);
  char const *triple = from_ruby<char const *>(tripleName);
  
  llvm::MCAsmInfo *MAI = target.createMCAsmInfo(triple);
  return to_ruby<llvm::MCAsmInfo>(*MAI);
}

The problem here, is it's ok to use llvm::MCAsmInfo objects, but as soon as I use it in the cast (e.g. to_ruby), I immediately get an undefined symbol __ZTIN4llvm9MCAsmInfoE. Similar symbols for other llvm classes are there in my library's .o file, this one does not.

Any hints?

Llvm typically doesn't build with RTTI enabled. Perhaps that's what you're running into?

Jim

I've actually tried to compile both LLVM and my lib with -frtti with same results.

Vladimir Pouzanov <farcaller@gmail.com> writes:

From: llvmdev-bounces@cs.uiuc.edu [mailto:llvmdev-bounces@cs.uiuc.edu]

>> Llvm typically doesn't build with RTTI enabled. Perhaps that's what
>> you're running into?
>>
> I've actually tried to compile both LLVM and my lib with -frtti with
> same results.

Please show the exact commands you used for building LLVM with RTTI
support.

It would also help if you repeat your recipe for building LLVM but appending
to your `make' command the text "VERBOSE=1" and then show the compiler
command line for one .cpp file (lib/MC/MCAsmInfo.cpp is the best
candidate.)

There is (was?) a CMake variable for this if you're going that route. Setting LLVM_REQUIRES_RTTI=1 enabled an RTTI build that I haven't had issues with. I don't know what the ./configure equivalent is, sorry.

-Gordon

Gordon Keiser <gkeiser@arxan.com> writes:

There is (was?) a CMake variable for this if you're going that route.
Setting LLVM_REQUIRES_RTTI=1 enabled an RTTI build that I haven't had
issues with. I don't know what the ./configure equivalent is, sorry.

LLVM_REQUIRES_RTTI is an internal variable. It works as you say, but
there is no guarantee about it.

Adding a proper option for enabling RTTI on the CMake build is trivial,
and IMO it is useful too.

Thanks Oscar, I wasn't aware of that. I've been using it for some time now, and don't use the CMake GUI so I always assumed it was a standard option. I'll pass this along. :slight_smile:

-Gordon

Good. Copying llvmdev for the record.

Vladimir Pouzanov <farcaller@gmail.com> writes: