c++ – Difference in performance numbers with clang – usage of Ninja generator and visual studio generator


Recently, have been trying to experiment by building the same application in Clang with the ninja generator and visual studio generator using cmake. Ninja Generator is observed to give a clear advantage in terms of performance while comparing with Visual Studio Generator

The performance here refers to runtime performance of the application we are trying to run after compilation

Ninja Generator – Internally uses clang.exe and clang++.exe
Visual Studio Generator – Internally uses clang-cl.exe
Clang version – 17.0.3

Flags used while compiling same file in both generators ;

Visual Studio Generator –

/O2 /Ob2 /D _WINDLL /D _MBCS /D WIN32 /D _WINDOWS /D NDEBUG /D _XOPEN_SOURCE=600 /D "CMAKE_INTDIR=\"Release\"" /EHsc /MD /GS /arch:AVX512 /GR /Gd /TC --target=amd64-pc-windows-msvc -Xclang -fopenmp

Ninja Generator –

-O3 -DNDEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrt -std=gnu11 -Wshadow -Wstrict-prototypes -Wpointer-arith -Wmissing-prototypes -Werror=implicit-int -Werror=implicit-function-declaration -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wunreachable-code-break -Wunreachable-code-return -Wdouble-promotion -march=native -fopenmp=libomp -MD -MT

Wondering what could cause this difference in performance. Please do chime in with thoughts here. Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *