blob: 4cdf5f6ad150fd4e674ece4607b6a86f6a4cd51f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
Taken Debian's patch and removed docs matches:
https://salsa.debian.org/toolchain-team/gcc.git
Also see https://bugs.gentoo.org/621036 where
initially Gentoo used too complicated macro.
# DP: Turn on -D_FORTIFY_SOURCE=2 by default for C, C++, ObjC, ObjC++,
# DP: if the optimization level is > 0
--- a/gcc/c-family/c-cppbuiltin.cc
+++ b/gcc/c-family/c-cppbuiltin.cc
@@ -1510,6 +1510,16 @@ 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);
+#if !defined(ACCEL_COMPILER)
+ #ifndef GENTOO_FORTIFY_SOURCE_LEVEL
+ #define GENTOO_FORTIFY_SOURCE_LEVEL 2
+ #endif
+
+ /* F_S enabled by default for optimization levels > 0, except for ASAN: https://github.com/google/sanitizers/issues/247 */
+ if (optimize && ! (flag_sanitize & SANITIZE_ADDRESS))
+ builtin_define_with_int_value ("_FORTIFY_SOURCE", GENTOO_FORTIFY_SOURCE_LEVEL);
+#endif
+
/* Misc. */
if (flag_gnu89_inline)
cpp_define (pfile, "__GNUC_GNU_INLINE__");
|