I was wondering why compiles were so slow and noticed that clang-cl.exe is never consuming more than ~16.5% CPU on my laptop. This is an i7-7700HQ, 32GB memory, running Windows 10 Pro.
Memory and disk use appear trivial as well, and the computer was otherwise mostly idle at the time.
Compiling a trivial hello-world takes 11 seconds:
$ clang --version
clang version 4.0.1
Target: i686-pc-windows-msvc
Thread model: posix
InstalledDir: C:\LLVM\bin
Compiling the same program under the Linux subsystem and clang-3.5 takes 0.16seconds. The Visual Studio commandline compiler is likewise almost instant.
This is release_40 from one of the git mirrors, build built as part of the LLVM tree using Visual Studio 2015 command prompt, with (I think, not 100% sure, don’t know cmake well enough to figure out after the fact) the following cmake invovations:
I suspect this figure just represents the fact that Clang is using 1/8
cores (plus some help from others for I/O in the OS, perhaps). Even a
debug Clang uses 100% of one core in my experience.
CMAKE_BUILD_TYPE=Debug will result in a non-optimized compiler. Although I don’t have numbers at hand, you might want to set CMAKE_BUILD_TYPE=Release.
Also -DLLVM_ENABLE_ASSERTIONS=On
The build system at some point had a warning informing users that this might produce an order of magnitude (or more) slower compiler.
I’d suggest you keep an optimized and unoptimized compiler around. Though even then, Hello World doesn’t take me 10 seconds to compile… so maybe there’s other things going on. Sounds like you’d want one set of LLVM stuff with all the debugging knobs turned on (exactly as you’ve built) & use that with your frontend, and another, release build, for running clang, etc for practical porpoises.
You’ll need a PDB, though, to get anything useful out of it. You can either re-configure and re-build with -DCMAKE_BUILD_TYPE=RelWithDebInfo, or you can try hacking the VS solution to add “/DEBUG” to the clang.exe linker options. Then it will only be a short re-link.
Having previous modified the generated projects before I highly advise against it. It’s tedious, you have to get all of them, and cmake will blow it away the next time you regenerate. You are much better off using RelWithDebugInfo. Note that the last time I generated VS solutions it generated all 3 and I could switch between them. Check if you can just switch your solution’s configuration.
Assuming you are using Visual Studio IDE, choose build configuration in toolbar and build again. Debug by default.
CMAKE_BUILD_TYPE should not be set for Visual Studio Generator.
Debug configuration with Visual C++ enables expensive iterator checks (_ITERATOR_DEBUG_LEVEL). They do catch bugs sometime.
For example, vector::operator * is: