--- gcc/gcc/cppbuiltin.c +++ gcc/gcc/cppbuiltin.c @@ -99,6 +99,8 @@ define_builtin_macros_for_compilation_flags (cpp_reader *pfile) cpp_define (pfile, "__OPTIMIZE_SIZE__"); if (optimize) cpp_define (pfile, "__OPTIMIZE__"); + if (optimize >= 2) + cpp_define (pfile, "_FORTIFY_SOURCE=2"); if (fast_math_flags_set_p (&global_options)) cpp_define (pfile, "__FAST_MATH__"); --- gcc/gcc/doc/invoke.texi +++ gcc/gcc/doc/invoke.texi @@ -6658,6 +6658,12 @@ also turns on the following optimization flags: Please note the warning under @option{-fgcse} about invoking @option{-O2} on programs that use computed gotos. +NOTE: In ALT Linux gcc 4.1.1-alt9 and later versions, +@option{-D_FORTIFY_SOURCE=2} is set by default, and is activated when +@option{-O} is set to 2 or higher. This enables additional compile-time +and run-time checks for several libc functions. To disable, specify +either @option{-U_FORTIFY_SOURCE} or @option{-D_FORTIFY_SOURCE=0}. + @item -O3 @opindex O3 Optimize yet more. @option{-O3} turns on all optimizations specified