From 5b51f9e11eda3aeb3a13f50dcbf73320d085f349 Mon Sep 17 00:00:00 2001 From: Arkadiusz Hiler Date: Tue, 7 May 2019 14:54:35 +0300 Subject: meson: Use -D_FORTIFY_SOURCE=2 on optimized builds Some distribution enable _FORTIFY_SOURCE implicitly if user sets of -O1 greater in the CFLAGS, which may cause surprise compile failures. Let's fortify explicitly and for everyone with default build, since the checks provided are good. Cc: Eero Tamminen Signed-off-by: Arkadiusz Hiler Reviewed-by: Petri Latvala --- meson.build | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/meson.build b/meson.build index 503180ed..a05e912c 100644 --- a/meson.build +++ b/meson.build @@ -256,6 +256,13 @@ config.set10('HAVE_MEMFD_CREATE', have) add_project_arguments('-D_GNU_SOURCE', language : 'c') add_project_arguments('-include', 'config.h', language : 'c') +# FEATURE_TEST_MACROS(7) +# performs lightweight overflow checks on quite a few libc functions +# requires -O optimizations +if ['debugoptimized', 'release', 'minsize'].contains(get_option('buildtype')) + add_project_arguments('-D_FORTIFY_SOURCE=2', language : 'c') +endif + config.set('PACKAGE_NAME', meson.project_name()) config.set_quoted('PACKAGE_VERSION', meson.project_version()) config.set_quoted('PACKAGE', meson.project_name()) -- cgit v1.2.3