Local release build slower than Github release binary

I am trying to build clang on Windows. I configured the project with the following CMake command.

cmake llvm -B D:\build\llvm-18\clang-cl_18-Release -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_C_FLAGS="-fstrict-aliasing /clang:-O3" -DCMAKE_CXX_FLAGS="-fstrict-aliasing /clang:-O3" -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_USE_LINKER=lld -DLLVM_ENABLE_LTO=ON -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_ENABLE_PROJECTS=clang

I set build type as release, enabled optimization flags that clang-cl doesn’t enable by default, and enabled LTO. The compiled clang spends about 1.5x the time, compared to the Github release build, to compile one source file to object file (eliminating linker factors). What optimizations did my build miss?

clang version 18.1.7
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Program Files\LLVM\bin

This GitHub releases for Windows are optimized with PGO too.

2 Likes

You can see exactly how the release binaries are built here: llvm-project/llvm/utils/release/build_llvm_release.bat at main · llvm/llvm-project · GitHub

1 Like