Code You Build Yourself Gets the Compiler's Defaults, Not the Distribution's Flags
A distribution passes hardening flags when it builds its packages. Almost none of those flags are defaults of the compiler it ships. Code you build yourself in that image, without passing those flags, gets only the toolchain’s defaults.
On Debian 13, Fedora 44 and CentOS Stream 10 cloud images with gcc and clang installed, both compilers at -O2 with no hardening flag build a binary with no stack canary, no fortify (bounds-checked libc calls), no stack-clash protection (stack probing) and only partial RELRO, where full RELRO makes the GOT read-only. On Debian both apply PIE (an executable the kernel can load at a random address). Some distributions’ compilers apply the four themselves. On Ubuntu 24.04 (gcc 13.2.0 as first shipped, 13.3.0 in 24.04.5), gcc applies all four to an executable (LP#2078989: its specs attach -z now to -pie), and Ubuntu’s clang applies PIE alone. On Wolfi clang applies all four, and gcc does when the image’s default PATH finds the wrapper (a script that adds flags) at /usr/local/bin/gcc; with /usr/bin/gcc found first, gcc applies only the canary. On Arch both compilers apply the canary and none of the other three.
Build images differ the same way. The manylinux images and Docker’s gcc images apply none of the four (fortify reads unsupported on manylinux2014); cimg/base, GitHub’s ubuntu-slim and the Heroku 24 and Google builders, each with gcc 13.3.0, apply all four to an executable.
The OpenSSF guide says to whoever builds a compiler: “where practical make the generated compiler’s default options the secure options.”
chard 0.2.1 read these defaults on 2026-11-29, on distribution, cloud, container and build images. The tables here are examples. Every reading is at chard.page, which keeps measuring. chard reads no package build, so an off says nothing about a distribution’s packages, and no row ranks one distribution against another.
| System | Compiler | canary | PIE | RELRO | fortify | stack-clash |
|---|---|---|---|---|---|---|
| Debian 13.8 | gcc 14.2.0 | off | on | partial | off | off |
| Debian 13.8 | clang 19.1.7 | off | on | partial | off | off |
| Fedora 44 | gcc 16.2.1 | off | off | partial | off | off |
| Fedora 44 | clang 22.1.8 | off | off | partial | off | off |
| CentOS Stream 10 | gcc 14.4.1 | off | off | partial | off | off |
| CentOS Stream 10 | clang 23.1.3 | off | off | partial | off | off |
| Ubuntu 24.04.5 | gcc 13.3.0 | on | on | on | on | on |
| Ubuntu 24.04.5 | clang 18.1.3 | off | on | partial | off | off |
| Arch Linux | gcc 16.2.1 | on | on | partial | off | off |
| Arch Linux | clang 23.1.5 | on | on | partial | off | off |
Wolfi, /usr/local/bin first | gcc 16.2.0 | on | on | on | on | on |
Wolfi, /usr/bin first | gcc 16.2.0 | on | on | partial | off | off |
| Wolfi | clang 23.1.6 | on | on | on | on | on |
x86_64. “on” means the compiler applies it with no flag. The Debian, Fedora, CentOS Stream, Ubuntu and Arch lines are each distribution’s own image run as a virtual machine; Arch reads the same in its archlinux container. Debian 13.8 and Ubuntu 24.04.5 are point releases; Fedora 44, CentOS Stream 10, Arch and Wolfi are as their repositories stood on 2026-11-29. Wolfi is the wolfi-base container image, read with each PATH order. RELRO on is full RELRO (-z relro -z now); partial is -z relro alone. RELRO is read on a default executable; a shared object or a -no-pie executable from Ubuntu’s gcc reads partial.
How it was measured
chard builds small probe programs with the toolchain under test, runs them, and reads the binaries it built. Every check is built three ways: the flag forced on, forced off, and as configured. A verdict is given only when the forced builds differ as expected, so a compiler that accepts a flag and ignores it does not read on. One exception: some toolchains add the flag after the command line, so the forced-off build still has the protection; there chard reads the as-configured build and records the flag that forced it. Wolfi’s gcc wrapper, the nixpkgs wrapper and the clang of Alpine, Arch, CachyOS and Chimera are read that way, for the checks where the flag is appended.
Every reading here and on chard.page uses chard’s bare-optimized profile: -O2 and no other flag. It has -O2 because glibc applies _FORTIFY_SOURCE only when compiling with optimization.
A default here is whatever the installed toolchain (driver, compiler, linker and C library) does at -O2 with no hardening flag passed, whether that comes from upstream, from configure options, from a distribution’s patches or from a wrapper. The compiler is the one gcc or clang names on the PATH chard is started with, the image’s own unless stated. chard runs it in a cleared environment that keeps that PATH and any variable passed with --env.
On most distribution and container images the compilers were installed or upgraded for the measurement, from the image’s own repositories that day. The install also upgraded dependencies, the C library on some images. The build images and GitHub’s runners were measured with the compiler they came with.
The package build’s flags below are a control, run outside chard on 2026-11-25 in the public images named below: each is what the image’s own tool prints, one run each.
The package build and the compiler
Each image prints what its package build passes: dpkg-buildflags --get on debian:13 and ubuntu:26.04, rpm --eval '%{optflags}' and '%{build_ldflags}' on fedora:44, and /etc/makepkg.conf on archlinux. Each cell reads package build / gcc alone: what the build passes, then what gcc applies by itself on the same release. x86_64.
| Protection | Debian 13 | Fedora 44 | Arch | Ubuntu 26.04 |
|---|---|---|---|---|
| stack protector | passed / off | passed / off | not passed / on | passed / on |
_FORTIFY_SOURCE | =2 / off | =3 / off | =3 / off | =3 / on |
| stack-clash protection | passed / off | passed / off | passed / off | passed / on |
-fcf-protection (control-flow marking) | passed / unsupported (the link drops the marking) | passed / off | passed / off | passed / on |
| PIE | not passed / on | specs file / off | not passed / on | not passed / on |
| RELRO | -z relro / partial | -z relro -z now / partial | -z relro -z now / partial | -z relro / on |
-Werror=format-security | passed / off | passed / off | passed / off | passed / off |
-D_GLIBCXX_ASSERTIONS | not passed / off | passed / off | passed / off | not passed / off |
On Debian and Fedora the package build passes most of these and the compiler alone applies PIE or nothing. Arch’s file passes no stack protector and no PIE, the two things its gcc does itself. On Ubuntu 26.04 dpkg and gcc both supply most of them.
Debian’s flags are documented in dpkg-buildflags(1).
Related: jvoisin/compiler-flags-distro tabulates the flags distributions use to build their packages. Its README says not to expect them in a distribution’s compiler.
Docker’s gcc images
Docker’s official gcc images build their compiler from source on a Debian base. The gcc 14 Dockerfile starts from buildpack-deps:trixie and runs configure with --build, --disable-multilib and --enable-languages=c,c++,fortran,go. Debian 13’s own gcc 14.2.0 records a line containing --enable-default-pie. Docker’s gcc 14, 15 and 16 read PIE off; Debian 13’s gcc, built with that option, reads it on.
Ubuntu 24.04’s gcc applies all four protections to an executable; Debian and Fedora apply them only through the package build. An image built on a distribution inherits its compiler, not its package build; the companion piece shows what that means for Python’s wheels.