[SOLVED] Using Clang with QtCreator, very slow builds.
I have recently ported a small application of mine to C++11 (and with that I mean I am now using a very small subset of the new language features) but find that after the port and the change-over to Clang, build times are extremely long.
Prior to the change I could clean and build everything in approx 1 min (GCC 4.6.3), after the changes and using Clang it now (consistently) takes 4+ min to compile the same application (this is all done via QtCreator).
My setup is as follows:
Ubuntu 12.04 LTS (32-bit)
Qt 5.1.2 (built from source about 2 months ago)
QtCreator 2.8.81 (based on Qt 5.1.2, built with GCC 4.6.3 at the same time as I built Qt)
LLVM/Clang 3.4 (obtained and built exactly as per these instructions about a week ago: http://clang.llvm.org/get_started.html )
I have also tried building a different branch of the qt creator source as per this article: http://procedural.tumblr.com/post/50723377576
but find that my version of qmake is incompatible with the source from the clang-stable branch (I think...keep getting an error when running qmake about some plugin not being accessible/available...crap, I should have noted the error down last night...if it is important, I will find it again when I get home this afternoon).
I have run out of ideas.
Thanks for your help!
wip/clang branch is not for compiling projects using clang! It is an experiment in using clang as a code model for Qt Creator itself.
You can safely use standard Qt Creator (self-built or prebuilt), just set the clang Kit and it should work. I am surprised it takes longer for you to compile. I've always used prebuilt clang from apt-get (currently it's version 3.2 in Kubuntu 13.10) and it usually compiles stuff about 30% faster than GCC.
[quote author="sierdzio" date="1380263679"]wip/clang branch is not for compiling projects using clang! It is an experiment in using clang as a code model for Qt Creator itself.[/quote]
Aaah, thanks for clearing that confusion up for me Sierdzio!
[quote]You can safely use standard Qt Creator (self-built or prebuilt), just set the clang Kit and it should work. I am surprised it takes longer for you to compile. I've always used prebuilt clang from apt-get (currently it's version 3.2 in Kubuntu 13.10) and it usually compiles stuff about 30% faster than GCC.[/quote]
The official package for Ubuntu 12.04 still sits on 3.06 and the other (latest) available pre-built binaries (http://llvm.org/releases/download.html#3.3) don't seem to match my 32-bit system.
I could probably either upgrade my distro or downgrade my clang version which would solve the immediate problem, but not answer the question as to why all my self-builts don't seem to perform as they should...I guess I have a bit more reading to do, I must have messed something up somewhere... :)
Or maybe newer clang is slower :)
OK, found the problem. When building LLVM from source (as per http://clang.llvm.org/get_started.html ), step six mentions the following re the default configuration:
"This builds both LLVM and Clang for debug mode."
I misinterpreted this to mean that it is required for debugging my software (as a drop-in replacement for gdb...you know what they say about assumptions...), but I was (horribly) mistaken. What it does is to build LLVM and Clang in debug mode for LLVM and Clang contributors.
What you actually want is to run configure with the "--enable-optimized" flag set, i.e. replace the configure command under step 6 with:
Build time down to <30 seconds... :D
Haha, yes, sometimes assumptions can cause unnecessary problems :) OK so now it seems you're all set up pretty nicely.
Very nicely indeed, thanks! Clang rocks :)