aboutsummaryrefslogtreecommitdiff
blob: 36c576211df146b73702d3e9245e1ed9db19ce6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Enable -D_FORTIFY_SOURCE=2 by default.


--- a/gcc/c-family/c-cppbuiltin.c
+++ b/gcc/c-family/c-cppbuiltin.c
@@ -951,6 +951,9 @@ c_cpp_builtins (cpp_reader *pfile)
   builtin_define_with_value ("__REGISTER_PREFIX__", REGISTER_PREFIX, 0);
   builtin_define_with_value ("__USER_LABEL_PREFIX__", user_label_prefix, 0);
 
+  /* Fortify Source enabled by default w/optimization.  */
+  cpp_define (pfile, "_FORTIFY_SOURCE=((defined __OPTIMIZE__ && __OPTIMIZE__ > 0) ? 2 : 0)");
+
   /* Misc.  */
   if (flag_gnu89_inline)
     cpp_define (pfile, "__GNUC_GNU_INLINE__");