| 1 |
Enable -D_FORTIFY_SOURCE=2 by default |
| 2 |
|
| 3 |
|
| 4 |
--- a/gcc/doc/invoke.texi |
| 5 |
+++ b/gcc/doc/invoke.texi |
| 6 |
@@ -5973,6 +5973,11 @@ also turns on the following optimization flags: |
| 7 |
Please note the warning under @option{-fgcse} about |
| 8 |
invoking @option{-O2} on programs that use computed gotos. |
| 9 |
|
| 10 |
+NOTE: In Gentoo, @option{-D_FORTIFY_SOURCE=2} is set by default, and is |
| 11 |
+activated when @option{-O} is set to 2 or higher. This enables additional |
| 12 |
+compile-time and run-time checks for several libc functions. To disable, |
| 13 |
+specify either @option{-U_FORTIFY_SOURCE} or @option{-D_FORTIFY_SOURCE=0}. |
| 14 |
+ |
| 15 |
@item -O3 |
| 16 |
@opindex O3 |
| 17 |
Optimize yet more. @option{-O3} turns on all optimizations specified |
| 18 |
--- a/gcc/gcc.c |
| 19 |
+++ b/gcc/gcc.c |
| 20 |
@@ -741,6 +741,7 @@ static const char *cpp_unique_options = |
| 21 |
%{H} %C %{D*&U*&A*} %{i*} %Z %i\ |
| 22 |
%{fmudflap:-D_MUDFLAP -include mf-runtime.h}\ |
| 23 |
%{fmudflapth:-D_MUDFLAP -D_MUDFLAPTH -include mf-runtime.h}\ |
| 24 |
+ %{!U_FORTIFY_SOURCE:%{!D_FORTIFY_SOURCE:%{!D_FORTIFY_SOURCE=*:-D_FORTIFY_SOURCE=2}}}\ |
| 25 |
%{E|M|MM:%W{o*}}"; |
| 26 |
|
| 27 |
/* This contains cpp options which are common with cc1_options and are passed |