Host-Tuned GCC for Faster Compilation

https://lobste.rs/rss Hits: 23
Summary

A while ago, I became interested in reducing my compile times, and examined various methods for this.This blog post is about enabling all compiler options that I believe can make gcc faster when compiling code, and measuring the gains I got as a result.How to Build It#mkdir build-gcc16 cd build-gcc16 ../gcc-16.1.0/configure \ --prefix="$HOME/opt/gcc16-super" \ --program-prefix=super- \ --enable-languages=c,c++ \ --disable-multilib \ --with-build-config='bootstrap-native bootstrap-lto bootstrap-O3' make profiledbootstrap -j$(nproc) make install-strip Expect to be waiting for a while on make profiledbootstrap. It took 72 minutes of wall time on my laptop (AMD Ryzen AI MAX+ PRO 395, 16c/32t, -j32).Now, I will break down the various configure options, and what they precisely do. If you wish to see the configure options used to compile any build of gcc, gcc -v will dump them.Configure Options Explained#--with-build-config='bootstrap-native bootstrap-lto bootstrap-O3'--with-build-config selects small Makefile fragments from gcc/config/*.mk that control how the bootstrap stages are compiled. The relevant ones here are:bootstrap-native adds -march=native -mtune=native to the flags, so the resulting compiler binary is optimized for the build host. Without this, the compiler is built with generic x86-64 codegen, and can’t use AVX2, AVX512, etc. Note that this affects the compiler itself, not the code it generates. If you also want the compiler to default to native-tuned output for your programs, see --with-arch/--with-cpu/--with-tune below.bootstrap-lto enables link-time optimization for the bootstrap stages. LTO lets the optimizer work across translation unit boundaries when building the compiler itself, which is a large codebase that benefits from it.bootstrap-O3 raises the optimization level for the bootstrap stages from -O2 to -O3.make profiledbootstrapThis is a make target, not a configure option. It performs a profile-guided optimization (PGO) build: it first builds an ...

First seen: 2026-05-25 12:15

Last seen: 2026-05-26 10:32