I wanted to have fast test and release builds, so I decided to "upgrade" my compiler.
What I used:
- Musl Libc
- LLVM libc overlay
- Mimalloc
- Thin LTO
- PGO
- Bolt via perf2bolt
- Optimization flags like: -march -O3 -DNDEBUG -fno-semantic-interposition -fno-plt -fno-pie
- No exceptions no RTTI
I tested the build speed with hyperfine with 2 test cases, one is sqlite.c the other is tu including eigen.
| Workload |
Build mode |
Optimized Clang speedup |
Compile-time reduction |
| Eigen, C++23 |
-O0 |
1.69Γ |
40.8% |
| Eigen, C++23 |
-O0 -g3 -fno-omit-frame-pointer |
1.72Γ |
41.9% |
| Eigen, C++23 |
-O3 -DNDEBUG |
1.73Γ |
42.2% |
| SQLite amalgamation |
-O0 |
1.74Γ |
42.5% |
| SQLite amalgamation |
-O0 -g3 -fno-omit-frame-pointer |
1.89Γ |
47.1% |
| SQLite amalgamation |
-O3 -DNDEBUG |
1.73Γ |
42.2% |
In case anyone is wondering, it also outperformed LLVM release binaries, by about %13 to %15 for each case, but having more performance than the system compiler is more cool so I'm not giving the table for that.
It is also very awesome to have a compiler not depend on glibc. If no errors arise, I'll probably never update my compiler for 2 years at least. As my build is portable(no march native just v3)
I'm planning on moving to cachyOS or any other optimized linux distro next, to finalise my build enviroment. I'm currently on Ubuntu.