CFLAGS
also: C compiler flags
CFLAGS is an environment variable that passes compiler flags and options to the C compiler during software compilation, controlling how code is optimized, debugged, and compiled.
CFLAGS stands for C compiler flags and is used primarily when compiling C and C++ source code from their raw form. When you run ./configure && make to build software from source, the build system reads CFLAGS to determine what options to pass to gcc, clang, or another C compiler.
Common CFLAGS include -O2 (optimization level 2), -g (include debug symbols), and -Wall (enable all compiler warnings). For example: CFLAGS="-O3 -march=native" ./configure tells the compiler to use aggressive optimization and tune for your specific CPU.
CFLAGS affects performance, binary size, and debuggability. Higher optimization levels (-O3) produce faster code but larger binaries and longer compile times, while -g is essential for debugging but increases binary size. You can set CFLAGS in your shell environment before running configure, or pass them directly on the command line.