Important: Please read the Qt Code of Conduct -

[SOLVED] 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:

    @0 __memmove_ssse3 memcpy-ssse3.S 1682 0x1348f8c
    1 llvm::PassRegistry::removeRegistrationListener(llvm::PassRegistrationListener*) /usr/lib/i386-linux-gnu/ 0xb0278ddb
    2 llvm::PassRegistrationListener::~PassRegistrationListener() /usr/lib/i386-linux-gnu/ 0xb026aa06
    3 llvm::PassNameParser::~PassNameParser() /usr/lib/i386-linux-gnu/ 0xb026aca2
    4 llvm::cl::list<llvm::PassInfo const*, bool, llvm::PassNameParser>::~list() /home/me/myApp/build/plugins/myApp/ 0xb31eb8a4
    5 __run_exit_handlers exit.c 78 0x1242f51
    6 __GI_exit exit.c 100 0x1242fdd
    7 __libc_start_main libc-start.c 258 0x12294db
    8 _start 0x8068ca1
    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:

    @0 llvm::FoldingSetNodeID::AddPointer(void const*) /usr/lib/i386-linux-gnu/ 0xb074f37a
    1 clang::FunctionProtoType::Profile(llvm::FoldingSetNodeID&, clang::QualType, clang::QualType const*, unsigned int, clang::FunctionProtoType::ExtProtoInfo const&, clang::ASTContext const&) /home/me/myApp/build/ 0x43a6b2e
    2 clang::FunctionProtoType::Profile(llvm::FoldingSetNodeID&, clang::ASTContext const&) /home/me/myApp/build/ 0x43a6dd4
    3 llvm::ContextualFoldingSet<clang::FunctionProtoType, clang::ASTContext&>::NodeEquals(llvm::FoldingSetImpl::Node*, llvm::FoldingSetNodeID const&, unsigned int, llvm::FoldingSetNodeID&) const /home/me/myApp/build/ 0x427d59f
    4 llvm::FoldingSetImpl::FindNodeOrInsertPos(llvm::FoldingSetNodeID const&, void*&) /usr/lib/i386-linux-gnu/ 0xb074fb67
    5 clang::ASTContext::getFunctionType(clang::QualType, clang::QualType const*, unsigned int, clang::FunctionProtoType::ExtProtoInfo const&) const /home/me/myApp/build/ 0x426ecbb
    6 clang::ASTContext::GetBuiltinType(unsigned int, clang::ASTContext::GetBuiltinTypeError&, unsigned int*) const /home/me/myApp/build/ 0x4274243
    7 clang::Sema::LazilyCreateBuiltin(clang::IdentifierInfo*, unsigned int, clang::Scope*, bool, clang::SourceLocation) /home/me/myApp/build/ 0x48baa24
    8 ?? /home/me/myApp/build/ 0x49fde04
    9 clang::Sema::LookupName(clang::LookupResult&, clang::Scope*, bool) /home/me/myApp/build/ 0x4a03d13
    10 clang::Sema::HandleDeclarator(clang::Scope*, clang::Declarator&, llvm::MutableArrayRefclang::TemplateParameterList*) /home/me/myApp/build/ 0x48cb270
    11 clang::Sema::ActOnDeclarator(clang::Scope*, clang::Declarator&) /home/me/myApp/build/ 0x48cb8f3
    12 clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&) /home/me/myApp/build/ 0x47196e1
    13 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, unsigned int, bool, clang::SourceLocation*, clang::Parser::ForRangeInit*) /home/me/myApp/build/ 0x4725883
    14 clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec&, clang::AccessSpecifier) /home/me/myApp/build/ 0x477563f
    15 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*, clang::AccessSpecifier) /home/me/myApp/build/ 0x4775d79
    16 clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) /home/me/myApp/build/ 0x4779c77
    17 clang::Parser::ParseTopLevelDecl(clang::OpaquePtrclang::DeclGroupRef&) /home/me/myApp/build/ 0x4779f48
    18 clang::ParseAST(clang::Sema&, bool, bool) /home/me/myApp/build/ 0x470e49c
    19 clang::ASTFrontendAction::ExecuteAction() /home/me/myApp/build/ 0x4671a57
    20 clang::CodeGenAction::ExecuteAction() /home/me/myApp/build/ 0x456db42
    ... <More>
    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.

  • Nobody, really?...

  • try strace to see which libs are opened and when?

  • Thanks for the suggestion, Thomas. I didn't know about strace, still it didn't bring up anything useful. Now, 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.


    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?!)

  • In Qt4 OpenGL was a "per project" module, but since Qt5 is (almost entirely) all about QML and QtQuick2, OpenGL support is essential and built deep in QtGui. So the solution to get rid of GL dependencies completely is to have a whole separate Qt5 build with no OpenGL support, which will be highly limited in usage, but able to provide QWidget based projects that don't use OpenGL without dependencies on OpenGL.

  • Thanks for the clarification, utcenter.

    I can understand the need for OpenGL for QML and QtQuick2, I just wish there had been a way to avoid OpenGL for those of us who don't use QML or QtQuick2.

    Then again, it's probably true that, nowadays, we could rightly expect any machine to have proper support for OpenGL. It's just too bad that the VitualBox guys still haven't come up with some decent 3D support after all those years.

    Anyway, I might end up using OpenGL in my project, not to mention that I want to be able to use whatever Qt has to offer, so it wouldn't make sense for me to use my own version of Qt 5 with no OpenGL support.

  • I am normally using a Qt build with desktop OpenGL support, by default, Qt normally comes with an ANGLE implementation instead. But I have created another build explicitly for the purpose of building QtGui based applications in order to be able to distribute with minimal external dependencies. The pre-build version of Qt5 comes with a hefty set of dependencies, most of which can be eliminated when not needed. There is a minor inconvenience that the number of different Qt builds you have on your machine grows, but for the time being this is the only way to cut down the number of DLLs you have to ship with your program.

  • Notice that virtualbox has opengl support, I had it running nicely, including composited kwin, on a win7 box, on a previous assignment.
    So give that one another try ;)

  • @utcenter: indeed, it was a 'shock' when I found out that my application now takes much more space once deployed. This aside, I can't afford building a non-OpenGL version of Qt 5. I need to target Windows, Linux (32 and 64 bits) and OS X, so that would be a bit of a nightmare to manage, especially since I am very likely to use OpenGL at some point.

    @Thomas: how do you mean that VirtualBox has OpenGL support? Are you talking about the 3D hardware acceleration? If so, I have tried it: it crashes my Ubuntu 12.04 virtual machine on an OS X host. As for my Ubuntu 12.10 virtual machine, it doesn't crash but it's completely unusable. Bottom line, VirtualBox is great (I have been using it for years), but its 3D support is still really, really bad.

  • Ah, osX, yeah, virtualbox works better on Win.
    On MacOS I had to use vmware for getting opengl to work in there :) Which cost some 50 dollars or so.

  • I tried both VMWare and Parallels before. I didn't fancy VMWare and was, in the end, leaning towards Parallels, but then it badly crashed on me, so I reverted to VirtualBox.

    At the end of the day, everything works fine when I use LIBGL_ALWAYS_INDIRECT and that is what matters to me at this stage. I am not here to fix VirtualBox, just to make sure that my application works on the different platforms I need to support. :)

Log in to reply