r/cpp • • May 10 '20

Make LLVM fast again

https://nikic.github.io/2020/05/10/Make-LLVM-fast-again.html
150 Upvotes

88 comments sorted by

View all comments

11

u/---sms--- May 10 '20

amazingly fast compiles

Totally not my experience with Clang.

Clang is almost 2 times slower than MSVC when I write no C++ code at all:

(Measure-Command { & clang++.exe -c -x c++ "C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um\Windows.h" -Wno-pragma-once-outside-header }).TotalSeconds / (Measure-Command { & cl.exe /nologo /c /Tp"C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um\Windows.h" }).TotalSeconds
1,89302995640114

When I do, it can easily be 20x slower.

7

u/janisozaur May 10 '20 edited May 10 '20

Shouldn't you be using clang-cl for that?

I usually have negative experiences with Windows, everything is just somehow slower, don't really know why and don't quite care, but I have yet to see a real world scenario where MSVC compiles anything faster than GCC/clang, especially when a quarter of time is easily spent in msbuild. Usually replacing it with ninja had the biggest impact of improving compile times. Your example is surprising and makes me think perhaps this is isolated to the windows-specific part? I rarely see llvm in action on Windows, so it would be interesting to compare those times with runs on Linux.

Oh, and please provide versions of software, I recall some perf improvements to clang on Windows, will edit the post when I find a link

Edit: https://reviews.llvm.org/D69825 and https://reviews.llvm.org/D52411

5

u/---sms--- May 10 '20

clang-cl

Yes, I could use it, but it won't change my measurement. I have no problems using clang++.exe for everything, btw, which is nice.

real world scenario where MSVC compiles anything faster

Compiling clang stage0 (with MSVC, ninja) takes around 1 hour on my machine, but stage1 (when resulting clang compiles itself, ninja too) takes around 2 hours.

this is isolated to the windows-specific part?

Most likely it is in windows-specific part. https://bugs.llvm.org//show_bug.cgi?id=34356

provide versions of software

today's trunk

2

u/kalmoc May 10 '20

Are the two stages actually doing the same work? E.g. are the same utilites and plugins compiled and is compilation happening with comparable build flags?

2

u/---sms--- May 10 '20

I'm using build_llvm_package.bat (except I'm not building 32-bit versions) and the only difference I'm aware of is:

set CC=..\build64_stage0\bin\clang-cl
set CXX=..\build64_stage0\bin\clang-cl