From 1a1638cc7f84c431325460cdffdd3e2ff36874f3 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 13 Feb 2020 10:39:57 +0530 Subject: [PATCH] Build with _FORTIFY_SOURCE on gcc --- setup.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index b68cb06d5..fc806fc5f 100755 --- a/setup.py +++ b/setup.py @@ -204,6 +204,7 @@ def init_env( if ccver >= (5, 0): df += ' -Og' float_conversion = '-Wfloat-conversion' + fortify_source = '-D_FORTIFY_SOURCE=2' if cc == 'gcc' else '' optimize = df if debug or sanitize else '-O3' sanitize_args = get_sanitize_args(cc, ccver) if sanitize else set() cppflags = os.environ.get( @@ -215,7 +216,7 @@ def init_env( cflags = os.environ.get( 'OVERRIDE_CFLAGS', ( '-Wextra {} -Wno-missing-field-initializers -Wall -Wstrict-prototypes -std=c11' - ' -pedantic-errors -Werror {} {} -fwrapv {} {} -pipe {} -fvisibility=hidden' + ' -pedantic-errors -Werror {} {} -fwrapv {} {} -pipe {} -fvisibility=hidden {}' ).format( float_conversion, optimize, @@ -223,6 +224,7 @@ def init_env( stack_protector, missing_braces, '-march=native' if native_optimizations else '', + fortify_source ) ) cflags = shlex.split(cflags) + shlex.split(