From d7b054c3f6f1e7171e95c1b58bd67c3e497f4072 Mon Sep 17 00:00:00 2001 From: Nik Bougalis Date: Sat, 9 Aug 2014 13:27:01 -0700 Subject: [PATCH] When compiling debug builds with GCC use _FORTIFY_SOURCE=2: This gcc/glibc feature adds some (supposedly) lightweight checks which can help detect errors such as buffer overflows. --- SConstruct | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/SConstruct b/SConstruct index 99bc21de38..d8cfd2712d 100644 --- a/SConstruct +++ b/SConstruct @@ -355,6 +355,14 @@ def config_env(toolchain, variant, env): # Why is this only for gcc?! env.Append(CCFLAGS=['-Wno-unused-local-typedefs']) + # If we are in debug mode, use GCC-specific functionality to add + # extra error checking into the code (e.g. std::vector will throw + # for out-of-bounds conditions) + if variant == 'debug': + env.Append(CPPDEFINES={ + '_FORTIFY_SOURCE': 2 + }) + elif toolchain == 'msvc': env.Append (CPPPATH=[ os.path.join('src', 'protobuf', 'src'),