Results 1 to 3 of 3

Thread: Problem using LLVM with Qt 5.0.0 within on Ubuntu

  1. #1
    Join Date
    Mar 2010
    Posts
    319
    Thanks
    1
    Thanked 14 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Problem using LLVM with Qt 5.0.0 within on Ubuntu

    Hi,

    I use LLVM (3.2) in my project (Qt 5.0.0) and it works as expected on Windows and OS X, but on Ubuntu it just crashes. If I start my application, don't use any of the LLVM-specific stuff in my application, and try to quit my application, then I get the following debug traces:

    Qt Code:
    1. 0 __memmove_ssse3 memcpy-ssse3.S 1682 0x1348f8c
    2. 1 llvm::PassRegistry::removeRegistrationListener(llvm::PassRegistrationListener*) /usr/lib/i386-linux-gnu/libLLVM-3.0.so.1 0xb0278ddb
    3. 2 llvm::PassRegistrationListener::~PassRegistrationListener() /usr/lib/i386-linux-gnu/libLLVM-3.0.so.1 0xb026aa06
    4. 3 llvm::PassNameParser::~PassNameParser() /usr/lib/i386-linux-gnu/libLLVM-3.0.so.1 0xb026aca2
    5. 4 llvm::cl::list<llvm::PassInfo const*, bool, llvm::PassNameParser>::~list() /home/me/myApp/build/plugins/myApp/libLLVM.so 0xb31eb8a4
    6. 5 __run_exit_handlers exit.c 78 0x1242f51
    7. 6 __GI_exit exit.c 100 0x1242fdd
    8. 7 __libc_start_main libc-start.c 258 0x12294db
    9. 8 _start 0x8068ca1
    To copy to clipboard, switch view to plain text mode 
    If you look at line 4, my application uses my version of LLVM (which I build as a Qt plugin), but then at lines 1, 2 and 3, we can see that my application somehow decided to use the system version of LLVM. Why is that? I have no idea!

    All I know is that it used to work perfectly fine using Qt 4.8.x. I thought for a moment that it might be related to OpenGL/3D (Qt 5.0.0 uses OpenGL no matter what now, right?), especially since my Ubuntu box is in fact a virtual machine with no 3D acceleration (i.e. Mesa would take over and use llvmpipe?), but I then tried using the Ubuntu live CD (with 3D acceleration), and I got the same result, so I am puzzled...

    Otherwise, if I manually rename the system version of LLVM (so that my application cannot 'see' it), then everything works as expected (i.e. no crash) but I obviously don't want and, in fact, can't really do that!

    FWIW, here is another trace I get when starting my application and then trying to do some LLVM-specific stuff in my application:

    Qt Code:
    1. 0 llvm::FoldingSetNodeID::AddPointer(void const*) /usr/lib/i386-linux-gnu/libLLVM-3.0.so.1 0xb074f37a
    2. 1 clang::FunctionProtoType::Profile(llvm::FoldingSetNodeID&, clang::QualType, clang::QualType const*, unsigned int, clang::FunctionProtoType::ExtProtoInfo const&, clang::ASTContext const&) /home/me/myApp/build/libLLVM.so 0x43a6b2e
    3. 2 clang::FunctionProtoType::Profile(llvm::FoldingSetNodeID&, clang::ASTContext const&) /home/me/myApp/build/libLLVM.so 0x43a6dd4
    4. 3 llvm::ContextualFoldingSet<clang::FunctionProtoType, clang::ASTContext&>::NodeEquals(llvm::FoldingSetImpl::Node*, llvm::FoldingSetNodeID const&, unsigned int, llvm::FoldingSetNodeID&) const /home/me/myApp/build/libLLVM.so 0x427d59f
    5. 4 llvm::FoldingSetImpl::FindNodeOrInsertPos(llvm::FoldingSetNodeID const&, void*&) /usr/lib/i386-linux-gnu/libLLVM-3.0.so.1 0xb074fb67
    6. 5 clang::ASTContext::getFunctionType(clang::QualType, clang::QualType const*, unsigned int, clang::FunctionProtoType::ExtProtoInfo const&) const /home/me/myApp/build/libLLVM.so 0x426ecbb
    7. 6 clang::ASTContext::GetBuiltinType(unsigned int, clang::ASTContext::GetBuiltinTypeError&, unsigned int*) const /home/me/myApp/build/libLLVM.so 0x4274243
    8. 7 clang::Sema::LazilyCreateBuiltin(clang::IdentifierInfo*, unsigned int, clang::Scope*, bool, clang::SourceLocation) /home/me/myApp/build/libLLVM.so 0x48baa24
    9. 8 ?? /home/me/myApp/build/libLLVM.so 0x49fde04
    10. 9 clang::Sema::LookupName(clang::LookupResult&, clang::Scope*, bool) /home/me/myApp/build/libLLVM.so 0x4a03d13
    11. 10 clang::Sema::HandleDeclarator(clang::Scope*, clang::Declarator&, llvm::MutableArrayRef<clang::TemplateParameterList*>) /home/me/myApp/build/libLLVM.so 0x48cb270
    12. 11 clang::Sema::ActOnDeclarator(clang::Scope*, clang::Declarator&) /home/me/myApp/build/libLLVM.so 0x48cb8f3
    13. 12 clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&) /home/me/myApp/build/libLLVM.so 0x47196e1
    14. 13 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, unsigned int, bool, clang::SourceLocation*, clang::Parser::ForRangeInit*) /home/me/myApp/build/libLLVM.so 0x4725883
    15. 14 clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec&, clang::AccessSpecifier) /home/me/myApp/build/libLLVM.so 0x477563f
    16. 15 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*, clang::AccessSpecifier) /home/me/myApp/build/libLLVM.so 0x4775d79
    17. 16 clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) /home/me/myApp/build/libLLVM.so 0x4779c77
    18. 17 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) /home/me/myApp/build/libLLVM.so 0x4779f48
    19. 18 clang::ParseAST(clang::Sema&, bool, bool) /home/me/myApp/build/libLLVM.so 0x470e49c
    20. 19 clang::ASTFrontendAction::ExecuteAction() /home/me/myApp/build/libLLVM.so 0x4671a57
    21. 20 clang::CodeGenAction::ExecuteAction() /home/me/myApp/build/libLLVM.so 0x456db42
    22. ... <More>
    To copy to clipboard, switch view to plain text mode 
    Again, you can see that sometimes my application uses its version of LLVM while, at other times, it uses the system version of LLVM...!?

    Now, I wouldn't expect many people to use LLVM in their project, but... how would you go about handling the case where your application uses its version of a library which is also used by your Linux system?...

    Cheers, Alan.

  2. #2
    Join Date
    Mar 2010
    Posts
    319
    Thanks
    1
    Thanked 14 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Problem using LLVM with Qt 5.0.0 within on Ubuntu

    Nobody, really?...

  3. #3
    Join Date
    Mar 2010
    Posts
    319
    Thanks
    1
    Thanked 14 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Problem using LLVM with Qt 5.0.0 within on Ubuntu

    Ok, I have spent some time googling around and... I have found some kind of a solution to my problem. I guess I should have mentioned that my Ubuntu box is, in fact, an Ubuntu virtual machine running within VirtualBox, and... since Qt 5 now requires OpenGL for any kind of application, well... that can cause problems depending on what you do and it certainly causes problems in my case (because of my use of LLVM). Anyway, the 'solution' consists of using indirect rendering, e.g.

    $ LIBGL_ALWAYS_INDIRECT=1 ./myapp

    Really not ideal, but at least it's now working fine. (Seriously, why on earth does Qt 5 forces you to use OpenGL in an application which doesn't actually make use of it?!)

Similar Threads

  1. Qt 5 build using clang/llvm on Linux
    By faizol in forum Installation and Deployment
    Replies: 0
    Last Post: 11th October 2012, 04:32
  2. Qt + LLVM's JIT
    By agarny in forum Qt Programming
    Replies: 3
    Last Post: 24th November 2011, 12:45
  3. installation problem of qt in ubuntu 10.10
    By sachinmcajnu in forum Newbie
    Replies: 1
    Last Post: 12th April 2011, 16:50
  4. Qt Creator Problem with Ubuntu 10.04
    By Hany in forum Qt Tools
    Replies: 1
    Last Post: 8th June 2010, 12:26
  5. Qt + LLVM
    By bunjee in forum Qt Programming
    Replies: 0
    Last Post: 4th November 2008, 17:14

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.