Hi @llvm, I've already asked the following questions to the clang dev list but got no response. Maybe there is a wider audience at llvmdev and someone here can help me. The question actually boils down to: How can I compile clang with rtti enabled? And this was my original mail (with some points now better explained) to clang: <--BEGIN--> Hi @clang, I'm somewhat puzzled about using rtti when building clang under gcc (gcc 4.3.3, linux/ubuntu). (There is no problem under MSVC since rtti seems to be active there anyway). The appropriate line 348 in llvm/makefile.rules is commented out meaning that llvm is usually compiled using rtti. However every clang lib adds -fno-rtti to CXXFLAGS by hand. This is not filtered out by makefile.rules even if REQUIRES_RTTI is defined (IMHO -fno-rtti should be filtered out in that case). Now I'm two-way bewildered. First: why is line 348 commented out? This renders REQUIRES_RTTI useless. Does rtti (llvm) and non-rtti (clang) code work together at all? I had serious trouble when trying this with my own application and eventually resigned . I'm forced to use rtti in my application as it uses some clang libs but also some tr1 stuff (which apparently needs rtti) and boost. This leads me to the second question: How can I compile the clang libs with rtti enabled? Eventually I got it by editing every single Makefile in the "lib" sub-directories and commenting out the appropriate line "CXXFLAGS = -fno-rtti". However this can't be a proper solution. As stated earlier if REQUIRES_RTTI would be evaluated similiar to ENABLE_EXPENSIVE_CHECKS regarding rtti then it would be easy to enable rtti for clang. OTOH I'm not a makefile expert (to be honest I'm very far away from it). Thus maybe I'm just overlooking the right way to enable rtti for the clang libs. <--END--> Thanks in advance for any help... Best regards Olaf Krzikalla -- Olaf Krzikalla Technische Universitaet Dresden Zentrum fuer Informationsdienste und Hochleistungsrechnen Abteilung Verteiltes und Datenintensives Rechnen Zellescher Weg 12, 01069 Dresden Willersbau, Zimmer A105 Telefonnr.: +49 351 463-32442
Hi Olaf, On Fri, Sep 11, 2009 at 5:24 AM, Olaf Krzikalla <Olaf.Krzikalla at tu-dresden.de> wrote:> Hi @clang, > > I'm somewhat puzzled about using rtti when building clang under gcc (gcc > 4.3.3, linux/ubuntu). > (There is no problem under MSVC since rtti seems to be active there anyway). > The appropriate line 348 in llvm/makefile.rules is commented out meaning > that llvm is usually compiled using rtti. However every clang lib adds > -fno-rtti to CXXFLAGS by hand. > This is not filtered out by makefile.rules even if REQUIRES_RTTI is > defined (IMHO -fno-rtti should be filtered out in that case). > Now I'm two-way bewildered. > First: why is line 348 commented out? This renders REQUIRES_RTTI > useless. Does rtti (llvm) and non-rtti (clang) code work together at > all? I had serious trouble when trying this with my own application and > eventually resigned .Dunno, but I think its fine to fix REQUIRES_RTTI, I'll do so right now.> I'm forced to use rtti in my application as it uses some clang libs but > also some tr1 stuff (which apparently needs rtti) and boost. This leads > me to the second question:That doesn't necessarily explain why you are forced to use RTTI (just as clang doesn't use RTTI but LLVM does, and only the LLVM parts build with RTTI). - Daniel
Daniel Dunbar schrieb:>> Hi @clang, >> First: why is line 348 commented out? This renders REQUIRES_RTTI >> useless. Does rtti (llvm) and non-rtti (clang) code work together at >> all? I had serious trouble when trying this with my own application and >> eventually resigned . >> > > Dunno, but I think its fine to fix REQUIRES_RTTI, I'll do so right now >Thank you, this should fix my actual problem.>> I'm forced to use rtti in my application as it uses some clang libs but >> also some tr1 stuff (which apparently needs rtti) and boost. This leads >> me to the second question: >> > > That doesn't necessarily explain why you are forced to use RTTI (just > as clang doesn't use RTTI but LLVM does, and only the LLVM parts build > with RTTI). >Digging deeper into this yields two issues. First boost function (and gcc's tr1::function implementation) needs rtti. Two months ago there was a discussion at the boost mailing list about this requirement (Douglas Gregor was involved) and the conclusion was that it needs to be working without rtti. However at the moment I have to go with what we have. Secondly gcc produces 'missing typeinfo' linker errors if I create a object (of a class which was defined in a clang lib, e.g. AST) in my own lib (where rtti is activated). The gcc strategy for creating these typeinfo objects explains why there is no typeinfo object if the clang lib is compiled without rtti. I'm not sure if the linker error is necessary anyway but on the other hand mixing rtti and non-rtti this is nothing covered by the standard. Thus I have to live with that too. Eventually my only solution for both points was to turn on rtti for clang libs. Best regards Olaf Krzikalla