https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88345
Bug ID: 88345 Summary: -Os overrides -finline-functions=N on the command line Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- The -Os effect on -falign-functions is documented in a confusing or even contradictory way: Optimize for size. -Os enables all -O2 optimizations except those that often increase code size: -falign-functions -falign-jumps -falign-labels -falign-loops -fprefetch-loop-arrays -freorder-blocks-algorithm=stc It also enables -finline-functions, causes the compiler to tune for code size rather than execution speed, and performs further optimizations designed to reduce code size. The first sentence implies -Os is doesn't enable -finline-functions, but the second sentence contradicts it. The documentation for -finline-functions=n doesn't help. It just says: If n is not specified or is zero, use a machine-dependent default. I haven't been able to find a way to determine the machine-dependent default except by testing. An experiment with an x86_64 compiler shows that -Os overrides whatever -falign-functions option is specified on the command line. Curiously, though, with -O2 GCC does honor the -falign-functions=n setting. Clang, on the other hand, does the opposite: it honors the -falign-functions=n setting with -Os and ignores it with -O2. $ cat u.c && gcc -Os -c -Wall -falign-functions=2 u.c && objdump -d u.o void f (void) { } void g (void) { } u.o: file format elf64-x86-64 Disassembly of section .text: 0000000000000000 <f>: 0: c3 retq 0000000000000001 <g>: 1: c3 retq