Help with LLVM 3.2 linking error

Hello

I'm trying to link my project with llvm 3.2 libraries.
I haven't touched the project for some months. Previously I used to
link to an svn build of llvm 3.1 and
everything worked fine.

I've compiled llvm with ./configure --enable-libcpp --enable-cxx11
Currently I'm only using StringRef, SmallVector and FoldingSet, so I
only link libLLVMSupport and libLLVMCore.
Are they enough or do I need to link something else?

The error I get is the following:
Undefined symbols for architecture x86_64:
  "typeinfo for llvm::FoldingSetImpl", referenced from:
      typeinfo for llvm::FoldingSet<Type> in Program.o
ld: symbol(s) not found for architecture x86_64

Looking at the error the question is: is llvm built with RTTI support
by default? If not, how do I enable it?
i don't find an option in configure --help. If RTTI support is not the
issue, which can be the cause of the error?

Thank you,
Nicola

P.S: I'm sorry in case the list gets two copies of this message, I've
had connection troubles

Nicola Gigante <nicola.gigante@gmail.com> writes:

The error I get is the following:
Undefined symbols for architecture x86_64:
  "typeinfo for llvm::FoldingSetImpl", referenced from:
      typeinfo for llvm::FoldingSet<Type> in Program.o
ld: symbol(s) not found for architecture x86_64

Looking at the error the question is: is llvm built with RTTI support
by default?

No.

If not, how do I enable it?

AFAIK, there is no method for enabling RTTI (other than modifying the
makefiles).

Ok, but is it the source of the error? does it comes from the fact that I'm linking llvm libraries without rtti with
my code that is compiled _with_ rtti? I cannot disable rtti in my code so it's a problem (at least I think so.
I use dynamic_casts, is -fno-rtti only for typeinfo?)
It sounds strange to me, the same used to apply before, but I didn't
get this error last month with the old setup…

Any hint?

Thank you,
Nicola

Nicola Gigante <nicola.gigante@gmail.com> writes:

Nicola Gigante <nicola.gigante@gmail.com> writes:

The error I get is the following:
Undefined symbols for architecture x86_64:
"typeinfo for llvm::FoldingSetImpl", referenced from:
     typeinfo for llvm::FoldingSet<Type> in Program.o
ld: symbol(s) not found for architecture x86_64

Looking at the error the question is: is llvm built with RTTI support
by default?

No.

If not, how do I enable it?

AFAIK, there is no method for enabling RTTI (other than modifying the
makefiles).

Ok, but is it the source of the error? does it comes from the fact
that I'm linking llvm libraries without rtti with my code that is
compiled _with_ rtti?

I think so.

I cannot disable rtti in my code so it's a problem (at least I think so.
I use dynamic_casts, is -fno-rtti only for typeinfo?)

dynamic_cast depends on RTTI.

It sounds strange to me, the same used to apply before, but I didn't
get this error last month with the old setup…

Any hint?

You can try building LLVM with

CXXFLAGS=-frtti configure ....
CXXFLAGS=-frtti make ...

I'm not sure if CXXFLAGS takes precedence over the hard-coded -fno-rtti
in the makefiles, though.

With the cmake build, you can try as above (but replacing `configure'
with `cmake') or, better:

cmake -DLLVM_REQUIRES_RTTI=ON ... rest of cmake args ...

Adding an option for enabling RTTI on the cmake build is trivial. Dunno
about the `configure' build. You can try filing a feature request on
Bugzilla.

Ok, I've managed to refactor some code and remove uses of dynamic_cast.
Making my project work without rtti is a good thing anyway, but I'm curious
about why this problem didn't arised months ago with previours llvm versions...

Bye,
Nicola

Nicola Gigante <nicola.gigante@gmail.com> writes:

Adding an option for enabling RTTI on the cmake build is trivial. Dunno
about the `configure' build. You can try filing a feature request on
Bugzilla.

Ok, I've managed to refactor some code and remove uses of dynamic_cast.
Making my project work without rtti is a good thing anyway, but I'm curious
about why this problem didn't arised months ago with previours llvm versions...

A quick look at the VC history of lib/Support/Makefile explains it:

commit 475832cc0fbf622dfe1db484c2db57cc2d97a530
Author: Joerg Sonnenberger

    Don't explicitly require RTTI and EH.
    
    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166772 91177308-0d34-0410-b5e6-96231b3b80d8

That means that until that change LLVMSupport library was compiled with
RTTI and EH on.

Yeah, this explains everything.

Thank you!
Nicola